Package org.jjazz.midi.api.sequencer
Class MidiUtils
java.lang.Object
org.jjazz.midi.api.sequencer.MidiUtils
Some utilities for MIDI (some stuff is used from javax.sound.midi)
- Author:
- Florian Bomers
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkSysexStatus
(byte[] data, int length) Checks the status byte for the system exclusive message.static void
checkSysexStatus
(int status) Checks the status byte for the system exclusive message.static double
convertTempo
(double tempo) converts
1 - MPQ-Tempo to BPM tempo
2 - BPM tempo to MPQ tempostatic int
getTempoMPQ
(MidiMessage midiMsg) parses this message for a META tempo message and returns the tempo in MPQ, or -1 if this isn't a tempo messagestatic boolean
isMetaEndOfTrack
(MidiMessage midiMsg) return true if the passed message is Meta End Of Trackstatic boolean
isMetaTempo
(MidiMessage midiMsg) return if the given message is a meta tempo messagestatic long
microsec2ticks
(long us, double tempoMPQ, int resolution) convert tempo to microsecond with given tempo Does not take tempo changes into account.static long
microsecond2tick
(Sequence seq, long micros, MidiUtils.TempoCache cache) Given a microsecond time, convert to tick. returns tempo at the given time in cache.getCurrTempoMPQstatic int
tick2index
(Track track, long tick) Binary search for the event indexes of the trackstatic long
tick2microsecond
(Sequence seq, long tick, MidiUtils.TempoCache cache) Given a tick, convert to microsecondstatic long
ticks2microsec
(long tick, double tempoMPQ, int resolution) convert tick to microsecond with given tempo.
-
Field Details
-
DEFAULT_TEMPO_MPQ
public static final int DEFAULT_TEMPO_MPQ- See Also:
-
META_END_OF_TRACK_TYPE
public static final int META_END_OF_TRACK_TYPE- See Also:
-
META_TEMPO_TYPE
public static final int META_TEMPO_TYPE- See Also:
-
-
Method Details
-
checkSysexStatus
Checks the status byte for the system exclusive message.- Parameters:
data
- the system exclusive message datalength
- the length of the valid message data in the array- Throws:
InvalidMidiDataException
- if the status byte is invalid for a system exclusive message
-
checkSysexStatus
Checks the status byte for the system exclusive message.- Parameters:
status
- the status byte for the message (0xF0 or 0xF7)- Throws:
InvalidMidiDataException
- if the status byte is invalid for a system exclusive message
-
isMetaEndOfTrack
return true if the passed message is Meta End Of Track -
isMetaTempo
return if the given message is a meta tempo message -
getTempoMPQ
parses this message for a META tempo message and returns the tempo in MPQ, or -1 if this isn't a tempo message -
convertTempo
public static double convertTempo(double tempo) converts
1 - MPQ-Tempo to BPM tempo
2 - BPM tempo to MPQ tempo -
ticks2microsec
public static long ticks2microsec(long tick, double tempoMPQ, int resolution) convert tick to microsecond with given tempo. Does not take tempo changes into account. Does not work for SMPTE timing! -
microsec2ticks
public static long microsec2ticks(long us, double tempoMPQ, int resolution) convert tempo to microsecond with given tempo Does not take tempo changes into account. Does not work for SMPTE timing! -
tick2microsecond
Given a tick, convert to microsecond- Parameters:
cache
- tempo info and current tempo
-
microsecond2tick
Given a microsecond time, convert to tick. returns tempo at the given time in cache.getCurrTempoMPQ -
tick2index
Binary search for the event indexes of the track- Parameters:
tick
- tick number of index to be found in array- Returns:
- index in track which is on or after "tick". if no entries are found that follow after tick, track.size() is returned
-