MidiPlayerTK.MPTKFootPrint

Experimental - Search a MIDI from a sequence of notes and calculate a score tempo.
More...

Inherits MonoBehaviour.

class inhiriting

class  FootPrint
 Contains detailed information about a MIDI footprint. More...
 

Public Member Functions

void MPTK_AddMultiple (string filter=null)
 
void MPTK_AddOne (string name)
 
void MPTK_Clear ()
 
FootPrint MPTK_Encode (List< MPTKEvent > sequence)
 
List< FootPrintMPTK_Search (List< MPTKEvent > sequence, int countnote=-1, float tempoScore=-1f)
 

Public Attributes

List< FootPrintMPTK_MidiLib
 
bool Verbose
 

Properties

int SettingCountNote [get, set]
 
int SettingFirstNote [get, set]
 
int SettingLastNote [get, set]
 
uint SettingShiftLeft [get, set]
 

Detailed Description

Experimental - Search a MIDI from a sequence of notes and calculate a score tempo.

These capabilities and API could evolve in time or ... disappear!
A footprint is calculated for each MIDI added in MPTK_MidiLib with MPTK_AddOne or MPTK_AddMultiple.
Then MPTK_Search can be used to find a list of MIDI with the same fooprint (or partial footprint) from a sequence of notes (List of MPTKEvent).
If notes in the sequence contains duration then a tempo score is given for each MIDI found.
Limitation: max of 8 first notes are used for calculating the footprint

Version
Maestro Pro
private MPTKFootPrint libFootPrint;
void Awake()
{
libFootPrint = gameObject.AddComponent<MPTKFootPrint>();
}
private void Start()
{
libFootPrint.Verbose = true;
libFootPrint.MPTK_AddMultiple("BACH");
libFootPrint.MPTK_AddOne("_simple-48");
libFootPrint.MPTK_AddOne("_simple-49");
libFootPrint.MPTK_AddOne("_simple-50");
}
private void YourMethod()
{
// .... build a sequence of notes ...
SequenceNotes.Add(new MPTKEvent() {Command = MPTKCommand.NoteOn, Value = value, Duration = duration) });
// .... Find MIDI with this sequence ...
List<MPTKFootPrint.FootPrint> listMidi = libFootPrint.MPTK_Search(SequenceNotes);
if (listMidi.Count > 0)
{
foreach (MPTKFootPrint.FootPrint midiFP in listMidi)
Debug.Log(midiFP.ToString());
}
else { Debug.Log("No MIDI found"); }
}
Experimental - Search a MIDI from a sequence of notes and calculate a score tempo.
Definition: MidiFootPrint.cs:52
void MPTK_AddOne(string name)
Definition: MidiFootPrint.cs:139
void MPTK_AddMultiple(string filter=null)
Definition: MidiFootPrint.cs:158
List< FootPrint > MPTK_Search(List< MPTKEvent > sequence, int countnote=-1, float tempoScore=-1f)
Definition: MidiFootPrint.cs:181
MPTKCommand
Definition: MPTKEnum.cs:12

Member Function Documentation

◆ MPTK_AddMultiple()

void MidiPlayerTK.MPTKFootPrint.MPTK_AddMultiple ( string  filter = null)

Add multiple MIDI to MPTK_MidiLib.

Parameters
filterOnly add MIDI when name contains filter in parameter. No case sensitive. Add all MIDI DB if null or missing

◆ MPTK_AddOne()

void MidiPlayerTK.MPTKFootPrint.MPTK_AddOne ( string  name)

Add a MIDI to MPTK_MidiLib. Use the exact name defined in Unity resources folder MidiDB without any path or extension.

Parameters
name

◆ MPTK_Clear()

void MidiPlayerTK.MPTKFootPrint.MPTK_Clear ( )

Clear MPTK_MidiLib.

◆ MPTK_Encode()

FootPrint MidiPlayerTK.MPTKFootPrint.MPTK_Encode ( List< MPTKEvent sequence)

Calculate the footprint from the sequence of MPTKEvent. Only noteon in the range defined in the Setting are used.

Parameters
sequence
Returns
footprint

◆ MPTK_Search()

List< FootPrint > MidiPlayerTK.MPTKFootPrint.MPTK_Search ( List< MPTKEvent sequence,
int  countnote = -1,
float  tempoScore = -1f 
)

Search in MPTK_MidiLib from the footprint (or partial footprint) from a sequence of notes.
If notes in the sequence contains duration then a tempo score is given for each MIDI found.

Parameters
sequenceSequence of MPTKEvent to search. Only the 8 first notes are used
countnoteNumber of notes to search. The count of notes in sequence must be equal to the count of note of the searched MIDI.
Default= -1, for searching partial match.
tempoScoreOnly MIDI found with a score equal or greater are keep in the resulting list. Default = -1, keep all MIDI regardless the score.
Returns
List of MIDI found. Each FootPrint in list contains the MIDI name and the tempo score between 0 and 1

Member Data Documentation

◆ MPTK_MidiLib

List<FootPrint> MidiPlayerTK.MPTKFootPrint.MPTK_MidiLib

List of MIDI to search for a sequence of notes. MIDI can be added with MPTK_AddOne or MPTK_AddMultiple.

◆ Verbose

bool MidiPlayerTK.MPTKFootPrint.Verbose

For debugging goal ...

Property Documentation

◆ SettingCountNote

int MidiPlayerTK.MPTKFootPrint.SettingCountNote
getset

Number of notes used to calculated the footprint. Default value = 8.

◆ SettingFirstNote

int MidiPlayerTK.MPTKFootPrint.SettingFirstNote
getset

First note of the footprint range

◆ SettingLastNote

int MidiPlayerTK.MPTKFootPrint.SettingLastNote
getset

Last note of the footprint range

◆ SettingShiftLeft

uint MidiPlayerTK.MPTKFootPrint.SettingShiftLeft
getset

Shift bit for the footprint builder. Default value = 8. Other value has not been tested.