|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectprovided.player.SequencePlayer
public class SequencePlayer
Sequence Player to create and play MIDI music sequences.
Field Summary | |
---|---|
private int |
_bpm
Tempo (beats per minute) |
private int |
_instrument
MIDI Instrument |
private static int[] |
_offsets
Half note steps from C in an octave |
private javax.sound.midi.Sequence |
_sequence
Music sequence |
private javax.sound.midi.Sequencer |
_sequencer
MIDI sequencer object |
private javax.sound.midi.Synthesizer |
_synthesizer
MIDI synthesizer object |
private int |
_ticksPerDefaultNote
Default note duration |
private int |
_ticksPerQuarterNote
Definition of a tick |
private javax.sound.midi.Track |
_track
Track within music sequence |
static int |
END_OF_TRACK
End of track marker |
Constructor Summary | |
---|---|
SequencePlayer(int ticksPerQuarterNote,
int instrument)
Create a new SequencePlayer to create and play music. |
Method Summary | |
---|---|
int |
addNote(Note note,
int start)
Add a note to the MIDI sequence with a default velocity of 64 for middle volume |
int |
addNote(Note note,
int start,
int velocity)
Add a note to the MIDI sequence. |
int |
getTempo()
Accessor for the current tempo |
int |
getTicksPerDefaultNote()
Accessor to get the current ticks per default note |
int |
getTicksPerQuarterNote()
Accessor for the current number of ticks per quarter note. |
boolean |
init(int ticksPerQuarterNote,
int instrument)
Initialize the SequencePlayer as per the supplied ticksPerQuarterNote and instrument this SequencePlayer was instantiated with. |
void |
play()
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 note |
void |
stop()
Stop playing music and close resources. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int END_OF_TRACK
private javax.sound.midi.Sequence _sequence
private javax.sound.midi.Track _track
private int _bpm
private int _ticksPerDefaultNote
private int _ticksPerQuarterNote
private int _instrument
private javax.sound.midi.Sequencer _sequencer
private javax.sound.midi.Synthesizer _synthesizer
private static final int[] _offsets
Constructor Detail |
---|
public SequencePlayer(int ticksPerQuarterNote, int instrument)
ticksPerQuarterNote
- - tick definitioninstrument
- - MIDI instrumentMethod Detail |
---|
public boolean init(int ticksPerQuarterNote, int instrument)
ticksPerQuarterNote
- - tick definitioninstrument
- - MIDI instrument
public int addNote(Note note, int start)
note
- - the note to schedule in the sequencestart
- - the tick at which this note should start playing
public int addNote(Note note, int start, int velocity)
note
- - the note to schedule in the sequencestart
- - the tick at which this note should start playingvelocity
- - the volume (0-127)
public void play()
public void stop()
public int getTicksPerDefaultNote()
public void setTicksPerDefaultNote(int ticksPerDefaultNote)
ticksPerDefaultNote
- the _ticksPerDefaultNote to setpublic int getTempo()
public void setTempo(int bpm)
bpm
- - beats per minutepublic int getTicksPerQuarterNote()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |