com.dixshtix.midi
Class Beats
java.lang.Object
|
+--java.lang.Number
|
+--com.dixshtix.midi.MidiNumber
|
+--com.dixshtix.midi.Beats
- All Implemented Interfaces:
- java.lang.Cloneable, java.io.Serializable
- public class Beats
- extends MidiNumber
Beats are a position within a song.
Two data bytes follow the Song Position Status. Just like with the
Pitch Wheel, these two bytes are combined into a 14-bit value. (See
Pitch Wheel remarks). This 14-bit value is the MIDI Beat upon which
to start the song. Songs are always assumed to start on a MIDI Beat of
0. Each MIDI Beat spans 6 MIDI Clocks. In other words, each MIDI Beat
is a 16th note (since there are 24 MIDI Clocks in a quarter note).
Example: If a Song Position value of 8 is received, then a sequencer
(or drum box) should cue playback to the third quarter note of the
song. (8 MIDI beats * 6 MIDI clocks per MIDI beat = 48 MIDI Clocks.
Since there are 24 MIDI Clocks in a quarter note, the first quarter
occurs on a time of 0 MIDI Clocks, the second quarter note occurs upon
the 24th MIDI Clock, and the third quarter note occurs on the 48th
MIDI Clock).
Often, the slave device has its playback tempo synced to the master
via MIDI Clock. See Syncing Sequence Playback in the package
com.dixshtix.midi.
- Version:
- 0.1
- Author:
- Richard C. Penner II
- See Also:
EventStatus.ksbSongPosition
,
EventType.kSongPosition
, Serialized Form
Fields inherited from class java.lang.Number |
serialVersionUID |
Constructor Summary |
Beats(int num)
Initialize the Ordinal number of MidiBeats. |
Method Summary |
int |
getBeats()
Returns number of MidiBeats since first Beat. |
int |
getClocks()
Returns number of MidiClocks since first QuarterNote. |
double |
getQnotes()
Returns number of MidiQuarterNotes since first QuarterNote. |
java.lang.String |
toString()
Produce a short, human-readable string. |
Methods inherited from class java.lang.Object |
, clone, finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait |
Beats
public Beats(int num)
- Initialize the Ordinal number of MidiBeats.
A beat is of period of microseconds-per-quarternote / 4.
Each MidiBeat consists of 6 MidiClocks.
It varies with the tempo and the ticks per quarternote in
the Opus header.
- Parameters:
num
- An unsigned number in the range 0-16383- See Also:
Opus.ticks_per_qnote
getBeats
public int getBeats()
- Returns number of MidiBeats since first Beat.
Zero-based, so the lowest value is 0.
getClocks
public int getClocks()
- Returns number of MidiClocks since first QuarterNote.
Zero-based, so the lowest value is 0.
Note: due the the granularity of the underlying data, this
will always be a multiple of 6.
getQnotes
public double getQnotes()
- Returns number of MidiQuarterNotes since first QuarterNote.
Zero-based, so the lowest value is 0.
toString
public java.lang.String toString()
- Produce a short, human-readable string.
Note: This assumes a
- Overrides:
toString
in class MidiNumber