- All Known Implementing Classes:
ASequencePlayer
,SequencePlayer
,SequencePlayer2
public interface ISequencePlayer
Abstract sequence player to create and play MIDI music sequences.
- Author:
- swong
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionint
Add a note to the MIDI sequence with a default velocity of 64 for middle volumeint
Add a note to the MIDI sequence.int
getTempo()
Accessor for the current tempoint
Accessor to get the current ticks per default noteint
Accessor for the current number of ticks per quarter note.boolean
init(int ticksPerQuarterNote, int instrument)
Initialize the sequence player as per the supplied ticksPerQuarterNote and instrument this SequencePlayer was instantiated with.void
play(ISequencePlayerStatus statusCmd)
Play the created sequence.void
setTempo(int bpm)
Set the tempo - can't change the tempo in the middle of a sequence, the last tempo set will be used for the whole sequence.void
setTicksPerDefaultNote(int ticksPerDefaultNote)
Accessor to set the current ticks per default notevoid
stop()
Stop playing music and close resources.
-
Field Details
-
END_OF_TRACK
static final int END_OF_TRACKEnd of track marker- See Also:
- Constant Field Values
-
-
Method Details
-
init
boolean init(int ticksPerQuarterNote, int instrument)Initialize the sequence player as per the supplied ticksPerQuarterNote and instrument this SequencePlayer was instantiated with. This method is called by the constructor to initialize the player upon instantiation and can be called again to reinitialize the SequencePlayer.- Parameters:
ticksPerQuarterNote
- - tick definitioninstrument
- - MIDI instrument- Returns:
- - true if properly initialized, false otherwise
-
addNote
Add a note to the MIDI sequence with a default velocity of 64 for middle volume- Parameters:
note
- - the note to schedule in the sequencestart
- - the tick at which this note should start playing- Returns:
- - the tick at which this note stops playing
-
addNote
Add a note to the MIDI sequence.- Parameters:
note
- - the note to schedule in the sequencestart
- - the tick at which this note should start playingvelocity
- - the volume (0-127)- Returns:
- - the tick at which this note stops playing
-
play
Play the created sequence.- Parameters:
statusCmd
- The finished() method of this command is called when the track finishes being played, i.e. a normal termination. There is no notification if play is forcibly stopped.
-
stop
void stop()Stop playing music and close resources. -
getTicksPerDefaultNote
int getTicksPerDefaultNote()Accessor to get the current ticks per default note- Returns:
- the _ticksPerDefaultNote
-
setTicksPerDefaultNote
void setTicksPerDefaultNote(int ticksPerDefaultNote)Accessor to set the current ticks per default note- Parameters:
ticksPerDefaultNote
- the _ticksPerDefaultNote to set
-
getTempo
int getTempo()Accessor for the current tempo- Returns:
- the tempo (in beats per minute)
-
setTempo
void setTempo(int bpm)Set the tempo - can't change the tempo in the middle of a sequence, the last tempo set will be used for the whole sequence.- Parameters:
bpm
- - beats per minute
-
getTicksPerQuarterNote
int getTicksPerQuarterNote()Accessor for the current number of ticks per quarter note.- Returns:
- the number of ticks per quarter note
-