Search in sources :

Example 1 with AudioStream

use of ddf.minim.spi.AudioStream in project Minim by ddf.

the class Minim method getLineIn.

/**
	 * Gets an {@link AudioInput}.
	 * 
	 * @param type
	 *            Minim.MONO or Minim.STEREO
	 * @param bufferSize
	 *            int: how long you want the <code>AudioInput</code>'s sample buffer
	 *            to be (ie the size of left, right, and mix buffers)
	 * @param sampleRate
	 *            float: the desired sample rate in Hertz (typically 44100)
	 * @param bitDepth
	 *            int: the desired bit depth (typically 16)
	 * @return an <code>AudioInput</code> with the requested attributes
	 */
public AudioInput getLineIn(int type, int bufferSize, float sampleRate, int bitDepth) {
    AudioInput input = null;
    AudioStream stream = mimp.getAudioInput(type, bufferSize, sampleRate, bitDepth);
    if (stream != null) {
        AudioOut out = mimp.getAudioOutput(type, bufferSize, sampleRate, bitDepth);
        // that will pull samples from it and so forth
        if (out == null) {
            out = new BasicAudioOut(stream.getFormat(), bufferSize);
        }
        input = new AudioInput(stream, out);
    }
    if (input != null) {
        addSource(input);
    } else {
        error("Minim.getLineIn: attempt failed, could not secure an AudioInput.");
    }
    return input;
}
Also used : AudioStream(ddf.minim.spi.AudioStream) AudioOut(ddf.minim.spi.AudioOut)

Example 2 with AudioStream

use of ddf.minim.spi.AudioStream in project Minim by ddf.

the class Minim method stop.

/**
	 * 
	 * Stops Minim and releases all audio resources.
	 * <p>
	 * If using Minim outside of Processing, you must call this to 
	 * release all of the audio resources that Minim has generated.
	 * It will call close() on all of them for you.
	 * 
	 */
public void stop() {
    debug("Stopping Minim...");
    // close all sources and release them
    for (AudioSource s : sources) {
        // null the parent so the AudioSource doesn't try to call removeSource
        s.parent = null;
        s.close();
    }
    sources.clear();
    for (AudioStream s : streams) {
        s.close();
    }
    // stop the implementation
    mimp.stop();
}
Also used : AudioStream(ddf.minim.spi.AudioStream)

Example 3 with AudioStream

use of ddf.minim.spi.AudioStream in project Minim by ddf.

the class Minim method getInputStream.

/**
	 * Get the input as an AudioStream that you can read from yourself, rather
	 * than wrapped in an AudioInput that does that work for you.
	 * 
	 * @param type
	 *            Minim.MONO or Minim.STEREO
	 * @param bufferSize
	 *            int: how long you want the AudioStream's interal 
	 *            buffer to be.
	 * @param sampleRate
	 *            float: the desired sample rate in Hertz (typically 44100)
	 * @param bitDepth
	 *            int: the desired bit depth (typically 16)
	 * @return an AudioStream that reads from the input source of the soundcard.
	 */
public AudioStream getInputStream(int type, int bufferSize, float sampleRate, int bitDepth) {
    AudioStream stream = mimp.getAudioInput(type, bufferSize, sampleRate, bitDepth);
    streams.add(stream);
    return stream;
}
Also used : AudioStream(ddf.minim.spi.AudioStream)

Aggregations

AudioStream (ddf.minim.spi.AudioStream)3 AudioOut (ddf.minim.spi.AudioOut)1