ddf.minim
Class BufferedFileOut

java.lang.Object
  extended byddf.minim.AudioFileOut
      extended byddf.minim.BufferedFileOut
All Implemented Interfaces:
ARListener

public class BufferedFileOut
extends AudioFileOut

BufferedFileOut is an implementation of the AudioFileOut protocol that records to an in-memory buffer and then writes the data to disk when save() is called. Because of this it is possible to specify the file format to use for saving after the audio has already been recorded. It is also possible to save the recorded audio to multiple formats by calling save(type) for each file format you want to save to. Because the saving is performed in the same thread of execution as your Processing sketch, you can expect your sketch to hang while the audio is written to disk. How long it hangs will be proportional to the length of the audio buffer.

Author:
Damien Di Fede

Field Summary
protected  java.util.ArrayList buffers
           
protected  byte[] byteBuffer
           
 
Fields inherited from class ddf.minim.AudioFileOut
AIFC, AIFF, AU, filename, fileType, format, recording, SND, WAV
 
Constructor Summary
BufferedFileOut(javax.sound.sampled.AudioFormat format, java.lang.String name)
          Constructs a BufferedFileOut that expects audio in the given AudioFormat and which will save to a file with given name.
 
Method Summary
 void readSamples(org.tritonus.share.sampled.FloatSampleBuffer fsb)
          Reads samples from fsb and writes them to the left and right AudioBuffers.
 void save()
          Saves the audio in the internal buffer to a file using the current settings for file type and file name.
 void save(javax.sound.sampled.AudioFileFormat.Type type)
          Saves the audio in the internal buffer to a file using the provided file type and the current file name.
 
Methods inherited from class ddf.minim.AudioFileOut
isRecording, setName, setType, startRecording, stopRecording
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

byteBuffer

protected byte[] byteBuffer

buffers

protected java.util.ArrayList buffers
Constructor Detail

BufferedFileOut

public BufferedFileOut(javax.sound.sampled.AudioFormat format,
                       java.lang.String name)
Constructs a BufferedFileOut that expects audio in the given AudioFormat and which will save to a file with given name.

Parameters:
format - the AudioFormat you want to record in
name - the name of the file to save to (not including the extension)
Method Detail

save

public void save()
Saves the audio in the internal buffer to a file using the current settings for file type and file name.

Specified by:
save in class AudioFileOut
See Also:
#save(), #save()

save

public void save(javax.sound.sampled.AudioFileFormat.Type type)
Saves the audio in the internal buffer to a file using the provided file type and the current file name.

Specified by:
save in class AudioFileOut
Parameters:
type - the file format to save the recorded audio as
See Also:
#save(javax.sound.sampled.AudioFileFormat.Type), #save(javax.sound.sampled.AudioFileFormat.Type)

readSamples

public void readSamples(org.tritonus.share.sampled.FloatSampleBuffer fsb)
Description copied from interface: ARListener
Reads samples from fsb and writes them to the left and right AudioBuffers. Then mixes left and right in mix.

Parameters:
fsb - the FloatSampleBuffer to read from