Class Overview
Some utilities for MIDI (some stuff is used from javax.sound.midi)
Summary
Nested Classes |
class |
MidiUtils.TempoCache |
|
Public Methods |
static
double
|
convertTempo(double tempo)
converts
1 - MPQ-Tempo to BPM tempo
2 - BPM tempo to MPQ tempo
|
static
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 message
|
static
boolean
|
isMetaEndOfTrack(MidiMessage midiMsg)
return true if the passed message is Meta End Of Track
|
static
boolean
|
isMetaTempo(MidiMessage midiMsg)
return if the given message is a meta tempo message
|
static
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.
|
static
int
|
tick2index(Track track, long tick)
Binary search for the event indexes of the track
|
static
long
|
tick2microsecond(Sequence seq, long tick, MidiUtils.TempoCache cache)
Given a tick, convert to microsecond
|
static
long
|
ticks2microsec(long tick, double tempoMPQ, int resolution)
convert tick to microsecond with given tempo.
|
[Expand]
Inherited Methods |
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this object.
|
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
void
|
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
final
Class<?>
|
getClass()
Returns the runtime class of this Object .
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's
monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait()
Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object.
|
final
void
|
wait(long timeout, int nanos)
Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object, or
some other thread interrupts the current thread, or a certain
amount of real time has elapsed.
|
final
void
|
wait(long timeout)
Causes the current thread to wait until either another thread invokes the
notify() method or the
notifyAll() method for this object, or a
specified amount of time has elapsed.
|
|
Constants
public
static
final
int
DEFAULT_TEMPO_MPQ
Constant Value:
500000
(0x0007a120)
public
static
final
int
META_END_OF_TRACK_TYPE
Constant Value:
47
(0x0000002f)
public
static
final
int
META_TEMPO_TYPE
Constant Value:
81
(0x00000051)
Public Constructors
Public Methods
public
static
double
convertTempo
(double tempo)
converts
1 - MPQ-Tempo to BPM tempo
2 - BPM tempo to MPQ tempo
public
static
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 message
public
static
boolean
isMetaEndOfTrack
(MidiMessage midiMsg)
return true if the passed message is Meta End Of Track
public
static
boolean
isMetaTempo
(MidiMessage midiMsg)
return if the given message is a meta tempo message
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!
public
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.getCurrTempoMPQ
public
static
int
tick2index
(Track track, long tick)
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
public
static
long
tick2microsecond
(Sequence seq, long tick, MidiUtils.TempoCache cache)
Given a tick, convert to microsecond
Parameters
cache
| tempo info and current tempo
|
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!