Maestro - Midi Player Tool Kit for Unity Version 2.18.2
Loading...
Searching...
No Matches

Contains information about the tempo change.
. More...

Public Member Functions

 MPTKTempo (int index, long fromTick=0, long toTick=long.MaxValue, double fromTime=0d, double pulse=0d, int microsecondsPerQuarterNote=0)
 Creates a tempo segment with default value.
double CalculateTime (long tick)
 Realtime in milliseconds for this tick in this segment.
override string ToString ()
 String description of this segment.

Static Public Member Functions

static int FindSegment (List< MPTKTempo > tempoMap, long tickSearch, int fromIndex=0)
 Find an index in the tempo change list from a tick position.
static int FindSegment (List< MPTKTempo > tempoMap, float timeSearch, int fromIndex=0)
 Find an index in the tempo change list from a time position in milliseconds.
static void CalculateMap (int deltaTicksPerQuarterNote, List< MPTKEvent > mptkEvents, List< MPTKTempo > temposMap)
 Creates a tempo map from a MIDI events list with tempo change.
An allocated tempo map must be defined in parameter but the content will be cleared.

Public Attributes

int Index
 Index of this segment if added to a list of tempo map with #MPTK_CalculateTempoMap.
long FromTick
 Tick start of this segment.
long ToTick
 Tick end of this segment.
double FromTime
 Exact time in milliseconds to reach this tempo or signature change.
double Pulse
 Duration in milliseconds of a MIDI tick in this segment. The pulse length is the minimum time in milliseconds between two MIDI events.
.
int MicrosecondsPerQuarterNote
 BPM = 60000000 / MicrosecondsPerQuarterNote.

Static Public Attributes

static int DeltaTicksPerQuarterNote
 This information is mandatory to calculate start/end measure and beat.

Detailed Description

Contains information about the tempo change.
.

Version
Maestro 2.9.0
Note
  • The tempo map is automaticalled build when a MIDI file is loaded from the MIDI DB, from an external MIDI or from a MIDI Writer instance.
  • The tempo map must be run by script on your MIDI events when created with MidiFileWriter2 with:
    #MPTK_CalculateTempoMap
  • Each segments defined the tick start/end and the start real time of the segment and the pulse (duration in milliseconds of a MIDI tick) which is constant all along the segment.

Constructor & Destructor Documentation

◆ MPTKTempo()

MidiPlayerTK.MPTKTempo.MPTKTempo ( int index,
long fromTick = 0,
long toTick = long::MaxValue,
double fromTime = 0d,
double pulse = 0d,
int microsecondsPerQuarterNote = 0 )

Creates a tempo segment with default value.

Parameters
index
fromTickdefault 0
toTickdefault ong.MaxValue
fromTimedefault 0
pulsedefault 0
microsecondsPerQuarterNotedefault 0

Member Function Documentation

◆ FindSegment() [1/2]

int MidiPlayerTK.MPTKTempo.FindSegment ( List< MPTKTempo > tempoMap,
long tickSearch,
int fromIndex = 0 )
static

Find an index in the tempo change list from a tick position.

Warning
  • To avoid confusion with search by time, make sure the tickSearch parameter is a long (or int).
Note
  • If tick is a border between two segments, the upper segment is returned.
Parameters
tempoMapList of tempo map build with MPTK_CalculateTempoMap
tickSearchsearch from this tick value
fromIndexsearch from this index position in the list (for optimization)
Returns
index of the segment in tempoMap

◆ FindSegment() [2/2]

int MidiPlayerTK.MPTKTempo.FindSegment ( List< MPTKTempo > tempoMap,
float timeSearch,
int fromIndex = 0 )
static

Find an index in the tempo change list from a time position in milliseconds.

Warning
  • To avoid confusion with search by ticks, make sure the timeSearch parameter is a float.
Note
Parameters
tempoMapList of tempo map build with MPTK_CalculateTempoMap
timeSearchsearch from this time in milliseconds
fromIndexsearch from this index position in the TempoMap list (for optimization)
Returns
index of the segment in tempoMap

◆ CalculateTime()

double MidiPlayerTK.MPTKTempo.CalculateTime ( long tick)

Realtime in milliseconds for this tick in this segment.

Parameters
tick
Returns

◆ CalculateMap()

void MidiPlayerTK.MPTKTempo.CalculateMap ( int deltaTicksPerQuarterNote,
List< MPTKEvent > mptkEvents,
List< MPTKTempo > temposMap )
static

Creates a tempo map from a MIDI events list with tempo change.
An allocated tempo map must be defined in parameter but the content will be cleared.

Note
A default tempo segment will be added at tick 0 with BPM = 120
Version
2.10.0
// A MidiFileWriter2 (mfw) has been created with new MidiFileWriter2() With a set of MIDI events.
// Sort the events by ascending absolute time (optional)
// Calculate time, measure and beat for each events
mfw.CalculateTiming(logDebug: true, logPerf: true);
mfw.LogWriter();
Parameters
deltaTicksPerQuarterNote
mptkEvents
temposMap

Member Data Documentation

◆ Pulse

double MidiPlayerTK.MPTKTempo.Pulse

Duration in milliseconds of a MIDI tick in this segment. The pulse length is the minimum time in milliseconds between two MIDI events.
.

Note
  • Depends on the current tempo, the #MPTK_DeltaTicksPerQuarterNote (but not the Speed).
  • Formula: Pulse = (60000000 / MPTK_CurrentTempo) / MPTK_DeltaTicksPerQuarterNote / 1000