java.lang.Object
provided.abcMusic.player.impl.ASequencePlayer
- All Implemented Interfaces:
ISequencePlayer
- Direct Known Subclasses:
SequencePlayer
,SequencePlayer2
Common aspects of all sequence player implementations.
- Author:
- swong
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
Tempo (beats per minute)private int
MIDI Instrumentprivate static int[]
Half note steps from C in an octaveprivate Sequence
Music sequenceprivate int
Default note durationprivate int
Definition of a tickprivate Track
Track within music sequenceprotected ILogger
Logger for this and subclasses to useprivate static int
The offset of the ticks from zero to reduce the "repeated first note" problem.Fields inherited from interface provided.abcMusic.player.ISequencePlayer
END_OF_TRACK
-
Constructor Summary
ConstructorsConstructorDescriptionASequencePlayer(int ticksPerQuarterNote, int instrument)
Create a new abstract SequencePlayer to create and play music. -
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.protected Sequence
Internal accessor for the Sequence objectint
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.protected void
initBase(int ticksPerQuarterNote, int instrument)
Base initialization that sets the internal ticks per quarter note and instrument.protected boolean
Initial the internal Sequence and Track.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 noteMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface provided.abcMusic.player.ISequencePlayer
init, play, stop
-
Field Details
-
logger
Logger for this and subclasses to use -
TICK_OFFSET
private static final int TICK_OFFSETThe offset of the ticks from zero to reduce the "repeated first note" problem.- See Also:
- Constant Field Values
-
_offsets
private static final int[] _offsetsHalf note steps from C in an octave -
_track
Track within music sequence -
_bpm
private int _bpmTempo (beats per minute) -
_ticksPerDefaultNote
private int _ticksPerDefaultNoteDefault note duration -
_ticksPerQuarterNote
private int _ticksPerQuarterNoteDefinition of a tick -
_instrument
private int _instrumentMIDI Instrument -
_sequence
Music sequence
-
-
Constructor Details
-
ASequencePlayer
public ASequencePlayer(int ticksPerQuarterNote, int instrument)Create a new abstract SequencePlayer to create and play music.- Parameters:
ticksPerQuarterNote
- - tick definitioninstrument
- - MIDI instrument
-
-
Method Details
-
initBase
protected void initBase(int ticksPerQuarterNote, int instrument)Base initialization that sets the internal ticks per quarter note and instrument. Also zeroes out the beaths per minute, sets the internal ticks per default note to the ticks per quarter note and sets the internal MIDI track to null.- Parameters:
ticksPerQuarterNote
- - tick definitioninstrument
- - MIDI instrument
-
initTrack
protected boolean initTrack()Initial the internal Sequence and Track.- Returns:
- True if successful, false otherwise.
-
addNote
Add a note to the MIDI sequence with a default velocity of 64 for middle volume- Specified by:
addNote
in interfaceISequencePlayer
- Parameters:
note
- - the note to schedule in the sequencestartTick
- - the tick at which this note should start playing- Returns:
- - the tick at which this note stops playing
-
getTicksPerDefaultNote
public int getTicksPerDefaultNote()Accessor to get the current ticks per default note- Specified by:
getTicksPerDefaultNote
in interfaceISequencePlayer
- Returns:
- the _ticksPerDefaultNote
-
setTicksPerDefaultNote
public void setTicksPerDefaultNote(int ticksPerDefaultNote)Accessor to set the current ticks per default note- Specified by:
setTicksPerDefaultNote
in interfaceISequencePlayer
- Parameters:
ticksPerDefaultNote
- the _ticksPerDefaultNote to set
-
getTempo
public int getTempo()Accessor for the current tempo- Specified by:
getTempo
in interfaceISequencePlayer
- Returns:
- the tempo (in beats per minute)
-
setTempo
public 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.- Specified by:
setTempo
in interfaceISequencePlayer
- Parameters:
bpm
- - beats per minute
-
getTicksPerQuarterNote
public int getTicksPerQuarterNote()Accessor for the current number of ticks per quarter note.- Specified by:
getTicksPerQuarterNote
in interfaceISequencePlayer
- Returns:
- the number of ticks per quarter note
-
getSequence
Internal accessor for the Sequence object- Returns:
- The internal Sequence object
-
addNote
Add a note to the MIDI sequence.- Specified by:
addNote
in interfaceISequencePlayer
- Parameters:
note
- - the note to schedule in the sequencestartTick
- - the tick at which this note should start playingvelocity
- - the volume (0-127)- Returns:
- - the tick at which this note stops playing
-