abc.midi
Class TunePlayer

java.lang.Object
  extended byabc.midi.TunePlayer
All Implemented Interfaces:
java.util.EventListener, javax.sound.midi.MetaEventListener

public class TunePlayer
extends java.lang.Object
implements javax.sound.midi.MetaEventListener

TunePlayer objects enable you to play tunes using default MIDI sequencer.


Constructor Summary
TunePlayer()
          Constructs a tune player with default midi converter.
TunePlayer(MidiConverterInterface converter)
          Constructs a tune player with the specified midi converter.
 
Method Summary
 void addListener(TunePlayerListenerInterface listener)
          Adds a listener to this tune player.
 int getTempo()
          Returns the tempo currently used to play tunes.
 Tune getTune()
          The tune that is currently played,
 boolean isPlaying()
          Returns true if this player is currently playing a tune.
 void meta(javax.sound.midi.MetaMessage meta)
           
 void play(Tune tune)
          Plays the given tune.
 void removeListener(TunePlayerListenerInterface listener)
          Removes a listener from this tune player.
 void setTempo(int tempo)
          Sets the tempo used to play the tune.
 void start()
          Starts the player so that it can play tunes.
 void stop()
          Stops this player.
 void stopPlaying()
          Stops the playing of the current tune if any.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TunePlayer

public TunePlayer()
Constructs a tune player with default midi converter.

See Also:
BasicMidiConverter

TunePlayer

public TunePlayer(MidiConverterInterface converter)
Constructs a tune player with the specified midi converter.

Method Detail

addListener

public void addListener(TunePlayerListenerInterface listener)
Adds a listener to this tune player.

Parameters:
listener - The listener to be added to this tune player.

removeListener

public void removeListener(TunePlayerListenerInterface listener)
Removes a listener from this tune player.

Parameters:
listener - The listener to be removed from this tune player.

setTempo

public void setTempo(int tempo)
Sets the tempo used to play the tune. N.B: This is real time tempo change : the tempo will change even if a tune is playing.

Parameters:
tempo - the tempo used to play the tune.

getTempo

public int getTempo()
Returns the tempo currently used to play tunes.

Returns:
The tempo currently used to play tunes.

getTune

public Tune getTune()
The tune that is currently played,


play

public void play(Tune tune)
          throws java.lang.IllegalStateException
Plays the given tune.

Parameters:
tune - The tune to be played.
Throws:
java.lang.IllegalStateException - Thrown if the player hasn't been started before.

isPlaying

public boolean isPlaying()
Returns true if this player is currently playing a tune.

Returns:
true if this player is currently playing a tune, false otheriwse.

meta

public void meta(javax.sound.midi.MetaMessage meta)
Specified by:
meta in interface javax.sound.midi.MetaEventListener

start

public void start()
Starts the player so that it can play tunes. (Retrieves the default sequencer during this phasis).


stopPlaying

public void stopPlaying()
Stops the playing of the current tune if any.


stop

public void stop()
Stops this player.