Hello,
I have been asked how to capture output to a WAV file. You can use the
new WAVFileWriter class for that. Please see the attached file for an
example. The attached file is an improved version of
"JSynExamples\TJ_NonRealTime.java". I am now using a
BufferedOutputStream which speeds up the file I/O tremendously.
Here are some relevant excerpts from the example file.
// create objects needed to write a WAV file
RandomAccessFile rfile = new RandomAccessFile( "mysong.wav", "rw" );
wavWriter = new WAVFileWriter( rfile );
outStream = new BufferedOutputStream( wavWriter );
---------
// write header for WAV file
wavWriter.writeHeader( NUM_REC_CHANNELS, (int) FRAME_RATE );
----------
// Create a recorder that will continuously record its input.
recorder = new StreamRecorder( outStream, FRAMES_PER_BUFFER, 4,
NUM_REC_CHANNELS );
myOsc.output.connect( recorder.input );
----------
// Go back to the beginning of the random access file and
// update the WAV file chunk sizes based on final recorded size.
outStream.flush();
wavWriter.fixSizes();
outStream.close();
--
Phil Burk
http://www.softsynth.com