MidiPlayerTK.MPTKRangeLib

[MPTK PRO] - Load library of scale from GammeDefinition.csv in folder Resources/GeneratorTemplate.csv
For more information see here https://paxstellar.fr/midi-file-player-detailed-view-2-2/
More...

Static Public Member Functions

static MPTKRangeLib Range (int index, bool log=false)
 Get a scale from an index. Scales are read from GammeDefinition.csv in folder Resources/GeneratorTemplate.csv. More...
 
static MPTKRangeLib Range (MPTKRangeName index, bool log=false)
 Get a scale from an index. Scales are read from GammeDefinition.csv in folder Resources/GeneratorTemplate.csv. More...
 

Public Attributes

int Count
 Count of notes in the range More...
 
string Flag
 Some indicator when available. More...
 
int Index
 Position in the list (from the library) More...
 
bool Main
 Common scale if true else exotic More...
 
string Name
 Long name of the scale More...
 
string Short
 Short name of the scale More...
 

Properties

static int RangeCount [get]
 Count of scales availables in the library GammeDefinition.csv in folder Resources/GeneratorTemplate.csv More...
 
int this[int index] [get]
 Delta in 1/2 ton from the tonic, so first position (index=0) always return 0 regardless the range selected. More...
 

Detailed Description

[MPTK PRO] - Load library of scale from GammeDefinition.csv in folder Resources/GeneratorTemplate.csv
For more information see here https://paxstellar.fr/midi-file-player-detailed-view-2-2/

Play notes from a scale

// Need a reference to the prefab MidiStreamPlayer you have added in your scene hierarchy.
public MidiStreamPlayer midiStreamPlayer;
new void Start()
{
// Find the MidiStreamPlayer. Could be also set directly from the inspector.
midiStreamPlayer = FindObjectOfType<MidiStreamPlayer>();
}
private void PlayScale()
{
// get the current scale selected
MPTKRangeLib range = MPTKRangeLib.Range(CurrentScale, true);
for (int ecart = 0; ecart < range.Count; ecart++)
{
NotePlaying = new MPTKEvent()
{
Command = MPTKCommand.NoteOn, // midi command
Value = CurrentNote + range[ecart], // from 0 to 127, 48 for C4, 60 for C5, ...
Channel = StreamChannel, // from 0 to 15, 9 reserved for drum
Duration = DelayPlayScale, // note duration in millisecond, -1 to play indefinitely, MPTK_StopEvent to stop
Velocity = Velocity, // from 0 to 127, sound can vary depending on the velocity
Delay = ecart * DelayPlayScale, // delau in millisecond before playing the note
};
midiStreamPlayer.MPTK_PlayEvent(NotePlaying);
}
}
MPTKCommand
MIDI command codes. Defined the action to be done with the message: note on/off, change instrument,...
Definition: MPTKEvent.cs:15

Member Function Documentation

◆ Range() [1/2]

static MPTKRangeLib MidiPlayerTK.MPTKRangeLib.Range ( int  index,
bool  log = false 
)
static

Get a scale from an index. Scales are read from GammeDefinition.csv in folder Resources/GeneratorTemplate.csv.

Parameters
index
log
Returns

◆ Range() [2/2]

static MPTKRangeLib MidiPlayerTK.MPTKRangeLib.Range ( MPTKRangeName  index,
bool  log = false 
)
static

Get a scale from an index. Scales are read from GammeDefinition.csv in folder Resources/GeneratorTemplate.csv.

Parameters
index
log
Returns

Member Data Documentation

◆ Count

int MidiPlayerTK.MPTKRangeLib.Count

Count of notes in the range

◆ Flag

string MidiPlayerTK.MPTKRangeLib.Flag

Some indicator when available.

  • M = major scale
  • m = minor scale
  • _ = undetermined

◆ Index

int MidiPlayerTK.MPTKRangeLib.Index

Position in the list (from the library)

◆ Main

bool MidiPlayerTK.MPTKRangeLib.Main

Common scale if true else exotic

◆ Name

string MidiPlayerTK.MPTKRangeLib.Name

Long name of the scale

◆ Short

string MidiPlayerTK.MPTKRangeLib.Short

Short name of the scale

Property Documentation

◆ RangeCount

int MidiPlayerTK.MPTKRangeLib.RangeCount
staticget

Count of scales availables in the library GammeDefinition.csv in folder Resources/GeneratorTemplate.csv

◆ this[int index]

int MidiPlayerTK.MPTKRangeLib.this[int index]
get

Delta in 1/2 ton from the tonic, so first position (index=0) always return 0 regardless the range selected.

Parameters
indexPosition in the scale. If greater than count of notes in the scale, the delta in 1/2 tons is taken from the next octave.
Returns
Delta in 1/2 ton from the tonic