sky.monome.event.sequencer
Class NotePlayerListener<S extends Sequencer<S,B>,B extends ButtonManager<B>>


java.lang.Object

  extended by sky.monome.event.GenericListenerWithArguments

      extended by sky.monome.event.sequencer.SequencerListenerWithArguments<S,B>

          extended by sky.monome.event.sequencer.NotePlayerListener<S,B>

Type Parameters:
S - Type of sequencers that work with these note player listeners.
B - Type of button managers that are used by sequencer components that work with these note player listeners.
All Implemented Interfaces:
java.util.EventListener, SequencerListener<S,B>

public abstract class NotePlayerListener<S extends Sequencer<S,B>,B extends ButtonManager<B>>
extends SequencerListenerWithArguments<S,B>

Note player listener. This is a special implementation of the SequencerListener interface that is specialized in scale playing. Implementations of this abstract class can play notes via Midi or any other medium.

Since:
SkyMonome v1.1
Author:
PJ Skyman

Nested Class Summary
static class NotePlayerListener.PlayerMode
          Player mode used by note player listeners.
 
Field Summary
 
Fields inherited from class sky.monome.event.GenericListenerWithArguments
arguments
 
Constructor Summary
NotePlayerListener(Scale scale, MidiNote baseNote, S sequencer, NotePlayerListener.PlayerMode playerMode, java.lang.Object... arguments)
          Constructs a note player listener with the specified scale, the specified base note, the specified sequencer, the specified player mode, and specified arguments.
 
Method Summary
 MidiNote getBaseNote()
          Returns the base note of the played scale.
 NotePlayerListener.PlayerMode getPlayerMode()
          Returns the player mode used by this note player listener.
 Scale getScale()
          Returns the scale played by this note player listener.
 S getSequencer()
          Returns the sequencer that triggers note playings.
abstract  void playNote(MidiNote midiNote)
          Plays the specified note.
 void setBaseNote(MidiNote baseNote)
          Sets the base note of the played scale.
 void setPlayerMode(NotePlayerListener.PlayerMode playerMode)
          Sets the player mode to use in this note player listener.
 void setScale(Scale scale)
          Sets the scale to be played by this note player listener.
 void setSequencer(S sequencer)
          Sets the sequencer that triggers note playings.
 void stepChanged(SequencerEvent<S,B> sequencerEvent)
          Invoked when a step changing occurs.
 
Methods inherited from class sky.monome.event.GenericListenerWithArguments
getArgument, getArgument, getArguments
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NotePlayerListener


public NotePlayerListener(Scale scale,

                          MidiNote baseNote,

                          S sequencer,

                          NotePlayerListener.PlayerMode playerMode,

                          java.lang.Object... arguments)
Constructs a note player listener with the specified scale, the specified base note, the specified sequencer, the specified player mode, and specified arguments.

Parameters:
scale - Scale to be played.
baseNote - Note which is the first note of the scale.
sequencer - Sequencer which triggers note playings.
playerMode - Player mode used by this note player listener.
arguments - Arguments which can be used in the playNote(MidiNote) method. These arguments are optional. The presence of these arguments is due to this class which extends SeqencerListenerWithArguments.
Method Detail

getBaseNote


public MidiNote getBaseNote()
Returns the base note of the played scale.

Returns:
The base note of the played scale.

setBaseNote


public void setBaseNote(MidiNote baseNote)
Sets the base note of the played scale.

Parameters:
baseNote - New base note for the scale to be played.

getPlayerMode


public NotePlayerListener.PlayerMode getPlayerMode()
Returns the player mode used by this note player listener.

Returns:
The player mode used by this note player listener.

setPlayerMode


public void setPlayerMode(NotePlayerListener.PlayerMode playerMode)
Sets the player mode to use in this note player listener.

Parameters:
playerMode - New player mode to use.

getScale


public Scale getScale()
Returns the scale played by this note player listener.

Returns:
The scale played by this note player listener.

setScale


public void setScale(Scale scale)
Sets the scale to be played by this note player listener.

Parameters:
scale - New scale to be played.

getSequencer


public S getSequencer()
Returns the sequencer that triggers note playings.

Returns:
The sequencer that triggers note playings.

setSequencer


public void setSequencer(S sequencer)
Sets the sequencer that triggers note playings.

Parameters:
sequencer - New sequencer that triggers note playings.

stepChanged


public void stepChanged(SequencerEvent<S,B> sequencerEvent)
Invoked when a step changing occurs. This implementation calculates the note to play, and calls the playNote(MidiNote) method.

Parameters:
sequencerEvent - Informations about the sequencer event.

playNote


public abstract void playNote(MidiNote midiNote)
Plays the specified note.

Parameters:
midiNote - Midi note to play.