|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ch.aplu.util.SoundRecorder
public class SoundRecorder
Class for recording sound and save it to a WAV file.
Constructor Summary | |
---|---|
SoundRecorder(javax.sound.sampled.AudioFormat audioFormat)
Same as SoundRecorder(bufSize, audioFormat, mixerIndex) with default buffer size (10000 bytes) and default sound recording device. |
|
SoundRecorder(javax.sound.sampled.AudioFormat audioFormat,
int mixerIndex)
Same as SoundRecorder(bufSize, audioFormat, mixerIndex) with default buffer size (10000 bytes). |
|
SoundRecorder(int bufSize,
javax.sound.sampled.AudioFormat audioFormat)
Same as SoundRecorder(bufSize, audioFormat, mixerIndex) with default sound recording device. |
|
SoundRecorder(int bufSize,
javax.sound.sampled.AudioFormat audioFormat,
int mixerIndex)
Create a recorder instance with given audioFormat using the given mixer index (sound device). |
Method Summary | |
---|---|
void |
addSoundSampleListener(SoundSampleListener listener)
Register a SoundSampleLister to get notifications for each recorded sound sample (default sample size: 10000 bytes). |
void |
capture()
Same as capture(ByteArrayOutputStream data), but store data in an internal buffer that can be read-out by getRecordedData(). |
void |
capture(java.io.ByteArrayOutputStream data)
Start capturing the sound in a separate capture thread and store data in the given stream. |
static java.lang.String[] |
getAvailableMixers()
Return a list of the names of available mixers (sound devices). |
byte[] |
getCapturedBytes()
Return a reference to the internal sound recording buffer. |
javax.sound.sampled.AudioFormat |
getFormat()
Return the current audio format. |
int |
getMixerIndex()
|
void |
stopCapture()
Stop the capturing process and return after the capture thread terminates. |
boolean |
writeWavFile(byte[] data,
java.io.File file)
Write the sound data from byte array into the given file in WAV format. |
boolean |
writeWavFile(byte[] data,
java.lang.String filename)
Write the sound data in the given byte array into file with given name in WAV format. |
boolean |
writeWavFile(java.io.ByteArrayOutputStream data,
java.io.File file)
Write the sound data the given stream into the given file in WAV format. |
boolean |
writeWavFile(java.io.ByteArrayOutputStream data,
java.lang.String filename)
Write the sound data in the given stream into file with given name in WAV format. |
boolean |
writeWavFile(int[] data,
java.io.File file)
Write the sound data from int array into the given file in WAV format. |
boolean |
writeWavFile(int[] data,
java.lang.String filename)
Write the sound data from int array into the given file with given name in WAV format. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SoundRecorder(javax.sound.sampled.AudioFormat audioFormat)
public SoundRecorder(int bufSize, javax.sound.sampled.AudioFormat audioFormat)
public SoundRecorder(javax.sound.sampled.AudioFormat audioFormat, int mixerIndex)
public SoundRecorder(int bufSize, javax.sound.sampled.AudioFormat audioFormat, int mixerIndex)
Method Detail |
---|
public void addSoundSampleListener(SoundSampleListener listener)
public void capture() throws javax.sound.sampled.LineUnavailableException
javax.sound.sampled.LineUnavailableException
public byte[] getCapturedBytes()
public void capture(java.io.ByteArrayOutputStream data) throws javax.sound.sampled.LineUnavailableException
javax.sound.sampled.LineUnavailableException
- if the sound
card is not availablepublic void stopCapture()
public boolean writeWavFile(int[] data, java.lang.String filename)
public boolean writeWavFile(byte[] data, java.lang.String filename)
public boolean writeWavFile(java.io.ByteArrayOutputStream data, java.lang.String filename)
public boolean writeWavFile(java.io.ByteArrayOutputStream data, java.io.File file)
public boolean writeWavFile(byte[] data, java.io.File file)
public boolean writeWavFile(int[] data, java.io.File file)
public static java.lang.String[] getAvailableMixers()
public int getMixerIndex()
public javax.sound.sampled.AudioFormat getFormat()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |