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

java.lang.Object
  extended by 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:
FilteredSoundStream

Field Summary
protected static int SAMPLE_SIZE_16_BIT
           
protected static int SAMPLE_SIZE_8_BIT
           
 
Constructor Summary
SoundFilter()
           
 
Method Summary
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.
 AudioFormat getAudioFormat(AudioInputStream audioInputStream)
          Return the audio format corresponding to the input stream Overrided by the filters that mofify AudioFormat
 int getRemainingSize()
          Gets the remaining size, in bytes, that this filter plays after the sound is finished.
 void reset()
          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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SAMPLE_SIZE_16_BIT

protected static final int SAMPLE_SIZE_16_BIT
See Also:
Constant Field Values

SAMPLE_SIZE_8_BIT

protected static final int SAMPLE_SIZE_8_BIT
See Also:
Constant Field Values
Constructor Detail

SoundFilter

public SoundFilter()
Method Detail

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


Copyright © 2014 Mairie de Paris. All Rights Reserved.