Class SignalProcessor

java.lang.Object
games.stendhal.client.sound.system.SignalProcessor
Direct Known Subclasses:
DirectedSound, Interruptor, MonoMixer, OggVorbisDecoder, PCMStreamConverter, Recorder, Recorder.Player, ReSampler, SoundFile, SoundLayers.VolumeAdjustor, SoundSystem.Output, SoundSystemNG.Output, ToneGenerator, VolumeAdjustor

public abstract class SignalProcessor extends Object
Every class that either wants to modify or generate a stream of PCM audio data should derive from this class

Each SignalProcessor is a chain link in a doubly linked list, a processing chain. The first SignalProcessor in such a chain should always generate audio data otherwise no data will arrive at the quit of the chain

Author:
silvio
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    connectTo​(SignalProcessor processor, boolean before)
     
    static void
    createChain​(SignalProcessor... processors)
    This function will create a processing chain by connecting any number of SignalProcessors together
    void
    Removes this SignalProcessor from the processing chain leaving adjacent SignalProcessors disconnected
    protected void
     
    protected boolean
    This function should be overwritten by all classes that want to generate an PCM audio stream e.g.
    void
    insert​(SignalProcessor processor, boolean before)
    Connects this SignalProcessor to the next one (it is inserted in the processing chain before nextProcessor)
    protected void
    modify​(float[] data, int frames, int channels, int rate)
    This function should be overwritten by all classes that want to modify an PCM audio stream.
    protected void
    propagate​(float[] data, int samples, int channels, int rate)
    This function should be called from a derived class to propagate the modified audio data to the next SignalProcessor in the chain
    void
     
    void
    replace​(SignalProcessor processor)
    Replaces this SignalProcessor with "processor" in the processing chain
    boolean
    This will call the generate() method of the first SignalProcessor in the processing chain
    void
    split​(boolean before)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SignalProcessor

      public SignalProcessor()
  • Method Details

    • insert

      public final void insert(SignalProcessor processor, boolean before)
      Connects this SignalProcessor to the next one (it is inserted in the processing chain before nextProcessor)
      Parameters:
      processor - nextProcessor
      before - flag to insert processor before this object
    • connectTo

      public final void connectTo(SignalProcessor processor, boolean before)
    • split

      public final void split(boolean before)
    • replace

      public final void replace(SignalProcessor processor)
      Replaces this SignalProcessor with "processor" in the processing chain
      Parameters:
      processor -
    • disconnect

      public final void disconnect()
      Removes this SignalProcessor from the processing chain leaving adjacent SignalProcessors disconnected
    • propagate

      protected final void propagate(float[] data, int samples, int channels, int rate)
      This function should be called from a derived class to propagate the modified audio data to the next SignalProcessor in the chain
      Parameters:
      data -
      samples -
      channels -
      rate -
    • quit

      public final void quit()
    • request

      public boolean request()
      This will call the generate() method of the first SignalProcessor in the processing chain
      Returns:
      true, until the stream is finished
    • modify

      protected void modify(float[] data, int frames, int channels, int rate)
      This function should be overwritten by all classes that want to modify an PCM audio stream. The audio data is uniform and interleaved. uniform: Each sample has a value between -1.0 and 1.0 interleaved: The channels are not separated. They are bundled in frames e.g. if there is stereo PCM data: data[0] and data[1] are the left and right channels of sample 0 data[2] and data[3] are the left and right channels of sample 1 data[4] and data[5] are the left and right channels of sample 2 and so on ... The number of samples can be calculated by: frames * channels
      Parameters:
      data - the audio data
      frames - the number of sample frames contained in "data"
      channels - number of channels
      rate - the sample rate
    • generate

      protected boolean generate()
      This function should be overwritten by all classes that want to generate an PCM audio stream e.g. a mp3 decoder, a frequency generator, ...
      Returns:
      true, until the stream is finished
    • finished

      protected void finished()
    • createChain

      public static void createChain(SignalProcessor... processors)
      This function will create a processing chain by connecting any number of SignalProcessors together
      Parameters:
      processors - any number of SignalProcessors to insert together