Class SoundFilter
java.lang.Object
fr.paris.lutece.plugins.captcha.modules.jcaptcha.service.sound.filter.SoundFilter
- Direct Known Subclasses:
EchoFilter,PitchFilter
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 -
Method Summary
Modifier and TypeMethodDescriptionabstract voidfilter(byte[] samples, int offset, int length, int sampleSizeInBits) Filters an array of samples.static shortget16bitSample(byte[] buffer, int position) Convenience method for getting a 16-bit sample from a byte array.static shortget8bitSample(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 AudioFormatintGets the remaining size, in bytes, that this filter plays after the sound is finished.voidreset()Resets this SoundFilter.static voidset16bitSample(byte[] buffer, int position, short sample) Convenience method for setting a 16-bit sample in a byte array.static voidset8bitSample(byte[] buffer, int position, short sample) Convenience method for setting a 8-bit sample in a byte array.
-
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 samplesoffset- the offsetlength- the lengthsampleSizeInBits- 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 bufferposition- 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 bufferposition- the positionsample- 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 bufferposition- 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 bufferposition- the positionsample- the sample
-
getAudioFormat
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
-