be.hogent.tarsos.dsp
Class WaveformWriter

java.lang.Object
  extended by be.hogent.tarsos.dsp.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
WaveformWriter(javax.sound.sampled.AudioFormat format, java.lang.String fileName)
          Initialize the writer.
 
Method Summary
 boolean process(AudioEvent audioEvent)
          Process the audio event.
 void processingFinished()
          Notify the AudioProcessor that no more data is available and processing has finished.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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.
Method Detail

process

public boolean process(AudioEvent audioEvent)
Description copied from interface: AudioProcessor
Process the audio event. Do the actual signal processing on an (optionally) overlapping buffer.

Specified by:
process in interface AudioProcessor
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 interface AudioProcessor