fr.paris.lutece.plugins.captcha.modules.jcaptcha.service.sound.filter
Class EchoFilter

java.lang.Object
  extended by fr.paris.lutece.plugins.captcha.modules.jcaptcha.service.sound.filter.SoundFilter
      extended by fr.paris.lutece.plugins.captcha.modules.jcaptcha.service.sound.filter.EchoFilter

public class EchoFilter
extends SoundFilter


Field Summary
 
Fields inherited from class fr.paris.lutece.plugins.captcha.modules.jcaptcha.service.sound.filter.SoundFilter
SAMPLE_SIZE_16_BIT, SAMPLE_SIZE_8_BIT
 
Constructor Summary
EchoFilter(float echoDelay, float decay)
          Creates an EchoFilter with the specified number of delay samples and the specified decay rate.
 
Method Summary
 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 fr.paris.lutece.plugins.captcha.modules.jcaptcha.service.sound.filter.SoundFilter
get16bitSample, get8bitSample, getAudioFormat, set16bitSample, set8bitSample
 
Methods inherited from class java.lang.Object
clone, equals, finalize, 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


Copyright © 2014 Mairie de Paris. All Rights Reserved.