Package be.tarsos.dsp.io.jvm
Class WaveformWriter
java.lang.Object
be.tarsos.dsp.io.jvm.WaveformWriter
- All Implemented Interfaces:
AudioProcessor
public class WaveformWriter extends java.lang.Object implements AudioProcessor
Writes a WAV-file to disk. It stores the bytes to a raw file and when the processingFinished method is called it prepends the raw file with a header to make it a legal WAV-file.
Writing a RAW file first and then a header is needed because the header contains fields for the size of the file, which is unknown beforehand. See Subchunk2Size and ChunkSize on this wav file reference.
- Author:
- Joren Six
-
Constructor Summary
Constructors Constructor Description WaveformWriter(TarsosDSPAudioFormat format, java.lang.String fileName)
WaveformWriter(javax.sound.sampled.AudioFormat format, java.lang.String fileName)
Initialize the writer. -
Method Summary
Modifier and Type Method Description boolean
process(AudioEvent audioEvent)
Process the audio event.void
processingFinished()
Notify the AudioProcessor that no more data is available and processing has finished.
-
Constructor Details
-
WaveformWriter
public WaveformWriter(javax.sound.sampled.AudioFormat format, java.lang.String fileName)Initialize the writer.- Parameters:
format
- The format of the received bytes.fileName
- The name of the wav file to store.
-
WaveformWriter
-
-
Method Details
-
process
Description copied from interface:AudioProcessor
Process the audio event. Do the actual signal processing on an (optionally) overlapping buffer.- Specified by:
process
in interfaceAudioProcessor
- Parameters:
audioEvent
- The audio event that contains audio data.- Returns:
- False if the chain needs to stop here, true otherwise. This can be used to implement e.g. a silence detector.
-
processingFinished
public void processingFinished()Description copied from interface:AudioProcessor
Notify the AudioProcessor that no more data is available and processing has finished. Can be used to deallocate resources or cleanup.- Specified by:
processingFinished
in interfaceAudioProcessor
-