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.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public WaveformWriter​(TarsosDSPAudioFormat format, java.lang.String fileName)
  • Method Details

    • 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