ddf.minim
Class StreamFileOut

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

public class StreamFileOut
extends AudioFileOut

StreamFileOut using the Tritonus AudioOutputStream class to stream audio directly to disk. The limitation of this approach is that the file format and the file name must be known before recording begins because the file must be created. The advantage is that you do not incur the overhead of an in-memory buffer and saving will not cause your sketch to hang because all the audio is already on disk and all that must be done is closing the file. Unlike BufferedFileOut, specifying the file format upon saving will do nothing and you cannot easily save your recorded audio to multiple formats. There are also fewer formats available to save in, limiting you to AIFF, AU, and WAV.

Author:
Damien Di Fede

Field Summary
protected  org.tritonus.share.sampled.file.AudioOutputStream aos
           
 
Fields inherited from class ddf.minim.AudioFileOut
AIFC, AIFF, AU, filename, fileType, format, recording, SND, WAV
 
Constructor Summary
StreamFileOut(javax.sound.sampled.AudioFormat format, java.lang.String name)
          Constructs a StreamFileOut that will record audio in the provided AudioFormat and save to a to a file called 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()
          Finishes the recording process by closing the file.
 void save(javax.sound.sampled.AudioFileFormat.Type type)
          Finishes the recording process by closing the file.
 void setName(java.lang.String name)
          Sets the name for the file.
 void setType(javax.sound.sampled.AudioFileFormat.Type type)
          Sets the file type of the file.
 
Methods inherited from class ddf.minim.AudioFileOut
isRecording, startRecording, stopRecording
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

aos

protected org.tritonus.share.sampled.file.AudioOutputStream aos
Constructor Detail

StreamFileOut

public StreamFileOut(javax.sound.sampled.AudioFormat format,
                     java.lang.String name)
Constructs a StreamFileOut that will record audio in the provided AudioFormat and save to a to a file called name.

Parameters:
format - the AudioFormat to record in
name - the file name (do not include the extension)
Method Detail

setName

public void setName(java.lang.String name)
Sets the name for the file. You should not include to file extension when setting the name as it will be gotten from the file type. It is not possible to change the name during recording. If you try, an error will be reported and the function will return. If you are not currently recording, this function will attempt to close the current file and then open a new one using the provided name and currently set file type.

Overrides:
setName in class AudioFileOut
Parameters:
name - the name of the file (without the extension)
See Also:
#setName(String)

setType

public void setType(javax.sound.sampled.AudioFileFormat.Type type)
Sets the file type of the file. It is not possible to change the file type during recording. If you try, an error will be reported and the function will return. If you are not currently recording, this function will attempt to close the current file and then open a new one using the provided file type and current file name. If you specify an invalid file type, it will default to WAV.

Overrides:
setType in class AudioFileOut
Parameters:
type -
See Also:
#setType(javax.sound.sampled.AudioFileFormat.Type)

save

public void save()
Finishes the recording process by closing the file.

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

save

public void save(javax.sound.sampled.AudioFileFormat.Type type)
Finishes the recording process by closing the file. This disregards type and simple calls save().

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