jjdh API

dh.javax.sound.filter
Class EchoFilter

java.lang.Object
  extended by dh.javax.sound.filter.SoundFilter
      extended by dh.javax.sound.filter.EchoFilter

public class EchoFilter
extends SoundFilter

The EchoFilter class is a SoundFilter that emulates an echo.

See Also:
FilteredSoundStream

Field Summary
private  float decay
           
private  short[] delayBuffer
           
private  int delayBufferPos
           
 
Constructor Summary
EchoFilter(int numDelaySamples, 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)
          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 dh.javax.sound.filter.SoundFilter
filter, getSample, setSample
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

delayBuffer

private short[] delayBuffer

delayBufferPos

private int delayBufferPos

decay

private float decay
Constructor Detail

EchoFilter

public EchoFilter(int numDelaySamples,
                  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.

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

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)
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

jjdh API

Copyright © 2006 Jonas Jacobi and Dennis Heidsiek. All Rights Reserved.