java.lang.Object
fr.paris.lutece.plugins.captcha.modules.jcaptcha.service.sound.filter.SoundFilter
Direct Known Subclasses:
EchoFilter, PitchFilter

public abstract class SoundFilter extends Object
A abstract class designed to filter sound samples. Since SoundFilters may use internal buffering of samples, a new SoundFilter object should be created for every sound played. However, SoundFilters can be reused after they are finished by called the reset() method.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    filter(byte[] samples, int offset, int length, int sampleSizeInBits)
    Filters an array of samples.
    static short
    get16bitSample(byte[] buffer, int position)
    Convenience method for getting a 16-bit sample from a byte array.
    static short
    get8bitSample(byte[] buffer, int position)
    Convenience method for getting a 8-bit sample from a byte array.
    getAudioFormat(AudioInputStream audioInputStream)
    Return the audio format corresponding to the input stream Overrided by the filters that mofify AudioFormat
    int
    Gets the remaining size, in bytes, that this filter plays after the sound is finished.
    void
    Resets this SoundFilter.
    static void
    set16bitSample(byte[] buffer, int position, short sample)
    Convenience method for setting a 16-bit sample in a byte array.
    static void
    set8bitSample(byte[] buffer, int position, short sample)
    Convenience method for setting a 8-bit sample in a byte array.

    Methods inherited from class java.lang.Object

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

    • SoundFilter

      public SoundFilter()
  • Method Details

    • reset

      public void reset()
      Resets this SoundFilter. Does nothing by default.
    • getRemainingSize

      public int getRemainingSize()
      Gets the remaining size, in bytes, that this filter plays after the sound is finished. An example would be an echo that plays longer than it's original sound. This method returns 0 by default.
      Returns:
      remaining size
    • filter

      public abstract void filter(byte[] samples, int offset, int length, int sampleSizeInBits)
      Filters an array of samples. Samples should be in 16-bit, signed, little-endian format. This method should be implemented by subclasses.
      Parameters:
      samples - the samples
      offset - the offset
      length - the length
      sampleSizeInBits - the sample size in bits
    • get8bitSample

      public static short get8bitSample(byte[] buffer, int position)
      Convenience method for getting a 8-bit sample from a byte array. Samples should be in 8-bit, unsigned, little-endian format.
      Parameters:
      buffer - the buffer
      position - the position
      Returns:
      8 bit sample
    • set8bitSample

      public static void set8bitSample(byte[] buffer, int position, short sample)
      Convenience method for setting a 8-bit sample in a byte array. Samples should be in 8-bit, unsigned, little-endian format.
      Parameters:
      buffer - the buffer
      position - the position
      sample - the sample
    • get16bitSample

      public static short get16bitSample(byte[] buffer, int position)
      Convenience method for getting a 16-bit sample from a byte array. Samples should be in 16-bit, signed, little-endian format.
      Parameters:
      buffer - the buffer
      position - the position
      Returns:
      16 bit sample
    • set16bitSample

      public static void set16bitSample(byte[] buffer, int position, short sample)
      Convenience method for setting a 16-bit sample in a byte array. Samples should be in 16-bit, signed, little-endian format.
      Parameters:
      buffer - the buffer
      position - the position
      sample - the sample
    • getAudioFormat

      public AudioFormat getAudioFormat(AudioInputStream audioInputStream)
      Return the audio format corresponding to the input stream Overrided by the filters that mofify AudioFormat
      Parameters:
      audioInputStream - the audio input stream
      Returns:
      the audio format corresponding to the input stream