com.brackeen.javagamebook.sound
Class Filter3d

java.lang.Object
  extended by com.brackeen.javagamebook.sound.SoundFilter
      extended by com.brackeen.javagamebook.sound.Filter3d

public class Filter3d
extends SoundFilter

The Filter3d class is a SoundFilter that creates a 3d sound effect. The sound is filtered so that it is quiter the farther away the sound source is from the listener.

Possible ideas to extend this class:

See Also:
FilteredSoundStream

Field Summary
private  float lastVolume
           
private  Sprite listener
           
private  int maxDistance
           
private static int NUM_SHIFTING_SAMPLES
           
private  Sprite source
           
 
Constructor Summary
Filter3d(Sprite source, Sprite listener, int maxDistance)
          Creates a new Filter3d object with the specified source and listener Sprites.
 
Method Summary
 void filter(byte[] samples, int offset, int length)
          Filters the sound so that it gets more quiet with distance.
 
Methods inherited from class com.brackeen.javagamebook.sound.SoundFilter
filter, getRemainingSize, getSample, reset, setSample
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NUM_SHIFTING_SAMPLES

private static final int NUM_SHIFTING_SAMPLES
See Also:
Constant Field Values

source

private Sprite source

listener

private Sprite listener

maxDistance

private int maxDistance

lastVolume

private float lastVolume
Constructor Detail

Filter3d

public Filter3d(Sprite source,
                Sprite listener,
                int maxDistance)
Creates a new Filter3d object with the specified source and listener Sprites. The Sprite's position can be changed while this filter is running.

The maxDistance parameter is the maximum distance that the sound can be heard.

Method Detail

filter

public void filter(byte[] samples,
                   int offset,
                   int length)
Filters the sound so that it gets more quiet with distance.

Specified by:
filter in class SoundFilter