Class EchoFilter

    • Constructor Summary

      Constructors 
      Constructor Description
      EchoFilter​(float echoDelay, float decay)
      Creates an EchoFilter with the specified number of delay samples and the specified decay rate.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void filter​(byte[] samples, int offset, int length, int sampleSizeInBits)
      Filters the sound samples to add an echo.
      int getRemainingSize()
      Gets the remaining size, in bytes, of samples that this filter can echo after the sound is done playing.
      void reset()
      Clears this EchoFilter's internal delay buffer.
      • Methods inherited from class java.lang.Object

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

      • EchoFilter

        public EchoFilter​(float echoDelay,
                          float decay)
        Creates an EchoFilter with the specified number of delay samples and the specified decay rate.

        The number of delay samples specifies how long before the echo is initially heard. For a 1 second echo with mono, 44100Hz sound, use 44100 delay samples.

        The decay value is how much the echo has decayed from the source. A decay value of .5 means the echo heard is half as loud as the source.

        Parameters:
        echoDelay - the echoDelay
        decay - the decay
    • Method Detail

      • getRemainingSize

        public int getRemainingSize()
        Gets the remaining size, in bytes, of samples that this filter can echo after the sound is done playing. Ensures that the sound will have decayed to below 1% of maximum volume (amplitude).
        Overrides:
        getRemainingSize in class SoundFilter
        Returns:
        the Remaining Size
      • reset

        public void reset()
        Clears this EchoFilter's internal delay buffer.
        Overrides:
        reset in class SoundFilter
      • filter

        public void filter​(byte[] samples,
                           int offset,
                           int length,
                           int sampleSizeInBits)
        Filters the sound samples to add an echo. The samples played are added to the sound in the delay buffer multipied by the decay rate. The result is then stored in the delay buffer, so multiple echoes are heard.
        Specified by:
        filter in class SoundFilter
        Parameters:
        samples - the samples
        offset - the offset
        length - the length
        sampleSizeInBits - the sample size in bits