TempoControl controls the tempo, in musical terms, of a song.
TempoControl is typically implemented in Players for MIDI
media, i.e. playback of a Standard MIDI File (SMF).
TempoControl is basic functionality for a MIDI playback
application. This is in contrast to {@link MIDIControl MIDIControl},
which targets advanced applications. Moreover, TempoControl
needs a sequence - e.g. a MIDI file - to operate. MIDIControl
does not require a sequence.
Musical tempo is usually specified in beats per minute. To
provide a means to access tempos with fractional beats per
minute, the methods to set and get the tempo work on
"milli-beat" per minute. A simple division by
1000 is sufficient to get the actual beats per minute.
As a MIDI file can contain any number of tempo changes
during playback, the absolute tempo is a state of the
sequencer. During playback of a MIDI file, setting the tempo
in response to a user interaction will not always yield the
desired result: the user's tempo can be overridden by the
playing MIDI file to another tempo just moments later.
In order to overcome this problem, a relative tempo rate is
used (in Java Sound terms: tempo factor). This rate is
applied to all tempo settings. The tempo rate is specified
in "milli-percent", i.e. a value of 100'000 means
playback at original tempo. The tempo rate is set with the
setRate() method of the super class,
{@link RateControl RateControl}.
The concept of tempo rate allows one to play back a MIDI sequence
at a different tempo without losing the relative tempo changes
in it.
The setTempo() and getTempo() methods
do not affect or reflect the playback rate. This means that
changing the
rate will not result in a change of the value returned by
getTempo() . Similarly, setting the tempo with
setTempo() does not change the rate, i.e.
the return value of getRate() is not changed. The
effective playback tempo is always the product of tempo and rate:
effectiveBeatsPerMinute = getTempo()
getRate() / 1000 / 100000
|