com.softsynth.jsyn.util
Class StreamRecorder

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by com.softsynth.jsyn.util.StreamRecorder
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.lang.Runnable

public class StreamRecorder
extends java.io.FilterOutputStream
implements java.lang.Runnable

Record audio data to a Java Output stream. This class uses an audio SampleWriter and a SampleQueueInputStream to collect the data. A thread periodically grabs data and writes it to the stream.

Author:
(C) 1997 Phil Burk, SoftSynth.com, All Rights Reserved
See Also:
SampleQueueInputStream

Field Summary
 SynthInput input
          Connect your audio output to this input.
 
Constructor Summary
StreamRecorder(java.io.OutputStream outStream, int framesPerBuffer, int numBuffers, int channelsPerFrame)
           
StreamRecorder(SynthContext synthContext, java.io.OutputStream outStream, int framesPerBuffer, int numBuffers, int channelsPerFrame)
          Create a recorder that will write an input signal to the outStream.
 
Method Summary
 boolean getLittleEndianness()
           
 boolean isLittleEndian()
           
 void run()
           
 void setLittleEndianness(boolean isLittleEndian)
          Set endianness of the byte stream.
 void start(int time)
          Start recording to the outStream.
 void stop(int time)
          Stop the recording thread.
 void transfer()
           
 
Methods inherited from class java.io.FilterOutputStream
close, flush, write, write, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

input

public SynthInput input
Connect your audio output to this input.

Constructor Detail

StreamRecorder

public StreamRecorder(java.io.OutputStream outStream,
                      int framesPerBuffer,
                      int numBuffers,
                      int channelsPerFrame)

StreamRecorder

public StreamRecorder(SynthContext synthContext,
                      java.io.OutputStream outStream,
                      int framesPerBuffer,
                      int numBuffers,
                      int channelsPerFrame)
Create a recorder that will write an input signal to the outStream.

Parameters:
framesPerBuffer - Number of audio frames in a block to be written to outStream.
numBuffers - Number of buffers to use. Should be at least 2.
channelsPerFrame - is 1 for mono, 2 for stereo
Method Detail

setLittleEndianness

public void setLittleEndianness(boolean isLittleEndian)
Set endianness of the byte stream. This will determine how shorts are converted to bytes. Use false for AIFF files. Use true for WAV files. The default is true.


getLittleEndianness

public boolean getLittleEndianness()

isLittleEndian

public boolean isLittleEndian()

transfer

public void transfer()
              throws java.io.IOException
Throws:
java.io.IOException

run

public void run()
Specified by:
run in interface java.lang.Runnable

start

public void start(int time)
Start recording to the outStream.


stop

public void stop(int time)
Stop the recording thread. This will join() with the thread which may take a moment.