public class AudioData
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected javax.sound.sampled.AudioFormat |
format |
protected java.util.List<javax.swing.event.ChangeListener> |
listeners |
protected int |
selectionEnd |
protected int |
selectionStart |
protected short[] |
shorts |
Constructor and Description |
---|
AudioData()
No-arg constructor.
|
AudioData(javax.sound.sampled.AudioInputStream ais)
Creates a new AudioData from the given AudioInputStream, converting the data to 16bit, little endian, SIGNED_PCM if
needed.
|
AudioData(short[] data,
float sampleRate)
Creates a new AudioData with the given data and sample rate.
|
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(javax.swing.event.ChangeListener listener)
Add a ChangeListener.
|
protected void |
fireStateChanged()
Notify all ChangeListeners of a change.
|
short[] |
getAudioData()
Gets the SIGNED_PCM 16 bit little endian audio data.
|
javax.sound.sampled.AudioFormat |
getAudioFormat()
Gets the audio format.
|
void |
removeChangeListener(javax.swing.event.ChangeListener listener)
Remove a ChangeListener.
|
void |
setAudioData(short[] data)
Sets the audio data and notifies all ChangeListeners.
|
protected javax.sound.sampled.AudioFormat format
protected short[] shorts
protected final java.util.List<javax.swing.event.ChangeListener> listeners
protected int selectionStart
protected int selectionEnd
public AudioData()
public AudioData(short[] data, float sampleRate)
data
- the audio samples; one sample per element in the arraysampleRate
- the sample rate in Hzpublic AudioData(javax.sound.sampled.AudioInputStream ais) throws java.io.IOException
ais
- the AudioInputStreamjava.io.IOException
- if problems happen when reading from aispublic short[] getAudioData()
public void setAudioData(short[] data)
data
- the new SIGNED_PCM 16 bit little endian samplespublic javax.sound.sampled.AudioFormat getAudioFormat()
public void addChangeListener(javax.swing.event.ChangeListener listener)
listener
- the listener to addpublic void removeChangeListener(javax.swing.event.ChangeListener listener)
listener
- the listener to removeprotected void fireStateChanged()