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

Contains information about time signature changes in a MIDI file. More...

Public Member Functions

 MPTKSignature (int index, long fromTick=0, long toTick=long.MaxValue, int numberBeatsMeasure=4, int numberQuarterBeat=4)
 Creates a signtaure segment with default value.
int TickToMeasure (long tick)
 Search a measure from a tick in this segment map.
int CalculateBeat (long tick, int measure)
 Calculate beat for this tick and measure position in this segment.
override string ToString ()
 String description of this segment.

Static Public Member Functions

static long MeasureToTick (List< MPTKSignature > temposMap, int measure)
 Search a tick position from a measure tempo map.
static void CalculateMap (int deltaTicksPerQuarterNote, List< MPTKEvent > mptkEvents, List< MPTKSignature > signaturesMap)
 Creates a signature map from a MIDI events list with time signature.
static void CalculateMeasureBoundaries (List< MPTKSignature > signaturesMap)
 Calculate FromMeasure and ToMeasure for all segments in the signature map.
static int FindSegment (List< MPTKSignature > signMap, long tickSearch, int fromIndex=0)
 Find a signature change from a tick position in the tempo map.

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.
int NumberBeatsMeasure
 From TimeSignature event: The numerator counts the number of beats in a mesure.
For example a numerator of 4 means that each bar contains four beats.
This is important knowing this value because usually the first beat of each bar has extra emphasis.
https://paxstellar.fr/2020/09/11/midi-timing/.
int NumberQuarterBeat
 From TimeSignature event: Describes of what note value a beat is.
int FromMeasure
 Start measure of this segment of event.
int ToMeasure
 End measure of this segment of event.

Static Public Attributes

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

Detailed Description

Contains information about time signature changes in a MIDI file.

Version
Maestro 2.10.0
Note
  • The signature map is automatically built when a MIDI file is loaded from the MIDI DB, from an external MIDI, or from a MIDI Writer instance.
  • The signature map must be processed by script on your MIDI events when created with MidiFileWriter2 using: #MPTK_CalculateMap and #MPTK_CalculateMeasureBoundaries
  • Each segment define the tick start/end and the measure start/end for the time signature.

Constructor & Destructor Documentation

◆ MPTKSignature()

MidiPlayerTK.MPTKSignature.MPTKSignature ( int index,
long fromTick = 0,
long toTick = long::MaxValue,
int numberBeatsMeasure = 4,
int numberQuarterBeat = 4 )

Creates a signtaure segment with default value.

Parameters
index
fromTickdefault 0
toTickdefault ong.MaxValue
numberBeatsMeasuredefault 4
numberQuarterBeatdefault 4

Member Function Documentation

◆ TickToMeasure()

int MidiPlayerTK.MPTKSignature.TickToMeasure ( long tick)

Search a measure from a tick in this segment map.

Parameters
tick
Returns

◆ MeasureToTick()

long MidiPlayerTK.MPTKSignature.MeasureToTick ( List< MPTKSignature > temposMap,
int measure )
static

Search a tick position from a measure tempo map.

Note
#MPTK_CalculateMeasureBoundaries must be applied to the tempo map before this call.
Parameters
temposMapList of tempo maps
measuremeasure to search (start at 1)
Returns
tick position found, value will be between FromTick and ToTick.

◆ CalculateBeat()

int MidiPlayerTK.MPTKSignature.CalculateBeat ( long tick,
int measure )

Calculate beat for this tick and measure position in this segment.

Parameters
ticktick to search in this segemnt map
measuremeasure to search in this segemnt map
Returns
Beat position (between 1 and NumberBeatsMeasure)

◆ CalculateMap()

void MidiPlayerTK.MPTKSignature.CalculateMap ( int deltaTicksPerQuarterNote,
List< MPTKEvent > mptkEvents,
List< MPTKSignature > signaturesMap )
static

Creates a signature map from a MIDI events list with time signature.

  • an allocated tempo map must be defined in parameter but the content will be cleared.
  • a default time signature 4/4 is created if no time signature event found
    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
    signaturesMap

◆ CalculateMeasureBoundaries()

void MidiPlayerTK.MPTKSignature.CalculateMeasureBoundaries ( List< MPTKSignature > signaturesMap)
static

Calculate FromMeasure and ToMeasure for all segments in the signature map.

// 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
signaturesMap

◆ FindSegment()

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

Find a signature change from a tick position in the tempo map.

Parameters
signMapList of tempo map build with MPTK_CalculateTempoMap
tickSearchsearch from this tick value
fromIndexsearch from this index position in the list (for optimazation)
Returns

◆ ToString()

override string MidiPlayerTK.MPTKSignature.ToString ( )

String description of this segment.

Returns

Member Data Documentation

◆ NumberQuarterBeat

int MidiPlayerTK.MPTKSignature.NumberQuarterBeat

From TimeSignature event: Describes of what note value a beat is.

Note
Calculated with 2^MPTK_TimeSigDenominatorn
  • 1 for a whole-note
  • 2 for a half-note
  • 4 for a quarter-note
  • 8 for an eighth-note, etc.
Equal 2 Power TimeSigDenominator from the MIDI signature message.
https://paxstellar.fr/2020/09/11/midi-timing/ https://majicdesigns.github.io/MD_MIDIFile/page_timing.html