| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectsound.player.SoundPlayback
public class SoundPlayback
| Constructor Summary | |
|---|---|
| SoundPlayback(float sampleRate,
              int sampleSizeInBits,
              int channels,
              int bufferSize,
              int putSamplesSize)Construct a sound playback object that plays audio through the computer's speaker. | |
| SoundPlayback(java.lang.String fileName,
              float sampleRate,
              int sampleSizeInBits,
              int channels,
              int bufferSize,
              int putSamplesSize)Construct a sound playback object that writes audio to a sound file with the specified name. | |
| Method Summary | |
|---|---|
|  void | putSamples(double[][] putSamplesArray)Play an array of audio samples. | 
|  void | putSamplesInt(int[][] putSamplesArray)Play an array of audio samples. | 
|  void | startPlayback()Perform initialization for the playback of audio data. | 
|  void | stopPlayback()Stop playing/writing audio. | 
| Methods inherited from class java.lang.Object | 
|---|
| equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Constructor Detail | 
|---|
public SoundPlayback(float sampleRate,
                     int sampleSizeInBits,
                     int channels,
                     int bufferSize,
                     int putSamplesSize)
sampleRate - Sample rate in Hz. Must be in the range: 8000
                         to 48000.sampleSizeInBits - Number of bits per sample (valid choices are
                         8 or 16).channels - Number of audio channels. 1 for mono, 2 for
                         stereo, etc.bufferSize - Requested size of the internal audio input
                         buffer in samples. This controls the latency (delay from
                         the time putSamples() is called until the audio is
                         actually heard). A lower bound on the latency is given by
                         (bufferSize / sampleRate) seconds.
                         Ideally, the
                         smallest value that gives acceptable performance (no underflow)
                         should be used. Typical values are about 1/10 th the sample
                         rate. For example, affineTransform 44100 Hz sample rate, a typical buffer
                         size value might be 4410.putSamplesSize - Size of the array parameter of
                         putSamples(). For performance reasons, the size should
                         be chosen smaller than bufferSize. Typical values
                         are 1/2 to 1/16 th of bufferSize.
public SoundPlayback(java.lang.String fileName,
                     float sampleRate,
                     int sampleSizeInBits,
                     int channels,
                     int bufferSize,
                     int putSamplesSize)
fileName - The file name to create. If the file already
                         exists, overwrite it. Valid sound file formats are WAVE (.wav),
                         AIFF (.aif, .aiff), AU (.au). The file format to write is
                         determined automatically from the file extension.sampleRate - Sample rate in Hz. Must be in the range: 8000
                         to 48000.sampleSizeInBits - Number of bits per sample (valid choices are
                         8 or 16).channels - Number of audio channels. 1 for mono, 2 for
                         stereo.putSamplesSize - Size of the array parameter of
                         putSamples(). There is no restriction on the value of
                         this parameter, but typical values are 64-2024.| Method Detail | 
|---|
public void putSamples(double[][] putSamplesArray)
                throws java.io.IOException,
                       java.lang.IllegalStateException
putSamplesArray - A two dimensional array containing
                        the samples to play or write to a file. 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 example,
                        putSamplesArray[n][m] contains the (m+1)th sample
                        of the (n+1)th channel. putSamplesArray should be a
                        rectangular array such that putSamplesArray.length() gives
                        the number of channels and putSamplesArray[n].length() is
                        equal to putSamplesSize, for all channels n. This
                        is not actually checked, however.
java.io.IOException - If there is a problem playing audio.
java.lang.IllegalStateException - If audio playback is currently
                               inactive. That is, If startPlayback() has not yet been called
                               or if stopPlayback() has already been called.
public void putSamplesInt(int[][] putSamplesArray)
                   throws java.io.IOException,
                          java.lang.IllegalStateException
putSamplesArray - A two dimensional array containing
                        the samples to play or write to a file. 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 example,
                        putSamplesArray[n][m] contains the (m+1)th sample
                        of the (n+1)th channel. putSamplesArray should be a
                        rectangular array such that putSamplesArray.length() gives
                        the number of channels and putSamplesArray[n].length() is
                        equal to putSamplesSize, for all channels n. This
                        is not actually checked, however.
java.io.IOException - If there is a problem playing audio.
java.lang.IllegalStateException - If audio playback is currently
                               inactive. That is, If startPlayback() has not yet been called
                               or if stopPlayback() has already been called.
public void startPlayback()
                   throws java.io.IOException,
                          java.lang.IllegalStateException
java.io.IOException - If there is a problem setting up
                               the system for audio playback. This will occur if
                               a file cannot be opened or if the audio out port cannot
                               be accessed.
java.lang.IllegalStateException - If this method is called
                               more than once between invocations of stopCapture().
public void stopPlayback()
                  throws java.io.IOException
java.io.IOException - If there is a problem closing the
                     audio resources, or if the "write audio data
                     to file" constructor was used  and the sound file has an
                     unsupported format.| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||