fang
Class SequentialSound

java.lang.Object
  extended by fang.SequentialSound
Direct Known Subclasses:
MidiSound, SampledSound, Sound

public abstract class SequentialSound
extends Object

This class can play only one sound at a time. Once the sound has played to completion, it can be replayed. SequentialSound is the base class for MidiSound and SampledSound, and the Sound class contains a collection of SequentialSound to play sounds simultaneously.

Author:
Jam Jenkins

Constructor Summary
SequentialSound()
           
 
Method Summary
abstract  double getClipLength()
          gets the duration of this sound in seconds
abstract  double getClipPosition()
          gets the clip position in seconds
abstract  SequentialSound getDuplicate()
          gets a sound that is just like this one in its default initially constructed state
abstract  int getLoopsLeft()
          gets how many times the sound will play through until it stops.
 double getPan()
           
 double getVolume()
          gets the multiplier that has been added to this sound.
 boolean isFinishedPlaying()
          determines if this sound is done playing.
abstract  boolean isLoaded()
          determines if the sound clip has been entirely loaded.
 boolean isLooping()
          tells whether the sound is currently looping
abstract  boolean isMuted()
          determines if the sound is audible when the clip is playing
abstract  boolean isPaused()
          determines if the sound is currently responding to the change in time.
 boolean isPlaying()
          tells whether the clip is currently audible and not yet at the end
 void loop()
          plays the sound repeatedly
abstract  void mute()
          makes the sound inaudible
abstract  void pause()
          stops the sound keeping the current position
abstract  void play()
          starts the sound playing
 void play(double pan)
          plays the sound, controlling the panning left or right
 void resume()
          plays the sound from its current location in time
abstract  void setClipPosition(double time)
          sets the clip position in seconds.
abstract  void setLooping(boolean doLoop)
          sets whether the sound should loop or not
abstract  void setLooping(int loops)
          sets how many times the sound should play before terminating
 void setPan(double pan)
           
 void setVolume(double volume)
          sets the volume of this clip.
 void start()
          starts the clip playing from the beginning
 void stop()
          sets the clip position to the end to stop the clip from playing
abstract  void turnSoundOn()
          makes the sound audible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SequentialSound

public SequentialSound()
Method Detail

getClipPosition

public abstract double getClipPosition()
gets the clip position in seconds

Returns:
the seconds that this clip has played

setClipPosition

public abstract void setClipPosition(double time)
sets the clip position in seconds.

Parameters:
time - the seconds from the start of the sound

getClipLength

public abstract double getClipLength()
gets the duration of this sound in seconds

Returns:
the seconds long this sound would play

play

public abstract void play()
starts the sound playing


pause

public abstract void pause()
stops the sound keeping the current position


mute

public abstract void mute()
makes the sound inaudible


turnSoundOn

public abstract void turnSoundOn()
makes the sound audible


setLooping

public abstract void setLooping(boolean doLoop)
sets whether the sound should loop or not

Parameters:
doLoop - true indicates the sound should loop indefinitely, false means to terminate playback at the end of the clip's duration

setLooping

public abstract void setLooping(int loops)
sets how many times the sound should play before terminating

Parameters:
loops - the number of times to play the sound before stopping. The default is 1.

getLoopsLeft

public abstract int getLoopsLeft()
gets how many times the sound will play through until it stops. The default is 0 meaning that once the current clip ends, the sound terminates.

Returns:
the number of entire clip durations left to play (zero is the default)

isLoaded

public abstract boolean isLoaded()
determines if the sound clip has been entirely loaded. Since loading is a time consuming operation, a sound may not be ready to play immediately after it is constructed.

Returns:
true if the sound has been loaded completely, false otherwise

isMuted

public abstract boolean isMuted()
determines if the sound is audible when the clip is playing

Returns:
true indicates that sound will be audible when the clip is playing, false means the sound is currently muted.

isPaused

public abstract boolean isPaused()
determines if the sound is currently responding to the change in time.

Returns:
true if the sound is paused, false otherwise

getDuplicate

public abstract SequentialSound getDuplicate()
gets a sound that is just like this one in its default initially constructed state

Returns:
a copy of the current sound

isFinishedPlaying

public boolean isFinishedPlaying()
determines if this sound is done playing. The sound is done playing when it either has not started or when it has reached the end of its playing duration.

Returns:

setVolume

public void setVolume(double volume)
sets the volume of this clip. This method actually affects the gain in a linear way. Setting the value to 1 means that the sound's volume is unchanged. Setting the value to 2 makes it twice as loud whereas setting it to 0.5 makes the sound 1/2 as loud. A default method is provided, but classes that extend SequentialSound may optionally make this method affect the actual sound.

Parameters:
volume - the multiplier to affect the volume

getVolume

public double getVolume()
gets the multiplier that has been added to this sound. By default, all sounds are unchanged and have a mutliplier of 1.

Returns:
the multiplier that affects the amplitude of the sound

setPan

public void setPan(double pan)

getPan

public double getPan()

start

public void start()
starts the clip playing from the beginning


stop

public void stop()
sets the clip position to the end to stop the clip from playing


play

public void play(double pan)
plays the sound, controlling the panning left or right

Parameters:
pan - the side on which to play where 0.0 is entirely on the left and 1.0 is entirely on the right, and 0.5 is evenly balanced. Any value between 0.0 and 1.0 is valid.

loop

public void loop()
plays the sound repeatedly


resume

public void resume()
plays the sound from its current location in time


isLooping

public boolean isLooping()
tells whether the sound is currently looping

Returns:
true means the sound is looping, false means the sound will terminate when it gets to the end of the clip

isPlaying

public boolean isPlaying()
tells whether the clip is currently audible and not yet at the end

Returns: