Play a mod or xm track streamed from the specified location

@param module The moudle to play back
@param source The OpenAL source to play the music on
@param start True if the music should be started
@param loop True if the track should be looped
8649
public void play(Module module, int source, boolean loop, boolean start) {
		this.source = source;
		this.loop = loop;
		this.module = module;
		done = false;
		
		ibxm = new IBXM(48000);
		ibxm.set_module(module);
		songDuration = ibxm.calculate_song_duration();

		if (bufferNames != null) {
			AL10.alSourceStop(source);
			bufferNames.flip();
			AL10.alDeleteBuffers(bufferNames);
		}
		
		bufferNames = BufferUtils.createIntBuffer(2);
		AL10.alGenBuffers(bufferNames);
		remainingBufferCount = 2;
		
		for (int i=0;i<2;i++) {
	        stream(bufferNames.get(i));
		}
        AL10.alSourceQueueBuffers(source, bufferNames);
		AL10.alSourcef(source, AL10.AL_PITCH, 1.0f);
		AL10.alSourcef(source, AL10.AL_GAIN, 1.0f); 
		
		if (start) {
			AL10.alSourcePlay(source);
		}
	}
1158795
public void setModule(JSModule module) {
    // An input may only belong to one module.
    checkArgument(module == null || this.module == null || this.module == module);
    this.module = module;
  }
526447
function initScriptMode () {
		//buffer source node
		let bufferNode = context.createBufferSource()
		bufferNode.loop = true;
		bufferNode.buffer = util.create(samplesPerFrame, channels, {context: context})

		node = context.createScriptProcessor(samplesPerFrame)
		node.addEventListener('audioprocess', function (e) {
			//release causes synchronous pulling the pipeline
			//so that we get a new data chunk
			let cb = release;
			release = null;
			cb && cb()

			if (isStopped) return;

			util.copy(shift(e.inputBuffer.length), e.outputBuffer)
		})

		//start should be done after the connection, or there is a chance it won’t
		bufferNode.connect(node)
		bufferNode.start()

		return node;
	}
341234
void setStream(OpenALStreamPlayer stream) {
		if (!soundWorks) {
			return;
		}

		currentMusic = sources.get(0);
		this.stream = stream;
		if (stream != null) {
			this.mod = null;
		}
		paused = false;
	}
572967
def loadModule(self, modName, **userCtx):
        """"""
        for mibSource in self._mibSources:
            debug.logger & debug.FLAG_BLD and debug.logger(
                'loadModule: trying %s at %s' % (modName, mibSource))

            try:
                codeObj, sfx = mibSource.read(modName)

            except IOError as exc:
                debug.logger & debug.FLAG_BLD and debug.logger(
                    'loadModule: read %s from %s failed: '
                    '%s' % (modName, mibSource, exc))
                continue

            modPath = mibSource.fullPath(modName, sfx)

            if modPath in self._modPathsSeen:
                debug.logger & debug.FLAG_BLD and debug.logger(
                    'loadModule: seen %s' % modPath)
                break

            else:
                self._modPathsSeen.add(modPath)

            debug.logger & debug.FLAG_BLD and debug.logger(
                'loadModule: evaluating %s' % modPath)

            g = {'mibBuilder': self,
                 'userCtx': userCtx}

            try:
                exec(codeObj, g)

            except Exception:
                self._modPathsSeen.remove(modPath)
                raise error.MibLoadError(
                    'MIB module "%s" load error: '
                    '%s' % (modPath, traceback.format_exception(*sys.exc_info())))

            self._modSeen[modName] = modPath

            debug.logger & debug.FLAG_BLD and debug.logger(
                'loadModule: loaded %s' % modPath)

            break

        if modName not in self._modSeen:
            raise error.MibNotFoundError(
                'MIB file "%s" not found in search path '
                '(%s)' % (modName and modName + ".py[co]", ', '.join(
                    [str(x) for x in self._mibSources])))

        return self
691407
private void initPlayer(Context ctx) {

		mMediaPlayer = new MediaPlayer();
		mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);

		try {
			mMediaPlayer.setDataSource(ctx, mUri);
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (SecurityException e) {
			e.printStackTrace();
		} catch (IllegalStateException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}

		try {
			mMediaPlayer.prepare();
		} catch (IllegalStateException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}

		mMediaPlayer.setOnCompletionListener(mOnCompletion);
	}
968670
private void doStartPlaying()
	{
		if (currentContainer!=null)
		{
			doStopPlaying();
			if (currentContainer instanceof ModContainer)
			{
				System.out.println(((ModContainer) currentContainer).getCurrentMod().toString());
			}
			Mixer mixer = createNewMixer();
			mixer.setExportFile(wavFileName);
			playerThread = new PlayThread(mixer, this);
			playerThread.start();
		}
	}
1342160
private void startMusic(float pitch, float volume, boolean loop) {
		if (currentMusic != null) {
			currentMusic.stop();
			currentMusic.fireMusicSwapped(this);
		}
		
		currentMusic = this;
		if (volume < 0.0f)
			volume = 0.0f;
		if (volume > 1.0f)
			volume = 1.0f;

		sound.playAsMusic(pitch, volume, loop);
		playing = true;
		setVolume(volume);
		if (requiredPosition != -1) {
			setPosition(requiredPosition);
		}
	}
851241
function runModules(str, modules) {
    var replacements = [],
        module;

    if (Array.isArray(modules) === false) {
        modules = [modules];
    }

    modules.forEach(function forEachModule(module) {
        if (!module) {
            throw new Error("Unknown module '" + module + "'");
        }

        runModule(module, str, replacements);
    });

    return replacements;
}
4866
@Override
    public void onPlayerPlay(SoundCloudTrack track, int position) {
        int offset = mHeaderView == null ? 0 : 1;
        mPlayedTrackPosition = position + offset;
        notifyDataSetChanged();
    }
1242015
function initModule (config, module) {
    // recursively load app dir(s)
    _.each(module.dir.app, appDir => {
        initAppDir(config, module, appDir)
    })
}
996063
public static void runServer (Module... modules)
    {
        Injector injector = Guice.createInjector(modules);
        PresentsServer server = injector.getInstance(PresentsServer.class);
        try {
            // initialize the server
            server.init(injector);

            // check to see if we should load and invoke a test module before running the server
            String testmod = System.getProperty("test_module");
            if (testmod != null) {
                try {
                    log.info("Invoking test module", "mod", testmod);
                    Class<?> tmclass = Class.forName(testmod);
                    Runnable trun = (Runnable)tmclass.newInstance();
                    trun.run();
                } catch (Exception e) {
                    log.warning("Unable to invoke test module '" + testmod + "'.", e);
                }
            }

            // start the server to running (this method call won't return until the server is shut
            // down)
            server.run();

        } catch (Throwable t) {
            log.warning("Unable to initialize server.", t);
            System.exit(-1);
        }
    }
870930
public void editNewModule(Runnable callback) {

        CmsModule module = new CmsModule();
        module.setSite("/");

        editModule(module, true, CmsVaadinUtils.getMessageText(Messages.GUI_MODULES_TITLE_NEW_MODULE_0), callback);

    }
882974
public synchronized void play(InputStream is) {
        boolean chained = false;
        init_jorbis();

        LOG.log(Level.INFO, "play stream: {0}", is);

        loop:
        while (true) {
            int eos = 0;

            int index = oy.buffer(BUFSIZE);
            buffer = oy.data;
            try {
                bytes = is.read(buffer, index, BUFSIZE);
            } catch (IOException ex) {
                LOG.log(Level.SEVERE, null, ex);
                return;
            }

            oy.wrote(bytes);

            if (chained) { //
                chained = false; //
            } //
            else { //
                if (oy.pageout(og) != 1) {
                    if (bytes < BUFSIZE) {
                        break;
                    }
                    LOG.info("Input does not appear to be an Ogg bitstream.");
                    return;
                }
            } //
            os.init(og.serialno());
            os.reset();

            vi.init();
            vc.init();

            if (os.pagein(og) < 0) {
                // error; stream version mismatch perhaps
                LOG.info("Error reading first page of Ogg bitstream data.");
                return;
            }

            if (os.packetout(op) != 1) {
                // no page? must not be vorbis
                LOG.info("Error reading initial header packet.");
                break;
                //      return;
            }

            if (vi.synthesis_headerin(vc, op) < 0) {
                // error case; not a vorbis header
                LOG.info("This Ogg bitstream does not contain Vorbis audio data.");
                return;
            }

            int i = 0;

            while (i < 2) {
                while (i < 2) {
                    int result = oy.pageout(og);
                    if (result == 0) {
                        break; // Need more data
                    }
                    if (result == 1) {
                        os.pagein(og);
                        while (i < 2) {
                            result = os.packetout(op);
                            if (result == 0) {
                                break;
                            }
                            if (result == -1) {
                                LOG.info("Corrupt secondary header.  Exiting.");
                                //return;
                                break loop;
                            }
                            vi.synthesis_headerin(vc, op);
                            i++;
                        }
                    }
                }

                index = oy.buffer(BUFSIZE);
                buffer = oy.data;
                try {
                    bytes = is.read(buffer, index, BUFSIZE);
                } catch (IOException ex) {
                    LOG.log(Level.SEVERE, null, ex);
                }

                if (bytes == 0 && i < 2) {
                    LOG.info("End of file before finding all Vorbis headers!");
                    return;
                }
                oy.wrote(bytes);
            }

            {
                byte[][] ptr = vc.user_comments;

                for (byte[] ptr1 : ptr) {
                    if (ptr1 == null) {
                        break;
                    }
                    LOG.log(Level.INFO, "Comment: {0}", new String(ptr1, 0, ptr1.length - 1));
                }
                LOG.log(Level.INFO, "Bitstream is {0} channel, {1}Hz", new Object[]{vi.channels, vi.rate});
                LOG.log(Level.INFO, "Encoded by: {0}\n", new String(vc.vendor, 0, vc.vendor.length - 1));
            }

            convsize = BUFSIZE / vi.channels;

            vd.synthesis_init(vi);
            vb.init(vd);

            float[][][] _pcmf = new float[1][][];
            int[] _index = new int[vi.channels];

            // test for rate, channels not 44100, 2
            if (vi.channels != Channels || vi.rate != Rate) {
                LOG.log(Level.SEVERE, "Encountered sound file with unusual channels and rates, should get new line!");
                return;
            }

            while (eos == 0) {
                while (eos == 0) {
                    int result = oy.pageout(og);
                    if (result == 0) {
                        break; // need more data
                    }
                    if (result == -1) { // missing or corrupt data at this page position
                        LOG.info("Corrupt or missing data in bitstream; continuing...");
                    } else {
                        os.pagein(og);

                        if (og.granulepos() == 0) { //
                            chained = true; //
                            eos = 1; //
                            break; //
                        } //

                        while (true) {
                            result = os.packetout(op);
                            if (result == 0) {
                                break; // need more data
                            }
                            if (result == -1) { // missing or corrupt data at this page position
                                // no reason to complain; already complained above
                                //System.err.println("no reason to complain; already complained above");
                            } else {
                                // we have a packet.  Decode it
                                int samples;
                                if (vb.synthesis(op) == 0) { // test for success!
                                    vd.synthesis_blockin(vb);
                                }
                                while ((samples = vd.synthesis_pcmout(_pcmf, _index)) > 0) {
                                    float[][] pcmf = _pcmf[0];
                                    int bout = (samples < convsize ? samples : convsize);

                                    // convert doubles to 16 bit signed ints (host order) and
                                    // interleave
                                    for (i = 0; i < vi.channels; i++) {
                                        int ptr = i * 2;
                                        //int ptr=i;
                                        int mono = _index[i];
                                        for (int j = 0; j < bout; j++) {
                                            int val = (int) (pcmf[i][mono + j] * 32767.);
                                            if (val > 32767) {
                                                val = 32767;
                                            }
                                            if (val < -32768) {
                                                val = -32768;
                                            }
                                            if (val < 0) {
                                                val |= 0x8000;
                                            }
                                            convbuffer[ptr] = (byte) (val);
                                            convbuffer[ptr + 1] = (byte) (val >>> 8);
                                            ptr += 2 * (vi.channels);
                                        }
                                    }
                                    outputLine.write(convbuffer, 0, 2 * vi.channels * bout);
                                    vd.synthesis_read(bout);
                                }
                            }
                        }
                        if (og.eos() != 0) {
                            eos = 1;
                        }
                    }
                }

                if (eos == 0) {
                    index = oy.buffer(BUFSIZE);
                    buffer = oy.data;
                    try {
                        bytes = is.read(buffer, index, BUFSIZE);
                    } catch (IOException ex) {
                        LOG.log(Level.SEVERE, null, ex);
                        return;
                    }

                    if (bytes == -1) {
                        break;
                    }
                    oy.wrote(bytes);
                    if (bytes == 0) {
                        eos = 1;
                    }
                }
            }

            os.clear();
            vb.clear();
            vd.clear();
            vi.clear();
        }

        oy.clear();

        if (is != null) {
            try {
                is.close();
            } catch (IOException ex) {
                LOG.log(Level.SEVERE, null, ex);
            }
        }
    }
974623
def play_async(cls, file_path, on_done=None):
        
        thread = threading.Thread(
            target=AudioPlayer.play, args=(file_path, on_done,))
        thread.start()
537432
def load_jamfile(self, dir, jamfile_module):
        """"""
        assert isinstance(dir, basestring)
        assert isinstance(jamfile_module, basestring)

        # See if the Jamfile is where it should be.
        is_jamroot = False
        jamfile_to_load = b2.util.path.glob([dir], self.JAMROOT)
        if jamfile_to_load:
            if len(jamfile_to_load) > 1:
                get_manager().errors()(
                    "Multiple Jamfiles found at '{}'\n"
                    "Filenames are: {}"
                    .format(dir, ' '.join(os.path.basename(j) for j in jamfile_to_load))
                )
            is_jamroot = True
            jamfile_to_load = jamfile_to_load[0]
        else:
            jamfile_to_load = self.find_jamfile(dir)

        dir = os.path.dirname(jamfile_to_load)
        if not dir:
            dir = "."

        self.used_projects[jamfile_module] = []

        # Now load the Jamfile in it's own context.
        # The call to 'initialize' may load parent Jamfile, which might have
        # 'use-project' statement that causes a second attempt to load the
        # same project we're loading now.  Checking inside .jamfile-modules
        # prevents that second attempt from messing up.
        if not jamfile_module in self.jamfile_modules:
            previous_project = self.current_project
            # Initialize the jamfile module before loading.
            self.initialize(jamfile_module, dir, os.path.basename(jamfile_to_load))

            if not jamfile_module in self.jamfile_modules:
                saved_project = self.current_project
                self.jamfile_modules[jamfile_module] = True

                bjam.call("load", jamfile_module, jamfile_to_load)

                if is_jamroot:
                    jamfile = self.find_jamfile(dir, no_errors=True)
                    if jamfile:
                        bjam.call("load", jamfile_module, jamfile)

                # Now do some checks
                if self.current_project != saved_project:
                    from textwrap import dedent
                    self.manager.errors()(dedent(
                        """
                        The value of the .current-project variable has magically changed
                        after loading a Jamfile. This means some of the targets might be
                        defined a the wrong project.
                        after loading %s
                        expected value %s
                        actual value %s
                        """
                        % (jamfile_module, saved_project, self.current_project)
                    ))

                self.end_load(previous_project)

                if self.global_build_dir:
                    id = self.attributeDefault(jamfile_module, "id", None)
                    project_root = self.attribute(jamfile_module, "project-root")
                    location = self.attribute(jamfile_module, "location")

                    if location and project_root == dir:
                        # This is Jamroot
                        if not id:
                            # FIXME: go via errors module, so that contexts are
                            # shown?
                            print "warning: the --build-dir option was specified"
                            print "warning: but Jamroot at '%s'" % dir
                            print "warning: specified no project id"
                            print "warning: the --build-dir option will be ignored"
960234
public void open() throws ModbusException {

        // Start the listener if it isn' already running

        if (!isRunning) {
            try {
                listenerThread = new Thread(listener);
                listenerThread.start();
                isRunning = true;
            }
            catch (Exception x) {
                closeListener();
                throw new ModbusException(x.getMessage());
            }
        }
    }