MidiPlayerTK.MPTKSignature

Contains information about signature change.
More...

Public Member Functions

 MPTKSignature (int index, long fromTick=0, long toTick=long.MaxValue, int numberBeatsMeasure=4, int numberQuarterBeat=4)
 Create a signtaure segment with default value More...
 
int CalculateBeat (long tick, int measure)
 
int TickToMeasure (long tick)
 
override string ToString ()
 

Static Public Member Functions

static void CalculateMap (int deltaTicksPerQuarterNote, List< MPTKEvent > mptkEvents, List< MPTKSignature > signaturesMap)
 
static void CalculateMeasureBoundaries (List< MPTKSignature > signaturesMap)
 
static int FindSegment (List< MPTKSignature > signMap, long tickSearch, int fromIndex=0)
 
static long MeasureToTick (List< MPTKSignature > temposMap, int measure)
 

Public Attributes

int FromMeasure
 
long FromTick
 
int Index
 
int NumberBeatsMeasure
 
int NumberQuarterBeat
 
int ToMeasure
 
long ToTick
 

Static Public Attributes

static int DeltaTicksPerQuarterNote
 

Detailed Description

Contains information about signature change.

Version
Maestro 2.10.0
Note
  • The signature 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 signature map must be run by script on your MIDI events when created with MidiFileWriter2 with:
    #MPTK_CalculateMap and #MPTK_CalculateMeasureBoundaries
  • Each segments defined the tick start/end, the measure start/end.

Constructor & Destructor Documentation

◆ MPTKSignature()

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

Create a signtaure segment with default value

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

Member Function Documentation

◆ 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()

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

Create 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)
    mfw.StableSortEvents();
    // Calculate time, measure and beat for each events
    mfw.CalculateTiming(logDebug: true, logPerf: true);
    mfw.LogWriter();
Parameters
deltaTicksPerQuarterNote
mptkEvents
signaturesMap

◆ CalculateMeasureBoundaries()

static 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)
mfw.StableSortEvents();
// Calculate time, measure and beat for each events
mfw.CalculateTiming(logDebug: true, logPerf: true);
mfw.LogWriter();
Parameters
signaturesMap

◆ FindSegment()

static 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

◆ MeasureToTick()

static 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.

◆ TickToMeasure()

int MidiPlayerTK.MPTKSignature.TickToMeasure ( long  tick)

Search a measure from a tick in this segment map.

Parameters
tick
Returns

◆ ToString()

override string MidiPlayerTK.MPTKSignature.ToString ( )

String description of this segment

Returns

Member Data Documentation

◆ DeltaTicksPerQuarterNote

int MidiPlayerTK.MPTKSignature.DeltaTicksPerQuarterNote
static

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

◆ FromMeasure

int MidiPlayerTK.MPTKSignature.FromMeasure

Start measure of this segment of event

◆ FromTick

long MidiPlayerTK.MPTKSignature.FromTick

Tick start of this segment

◆ Index

int MidiPlayerTK.MPTKSignature.Index

Index of this segment if added to a list of tempo map with #MPTK_CalculateTempoMap

◆ NumberBeatsMeasure

int MidiPlayerTK.MPTKSignature.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/

◆ 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

◆ ToMeasure

int MidiPlayerTK.MPTKSignature.ToMeasure

End measure of this segment of event

◆ ToTick

long MidiPlayerTK.MPTKSignature.ToTick

Tick end of this segment