public class AudioFileDataSource extends BaseDataProcessor
setAudioFile(java.io.File,String)
to set the input file, and call getData()
to obtain the Data frames.
Using JavaSound as backend this class is able to handle all sound files supported by JavaSound. Beside the built-in support for .wav, .au and .aiff. Using plugins (cf. http://www.jsresources.org/ ) it can be extended to support .ogg, .mp3, .speex and others.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
AUDIO_FILE_LISTENERS |
protected boolean |
bigEndian |
protected int |
bytesPerRead |
protected int |
bytesPerValue |
protected java.io.InputStream |
dataStream |
protected java.util.List<AudioFileProcessListener> |
fileListeners |
static java.lang.String |
PROP_BYTES_PER_READ
The property for the number of bytes to read from the InputStream each time.
|
protected int |
sampleRate |
protected boolean |
signedData |
logger
Constructor and Description |
---|
AudioFileDataSource() |
AudioFileDataSource(int bytesPerRead,
java.util.List<AudioFileProcessListener> listeners) |
Modifier and Type | Method and Description |
---|---|
void |
addNewFileListener(AudioFileProcessListener l)
Adds a new listener for new file events.
|
Data |
getData()
Reads and returns the next Data from the InputStream of StreamDataSource, return null if no data is read and end
of file is reached.
|
int |
getSampleRate() |
void |
initialize()
Initializes this DataProcessor.
|
boolean |
isBigEndian() |
void |
newProperties(PropertySheet ps)
This method is called when this configurable component needs to be reconfigured.
|
void |
removeNewFileListener(AudioFileProcessListener l)
Removes a listener for new file events.
|
void |
setAudioFile(java.io.File audioFile,
java.lang.String streamName)
Sets the audio file from which the data-stream will be generated of.
|
void |
setAudioFile(java.net.URL audioFileURL,
java.lang.String streamName)
Sets the audio file from which the data-stream will be generated of.
|
void |
setInputStream(javax.sound.sampled.AudioInputStream inputStream,
java.lang.String streamName)
Sets the InputStream from which this StreamDataSource reads.
|
getPredecessor, setPredecessor
getName, initLogger, toString
@S4Integer(defaultValue=3200) public static final java.lang.String PROP_BYTES_PER_READ
@S4ComponentList(type=Configurable.class) public static final java.lang.String AUDIO_FILE_LISTENERS
protected final java.util.List<AudioFileProcessListener> fileListeners
protected java.io.InputStream dataStream
protected int sampleRate
protected int bytesPerRead
protected int bytesPerValue
protected boolean bigEndian
protected boolean signedData
public AudioFileDataSource(int bytesPerRead, java.util.List<AudioFileProcessListener> listeners)
public AudioFileDataSource()
public void newProperties(PropertySheet ps) throws PropertyException
Configurable
newProperties
in interface Configurable
newProperties
in class ConfigurableAdapter
ps
- a property sheet holding the new dataPropertyException
- if there is a problem with the properties.public void initialize()
BaseDataProcessor
initialize
in interface DataProcessor
initialize
in class BaseDataProcessor
public void setAudioFile(java.io.File audioFile, java.lang.String streamName)
audioFile
- The location of the audio file to usestreamName
- The name of the InputStream. if null
the complete path of the audio file will be
uses as stream name.public void setAudioFile(java.net.URL audioFileURL, java.lang.String streamName)
audioFileURL
- The location of the audio file to usestreamName
- The name of the InputStream. if null
the complete path of the audio file will be
uses as stream name.public void setInputStream(javax.sound.sampled.AudioInputStream inputStream, java.lang.String streamName)
inputStream
- the InputStream from which audio data comesstreamName
- the name of the InputStreampublic Data getData() throws DataProcessingException
getData
in interface DataProcessor
getData
in class BaseDataProcessor
null
if none is availableDataProcessingException
- if there is a data processing errorpublic int getSampleRate()
public boolean isBigEndian()
public void addNewFileListener(AudioFileProcessListener l)
l
- listener to addpublic void removeNewFileListener(AudioFileProcessListener l)
l
- listener to remove