MidiPlayerTK.MPTKRangeLib

Build Scale and Play with MidiStreamPlayer.
More...

Static Public Member Functions

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

Public Attributes

int Count
 
string Flag
 
int Index
 
bool Main
 
string Name
 
string Short
 

Properties

static int RangeCount [get]
 
int this[int index] [get]
 

Detailed Description

Build Scale and Play with MidiStreamPlayer.

Version
Maestro Pro

See example in TestMidiStream.cs and ExtStreamPlayerPro.cs

// 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 C3, 60 for C4, ...
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);
}
}
Description of a MIDI Event. It's the heart of MPTK! Essential to handling MIDI by script from all ot...
Definition: MPTKEvent.cs:418
Build Scale and Play with MidiStreamPlayer.
Definition: MPTKRangeLib.cs:44
static MPTKRangeLib Range(int index, bool log=false)
Definition: MPTKRangeLib.cs:118
int Count
Definition: MPTKRangeLib.cs:76
Build and Play Real Time Music in relation with user actions or algorithms. This class must be used w...
Definition: MidiStreamPlayer.cs:79
void MPTK_PlayEvent(MPTKEvent mptkEvent)
Definition: MidiStreamPlayer.cs:133
MPTKCommand
Definition: MPTKEvent.cs:12

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