Supported file types
Valid sound file formats are WAVE (.wav), AIFF (.aif, .aiff), AU (.au). Valid sample rates are 8000, 11025, 22050, 44100, and 48000 Hz. Both 8 bit and 16 bit audio are supported. Mono and stereo files are supported.
Usage
The path to the sound file to write is given as a constructor parameter, along with parameters that specify the desired audio format. The constructor also takes an array length parameter, which is explained below.
After invoking the constructor, the putSamples() method should be repeatedly invoked to write samples to the specified sound file. This method is blocking, so it will not return until the samples have been written. The putSamples() method takes a multidimensional array as a parameter. The first index represents the channel number (0 for first channel, 1 for second channel, etc.). The second index represents the sample index within a channel. For each channel i, the size of the array, putSamplesArray[i].length, must be equal to the constructor parameter putSamplesArraySize. Otherwise an exception will occur. Thus, each call to putSamples() writes putSamplesArraySize on each channel. It should be noted that the putSamples() method does not write samples directly to a sound file, but instead writes samples to an internal array. The internal array of samples is written to the sound file by the closeFile() method.
The closeFile() method should be invoked when no more samples need to be written. This method will write the internal array of samples to the output file and close the file. It is not possible to write any more samples after closeFile() has been called. An exception will occur if putSamples() is invoked at any point after closeFile() is invoked.
Security issues
Applications have no restrictions on the capturing or playback of audio. Applet code is not allowed to write native files by default. The .java.policy file must be modified to grant applets more privileges.
Note: Requires Java 2 v1.3.0 or later. @author Brian K. Vogel @version $Id: SoundWriter.java,v 1.28 2007/12/06 18:30:04 cxh Exp $ @since Ptolemy II 1.0 @Pt.ProposedRating Red (vogel) @Pt.AcceptedRating Red (cxh) @see ptolemy.media.javasound.SoundCapture
|
|
|
|
|
|