MidiPlayerTK.MidiFileWriter2

[MPTK PRO] Build and Write a MIDI file from different sources.
More...

Public Member Functions

 MidiFileWriter2 ()
 
 MidiFileWriter2 (int deltaTicksPerQuarterNote, int midiFileType)
 
void MPTK_AddBPMChange (int track, long absoluteTime, int bpm)
 
void MPTK_AddChangePreset (int track, long absoluteTime, int channel, int preset)
 
void MPTK_AddChangePresetMilli (int track, float timeToPlay, int channel, int preset)
 
void MPTK_AddChannelAfterTouch (int track, long absoluteTime, int channel, int afterTouchPressure)
 
void MPTK_AddChannelAfterTouchMilli (int track, float timeToPlay, int channel, int afterTouchPressure)
 
void MPTK_AddChordFromLib (int track, long absoluteTime, int channel, MPTKChordName chordName, MPTKChordBuilder chord)
 
void MPTK_AddChordFromRange (int track, long absoluteTime, int channel, MPTKRangeLib range, MPTKChordBuilder chord)
 
void MPTK_AddControlChange (int track, long absoluteTime, int channel, MPTKController controller, int controllerValue)
 
void MPTK_AddControlChangeMilli (int track, float timeToPlay, int channel, MPTKController controller, int controllerValue)
 
void MPTK_AddNote (int track, long absoluteTime, int channel, int note, int velocity, int duration)
 
void MPTK_AddNoteMilli (int track, float timeToPlay, int channel, int note, int velocity, float duration)
 
void MPTK_AddOff (int track, long absoluteTime, int channel, int note)
 
void MPTK_AddOffMilli (int track, float timeToPlay, int channel, int note)
 
void MPTK_AddPitchWheelChange (int track, long absoluteTime, int channel, float pitchWheel)
 
void MPTK_AddPitchWheelChangeMilli (int track, float timeToPlay, int channel, float pitchWheel)
 
void MPTK_AddTempoChange (int track, long absoluteTime, int microsecondsPerQuarterNote)
 
void MPTK_AddText (int track, long absoluteTime, MPTKMeta typeMeta, string text)
 
void MPTK_AddTextMilli (int track, float timeToPlay, MPTKMeta typeMeta, string text)
 
void MPTK_AddTimeSignature (int track, long absoluteTime, int numerator=4, int denominator=4, int ticksInMetronomeClick=24, int no32ndNotesInQuarterNote=32)
 
MidiFile MPTK_BuildNAudioMidi ()
 
void MPTK_Clear ()
 
long MPTK_ConvertMilliToTick (float time)
 
float MPTK_ConvertTickToMilli (long tick)
 
void MPTK_CreateTrack (int count)
 
bool MPTK_Debug (string filename=null)
 
void MPTK_EndTrack (int trackNumber)
 
bool MPTK_LoadFromFile (string filename)
 
bool MPTK_LoadFromMidiDB (int indexMidiDb)
 
bool MPTK_LoadFromMPTK (List< TrackMidiEvent > midiEvents, int track=1)
 
void MPTK_SortEvents ()
 
bool MPTK_WriteToFile (string filename)
 
bool MPTK_WriteToMidiDB (string filename)
 

Static Public Member Functions

static int MPTK_BPM2MPQN (int bpm)
 
static int MPTK_GetMicrosecondsPerQuaterNote (int bpm)
 
static int MPTK_MPQN2BPM (int microsecondsPerQuaterNote)
 

Public Attributes

int MPTK_DeltaTicksPerQuarterNote
 
int MPTK_MidiFileType
 
string MPTK_MidiName
 

Properties

int Bpm [get]
 
int MPTK_MicrosecondsPerQuaterNote [get]
 
float MPTK_PulseLenght [get]
 
int MPTK_TrackCount [get]
 

Detailed Description

[MPTK PRO] Build and Write a MIDI file from different sources.

See full example with these scripts:

  • TestMidiGenerator.cs for an example of MIDI stream creation.
  • TinyMidiSequencer.cs for a light sequencer.

    This class replace MidiFileWriter with these changes: channel start at 0, new specfic event, better control.
    More information here: https://paxstellar.fr/class-midifilewriter2/

Constructor & Destructor Documentation

◆ MidiFileWriter2() [1/2]

MidiPlayerTK.MidiFileWriter2.MidiFileWriter2 ( )

Create an empty MidiFileWriter2. Set default value from the midi norm:

  • type = 1
  • Delta Ticks Per Quarter Note = 240
  • Beats Per Minute = 120

◆ MidiFileWriter2() [2/2]

MidiPlayerTK.MidiFileWriter2.MidiFileWriter2 ( int  deltaTicksPerQuarterNote,
int  midiFileType 
)

Create a MidiFileWriter2 with specific header midi value (for advanced use)

Parameters
deltaTicksPerQuarterNoteDelta Ticks Per Quarter Note
midiFileTypetype of Midi format. Must be 0 or 1 (better)

Member Function Documentation

◆ MPTK_AddBPMChange()

void MidiPlayerTK.MidiFileWriter2.MPTK_AddBPMChange ( int  track,
long  absoluteTime,
int  bpm 
)

Add a tempo change to the midi stream. There is no channel in parameter because tempo change is apply to the whole midi.

Parameters
trackTrack for this event
absoluteTimeTick time for this event
bpmquarter per minute

◆ MPTK_AddChangePreset()

void MidiPlayerTK.MidiFileWriter2.MPTK_AddChangePreset ( int  track,
long  absoluteTime,
int  channel,
int  preset 
)

Add a change preset

Parameters
trackTrack for this event
absoluteTimeTick time for this event
channelChannel must be in the range 0-15
presetPreset (program/patch) must be in the range 0-127

◆ MPTK_AddChangePresetMilli()

void MidiPlayerTK.MidiFileWriter2.MPTK_AddChangePresetMilli ( int  track,
float  timeToPlay,
int  channel,
int  preset 
)

Add a change preset

Parameters
trackTrack for this event
timeToPlaytime in millisecond to play the note from the start of the Midi
channelChannel must be in the range 0-15
presetPreset (program/patch) must be in the range 0-127

◆ MPTK_AddChannelAfterTouch()

void MidiPlayerTK.MidiFileWriter2.MPTK_AddChannelAfterTouch ( int  track,
long  absoluteTime,
int  channel,
int  afterTouchPressure 
)

Add a Channel After-Touch Event

Parameters
trackTrack for this event
absoluteTimeTick time for this event
channelChannel must be in the range 0-15
afterTouchPressureAfter-touch pressure from 0 to 127

◆ MPTK_AddChannelAfterTouchMilli()

void MidiPlayerTK.MidiFileWriter2.MPTK_AddChannelAfterTouchMilli ( int  track,
float  timeToPlay,
int  channel,
int  afterTouchPressure 
)

Add a Channel After-Touch Event

Parameters
trackTrack for this event
timeToPlaytime in millisecond to play the note from the start of the Midi
channelChannel must be in the range 0-15
afterTouchPressureAfter-touch pressure from 0 to 127

◆ MPTK_AddChordFromLib()

void MidiPlayerTK.MidiFileWriter2.MPTK_AddChordFromLib ( int  track,
long  absoluteTime,
int  channel,
MPTKChordName  chordName,
MPTKChordBuilder  chord 
)

Add a chord from a library of chord

MPTKChordBuilder chordLib = new MPTKChordBuilder() { Tonic = 60, Duration = duration, Velocity = 80, };
mfw.MPTK_AddChordFromLib(track1, absoluteTime, channel0, MPTKChordName.Major, chordLib); absoluteTime += ticksPerQuarterNote;
chordLib.Tonic = 62;
mfw.MPTK_AddChordFromLib(track1, absoluteTime, channel0, MPTKChordName.mM7, chordLib); absoluteTime += ticksPerQuarterNote;
chordLib.Tonic = 67;
mfw.MPTK_AddChordFromLib(track1, absoluteTime, channel0, MPTKChordName.m7b5, chordLib); absoluteTime += ticksPerQuarterNote;
chordLib.Tonic = 65;
mfw.MPTK_AddChordFromLib(track1, absoluteTime, channel0, MPTKChordName.M7, chordLib); absoluteTime += ticksPerQuarterNote;
[MPTK PRO] Build Chord and Play with MidiStreamPlayer.
Definition: MPTKChordBuilder.cs:16
MPTKChordName
[MPTK PRO] List of chords available
Definition: MPTKChordName.cs:13
Parameters
track
absoluteTime
channel
chordNameName of the chord See MPTKChordName
chordSee MPTKChordBuilder

◆ MPTK_AddChordFromRange()

void MidiPlayerTK.MidiFileWriter2.MPTK_AddChordFromRange ( int  track,
long  absoluteTime,
int  channel,
MPTKRangeLib  range,
MPTKChordBuilder  chord 
)

Add a chord from a range

// Play 4 chords, degree I - V - IV - V
// ------------------------------------
mfw.MPTK_AddText(track0, absoluteTime, MPTKMeta.SequenceTrackName, "Play 4 chords, degree I - V - IV - V ");
// We need degrees in major, so build a major range
MPTKRangeLib rangeMajor = MPTKRangeLib.Range(MPTKRangeName.MajorHarmonic);
// Build chord degree 1
MPTKChordBuilder chordDegreeI = new MPTKChordBuilder()
{
// Parameters to build the chord
Tonic = 60, // play in C
Count = 3, // 3 notes to build the chord (between 2 and 20, of course it doesn't make sense more than 7, its only for fun or experiementation ...)
Degree = 1,
// Midi Parameters how to play the chord
Duration = duration, // millisecond, -1 to play indefinitely
Velocity = 80, // Sound can vary depending on the velocity
// Optionnal MPTK specific parameters
Arpeggio = 0, // delay in milliseconds between each notes of the chord
Delay = 0, // delay in milliseconds before playing the chord
};
// Build chord degree V
MPTKChordBuilder chordDegreeV = new MPTKChordBuilder() { Tonic = 60, Count = 3, Degree = 5, Duration = duration, Velocity = 80, };
// Build chord degree IV
MPTKChordBuilder chordDegreeIV = new MPTKChordBuilder() { Tonic = 60, Count = 3, Degree = 4, Duration = duration, Velocity = 80, };
// Add degrees I - V - IV - V in the MIDI (all in major)
mfw.MPTK_AddChordFromRange(track1, absoluteTime, channel0, rangeMajor, chordDegreeI); absoluteTime += ticksPerQuarterNote;
mfw.MPTK_AddChordFromRange(track1, absoluteTime, channel0, rangeMajor, chordDegreeV); absoluteTime += ticksPerQuarterNote;
mfw.MPTK_AddChordFromRange(track1, absoluteTime, channel0, rangeMajor, chordDegreeIV); absoluteTime += ticksPerQuarterNote;
mfw.MPTK_AddChordFromRange(track1, absoluteTime, channel0, rangeMajor, chordDegreeV); absoluteTime += ticksPerQuarterNote;
[MPTK PRO] Build Scale and Play with MidiStreamPlayer.
Definition: MPTKRangeLib.cs:45
static MPTKRangeLib Range(int index, bool log=false)
Definition: MPTKRangeLib.cs:119
MPTKMeta
Definition: MPTKEvent.cs:318
MPTKRangeName
[MPTK PRO] List of ranges available
Definition: MPTKRangeName.cs:13
Parameters
track
absoluteTime
channel
rangeSee MPTKRangeLib
chordSee MPTKChordBuilder

◆ MPTK_AddControlChange()

void MidiPlayerTK.MidiFileWriter2.MPTK_AddControlChange ( int  track,
long  absoluteTime,
int  channel,
MPTKController  controller,
int  controllerValue 
)

Creates a general control change event (CC)

Parameters
trackTrack for this event
absoluteTimeTick time for this event
channelChannel must be in the range 0-15
controllerThe MIDI Controller. See MPTKController
controllerValueController value

◆ MPTK_AddControlChangeMilli()

void MidiPlayerTK.MidiFileWriter2.MPTK_AddControlChangeMilli ( int  track,
float  timeToPlay,
int  channel,
MPTKController  controller,
int  controllerValue 
)

Creates a control change event

Parameters
trackTrack for this event
timeToPlaytime in millisecond to play the note from the start of the Midi
channelChannel must be in the range 0-15
controllerThe MIDI Controller. See MPTKController
controllerValueController value

◆ MPTK_AddNote()

void MidiPlayerTK.MidiFileWriter2.MPTK_AddNote ( int  track,
long  absoluteTime,
int  channel,
int  note,
int  velocity,
int  duration 
)

Add a note on event at an absolute time (tick count). The corresponding Noteoff is automatically created if duration > 0

Parameters
trackTrack for this event
absoluteTimeTick time for this event
channelChannel must be in the range 0-15
noteNote must be in the range 0-127
velocityVelocity must be in the range 0-127.
durationTick duration. No noteoff is added if duration is <= 0, need to be added with MPTK_AddOff

◆ MPTK_AddNoteMilli()

void MidiPlayerTK.MidiFileWriter2.MPTK_AddNoteMilli ( int  track,
float  timeToPlay,
int  channel,
int  note,
int  velocity,
float  duration 
)

Add a note on event at a specific time in millisecond The corresponding Noteoff is automatically created if duration > 0

Parameters
trackTrack for this event
timeToPlaytime in millisecond to play the note from the start of the Midi
channelChannel must be in the range 0-15
noteNote must be in the range 0-127
velocityVelocity must be in the range 0-127.
durationDuration in millisecond. No noteoff is added if duration is <= 0, need to be added with MPTK_AddOffMilli

◆ MPTK_AddOff()

void MidiPlayerTK.MidiFileWriter2.MPTK_AddOff ( int  track,
long  absoluteTime,
int  channel,
int  note 
)

Add a note off event.

Parameters
trackTrack for this event
absoluteTimeTick time for this event
channelChannel must be in the range 0-15
noteNote must be in the range 0-127

◆ MPTK_AddOffMilli()

void MidiPlayerTK.MidiFileWriter2.MPTK_AddOffMilli ( int  track,
float  timeToPlay,
int  channel,
int  note 
)

Add a note off event at a specific time in millisecond The corresponding Noteoff is automatically created if duration > 0

Parameters
trackTrack for this event
timeToPlaytime in millisecond to play the note from the start of the Midi
channelChannel must be in the range 0-15
noteNote must be in the range 0-127

◆ MPTK_AddPitchWheelChange()

void MidiPlayerTK.MidiFileWriter2.MPTK_AddPitchWheelChange ( int  track,
long  absoluteTime,
int  channel,
float  pitchWheel 
)

Creates a control change event (CC) for the pitch (Pitch Wheel)
pitchWheel=

  • 0 minimum (0 also for midi standard event value)
  • 0.5 centered value (8192 for midi standard event value)
  • 1 maximum (16383 for midi standard event value)
Parameters
trackTrack for this event
absoluteTimeTick time for this event
channelChannel must be in the range 0-15
pitchWheelNormalized Pitch Wheel Value. Range 0 to 1. V2.88.2 range normalized from 0 to 1.

◆ MPTK_AddPitchWheelChangeMilli()

void MidiPlayerTK.MidiFileWriter2.MPTK_AddPitchWheelChangeMilli ( int  track,
float  timeToPlay,
int  channel,
float  pitchWheel 
)

Creates a control change event (CC) for the pitch (Pitch Wheel)

Parameters
trackTrack for this event
timeToPlaytime in millisecond to play the note from the start of the Midi
channelChannel must be in the range 0-15
pitchWheelPitch Wheel Value. 1:normal value, 0:pitch mini, 2:pitch max

◆ MPTK_AddTempoChange()

void MidiPlayerTK.MidiFileWriter2.MPTK_AddTempoChange ( int  track,
long  absoluteTime,
int  microsecondsPerQuarterNote 
)

Add a tempo change to the midi stream in microseconds per quarter note. There is no channel in parameter because tempo change apply to the whole midi.

Parameters
trackTrack for this event
absoluteTimeTick time for this event
microsecondsPerQuarterNoteMicroseconds per quarter note

◆ MPTK_AddText()

void MidiPlayerTK.MidiFileWriter2.MPTK_AddText ( int  track,
long  absoluteTime,
MPTKMeta  typeMeta,
string  text 
)

Create a new TimeSignatureEvent. This event is optionnal. Midi sequencer assumes the default value is 4,4,24,32. No track nor channel as teampo change applied to the whole midi.

Parameters
trackTrack for this event
absoluteTimeAbsolute time of this event
typeMetaMetaEvent type (must be one that is
Parameters
textThe text in this type
associated with text data)

◆ MPTK_AddTextMilli()

void MidiPlayerTK.MidiFileWriter2.MPTK_AddTextMilli ( int  track,
float  timeToPlay,
MPTKMeta  typeMeta,
string  text 
)

Create a new TimeSignatureEvent. This event is optionnal. Midi sequencer assumes the default value is 4,4,24,32. No track nor channel as teampo change applied to the whole midi.

Parameters
trackTrack for this event
timeToPlaytime in millisecond to play the note from the start of the Midi
typeMetaMetaEvent type (must be one that is
Parameters
textThe text in this type
associated with text data)

◆ MPTK_AddTimeSignature()

void MidiPlayerTK.MidiFileWriter2.MPTK_AddTimeSignature ( int  track,
long  absoluteTime,
int  numerator = 4,
int  denominator = 4,
int  ticksInMetronomeClick = 24,
int  no32ndNotesInQuarterNote = 32 
)

Create a new TimeSignatureEvent. This event is optionnal. Internal Midi sequencer assumes the default value is 4,4,24,32. No track nor channel as teampo change applied to the whole midi.

Parameters
trackTrack for this event
absoluteTimeTime at which to create this event
numeratorNumerator
denominatorDenominator
ticksInMetronomeClickTicks in Metronome Click. Set to 24 for a standard value.
no32ndNotesInQuarterNoteNo of 32nd Notes in Quarter Click. Set to 32 for a standard value.

More info here https://paxstellar.fr/2020/09/11/midi-timing/

◆ MPTK_BPM2MPQN()

static int MidiPlayerTK.MidiFileWriter2.MPTK_BPM2MPQN ( int  bpm)
static

Convert BPM to duration of a quarter in microsecond

Parameters
bpmm
Returns

◆ MPTK_BuildNAudioMidi()

MidiFile MidiPlayerTK.MidiFileWriter2.MPTK_BuildNAudioMidi ( )

Build a NAudio midi object from the midi events

Returns

◆ MPTK_Clear()

void MidiPlayerTK.MidiFileWriter2.MPTK_Clear ( )

Remove all midi events

◆ MPTK_ConvertMilliToTick()

long MidiPlayerTK.MidiFileWriter2.MPTK_ConvertMilliToTick ( float  time)

Convert a real time duration in millisecond to a number of tick regarding the current tempo.

Parameters
timeduration in milliseconds
Returns
duration in ticks

◆ MPTK_ConvertTickToMilli()

float MidiPlayerTK.MidiFileWriter2.MPTK_ConvertTickToMilli ( long  tick)

Convert the tick duration to a real time duration in millisecond regarding the current tempo.

Parameters
tickduration in ticks
Returns
duration in milliseconds

◆ MPTK_CreateTrack()

void MidiPlayerTK.MidiFileWriter2.MPTK_CreateTrack ( int  count)

DEPRECATED Create more tracks in the stream (one default track is created at init).
From version 2.88 tracks will be created automatically when writing Midi to a file. See MPTK_WriteToFile.

Parameters
countnumber of tracks to create

◆ MPTK_Debug()

bool MidiPlayerTK.MidiFileWriter2.MPTK_Debug ( string  filename = null)

Write Midi file to an OS folder

Parameters
filenamefilename of the midi file
Returns

◆ MPTK_EndTrack()

void MidiPlayerTK.MidiFileWriter2.MPTK_EndTrack ( int  trackNumber)

DEPRECATED Close the track (mandatory for a well formed midi file). From version 2.88 tracks will be ended automatically when writing Midi to a file. See MPTK_WriteToFile.

Parameters
trackNumberTrack number to close

◆ MPTK_GetMicrosecondsPerQuaterNote()

static int MidiPlayerTK.MidiFileWriter2.MPTK_GetMicrosecondsPerQuaterNote ( int  bpm)
static

DEPRECATED - use MPTK_BPM2MPQN in place - Convert BPM to duration of a quarter in microsecond

Parameters
bpmm
Returns

◆ MPTK_LoadFromFile()

bool MidiPlayerTK.MidiFileWriter2.MPTK_LoadFromFile ( string  filename)

Load a Midi file from OS system file (could be dependant of the OS)

Parameters
filename
Returns

◆ MPTK_LoadFromMidiDB()

bool MidiPlayerTK.MidiFileWriter2.MPTK_LoadFromMidiDB ( int  indexMidiDb)

Create a MidiFileWriter2 from a Midi found in MPTK MidiDB

// Create a midi file writer
// Load the selected midi from MidiDB index
mfw.MPTK_LoadFromMidiDB(selectedMidi);
// build th path + filename to the midi
string filename = Path.Combine(Application.persistentDataPath, MidiPlayerGlobal.CurrentMidiSet.MidiFiles[selectedMidi] + ".mid");
// write the midi file
mfw.MPTK_WriteToFile(filename);
[MPTK PRO] Build and Write a MIDI file from different sources.
Definition: MidiFileWriter2.cs:22
bool MPTK_LoadFromMidiDB(int indexMidiDb)
Definition: MidiFileWriter2.cs:247
bool MPTK_WriteToFile(string filename)
Definition: MidiFileWriter2.cs:860
MidiFileWriter2()
Definition: MidiFileWriter2.cs:147
Singleton class to manage all globales MPTK features. More information here: https://paxstellar....
Definition: MidiPlayerGlobal.cs:18
Parameters
indexMidiDb

◆ MPTK_LoadFromMPTK()

bool MidiPlayerTK.MidiFileWriter2.MPTK_LoadFromMPTK ( List< TrackMidiEvent >  midiEvents,
int  track = 1 
)

Create a MidiFileWriter2 from a MidiFilePlayer. A midi file must be loaded before from a MidiFilePlayer gameobject (as in example) or from a call to MidiFileWriter2.MPTK_LoadFromFile(filename).

MidiFilePlayer mfp = FindObjectOfType<MidiFilePlayer>();
if (mfp != null)
{
if (mfp.MPTK_IsPlaying)
{
string filename = Path.Combine(Application.persistentDataPath, mfp.MPTK_MidiName + ".mid");
mfw.MPTK_WriteToFile(filename);
}
else
Debug.LogWarning("MidiFilePlayer must playing to export midi data");
}
else
Debug.LogWarning("No MidiFilePlayer found in the hierarchy");
Play a MIDI file from the MidiDB. This class must be used with the prefab MidiFilePlayer.
Definition: MidiFilePlayer.cs:65
virtual string MPTK_MidiName
Definition: MidiFilePlayer.cs:77
bool MPTK_IsPlaying
Definition: MidiFilePlayer.cs:323
List< TrackMidiEvent > MPTK_MidiEvents
Definition: MidiFilePlayer.cs:731
int MPTK_TrackCount
Definition: MidiFilePlayer.cs:394
int MPTK_DeltaTicksPerQuarterNote
Definition: MidiFilePlayer.cs:748
bool MPTK_LoadFromMPTK(List< TrackMidiEvent > midiEvents, int track=1)
Definition: MidiFileWriter2.cs:217
Parameters
midiEventsList of TrackMidiEvent
trackTRack count, default 1

◆ MPTK_MPQN2BPM()

static int MidiPlayerTK.MidiFileWriter2.MPTK_MPQN2BPM ( int  microsecondsPerQuaterNote)
static

Convert duration of a quarter in microsecond to Beats Per Minute

Parameters
microsecondsPerQuaterNote
Returns

◆ MPTK_SortEvents()

void MidiPlayerTK.MidiFileWriter2.MPTK_SortEvents ( )

Sort the events by ascending absolute time. Typically, midi events are created ordered with increase time, but if not, this method must be called before writing to file or playing. Info: the TmidiEvents list of events will rebuild with this method.

◆ MPTK_WriteToFile()

bool MidiPlayerTK.MidiFileWriter2.MPTK_WriteToFile ( string  filename)

Write Midi file to an OS folder

Parameters
filenamefilename of the midi file
Returns

◆ MPTK_WriteToMidiDB()

bool MidiPlayerTK.MidiFileWriter2.MPTK_WriteToMidiDB ( string  filename)

Write Midi file to MidiDB. To be used only in edit mode not in a standalone application.

Parameters
filenamefilename of the midi file without any folder and any extension
Returns

Member Data Documentation

◆ MPTK_DeltaTicksPerQuarterNote

int MidiPlayerTK.MidiFileWriter2.MPTK_DeltaTicksPerQuarterNote

From Midi Header: Delta Ticks Per Quarter Note. Represent the duration time in "ticks" which make up a quarter-note. For instance, if 96, then a duration of an eighth-note in the file would be 48.

◆ MPTK_MidiFileType

int MidiPlayerTK.MidiFileWriter2.MPTK_MidiFileType

Get the midi file type of the loaded midi (0,1,2)

◆ MPTK_MidiName

string MidiPlayerTK.MidiFileWriter2.MPTK_MidiName

Name of this midi stream

Property Documentation

◆ Bpm

int MidiPlayerTK.MidiFileWriter2.Bpm
get

Get current Beats Per Minute https://en.wikipedia.org/wiki/Tempo

◆ MPTK_MicrosecondsPerQuaterNote

int MidiPlayerTK.MidiFileWriter2.MPTK_MicrosecondsPerQuaterNote
get

Get current Microseconds Per Quater Note https://en.wikipedia.org/wiki/Tempo The tempo is given in micro seconds per quarter beat. To convert this to BPM use method MPTK_MPQN2BPM This value can change during the playing when a change tempo event is defined. See here for more information https://paxstellar.fr/2020/09/11/midi-timing/

◆ MPTK_PulseLenght

float MidiPlayerTK.MidiFileWriter2.MPTK_PulseLenght
get

Lenght in millisecond of a tick. Obviously depends on the current tempo and the ticks per quarter.

◆ MPTK_TrackCount

int MidiPlayerTK.MidiFileWriter2.MPTK_TrackCount
get

Get the count of track. Track management is done automatically, they are created and ended as required. The count of tracks is limited to 64.