Search in sources :

Example 1 with PipedAudioStream

use of be.tarsos.dsp.io.PipedAudioStream in project cythara by gstraube.

the class AudioDispatcherFactory method fromPipe.

/**
 * Create a stream from a piped sub process and use that to create a new
 * {@link AudioDispatcher} The sub-process writes a WAV-header and
 * PCM-samples to standard out. The header is ignored and the PCM samples
 * are are captured and interpreted. Examples of executables that can
 * convert audio in any format and write to stdout are ffmpeg and avconv.
 *
 * @param source
 *            The file or stream to capture.
 * @param targetSampleRate
 *            The target sample rate.
 * @param audioBufferSize
 *            The number of samples used in the buffer.
 * @param bufferOverlap
 * 			  The number of samples to overlap the current and previous buffer.
 * @return A new audioprocessor.
 */
public static AudioDispatcher fromPipe(final String source, final int targetSampleRate, final int audioBufferSize, final int bufferOverlap) {
    PipedAudioStream f = new PipedAudioStream(source);
    TarsosDSPAudioInputStream audioStream = f.getMonoStream(targetSampleRate, 0);
    return new AudioDispatcher(audioStream, audioBufferSize, bufferOverlap);
}
Also used : TarsosDSPAudioInputStream(be.tarsos.dsp.io.TarsosDSPAudioInputStream) PipedAudioStream(be.tarsos.dsp.io.PipedAudioStream) AudioDispatcher(be.tarsos.dsp.AudioDispatcher)

Aggregations

AudioDispatcher (be.tarsos.dsp.AudioDispatcher)1 PipedAudioStream (be.tarsos.dsp.io.PipedAudioStream)1 TarsosDSPAudioInputStream (be.tarsos.dsp.io.TarsosDSPAudioInputStream)1