MidiPlayerTK.MPTKScaleLib

Build Scale and Play with MidiStreamPlayer.
More...

Static Public Member Functions

static MPTKScaleLib CreateScale (MPTKScaleName 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 = FindFirstObjectByType<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:45
Build and Play Real Time Music in relation with user actions or algorithms. This class must be used w...
Definition: MidiStreamPlayer.cs:36
void MPTK_PlayEvent(MPTKEvent mptkEvent)
Definition: MidiStreamPlayer.cs:109
MPTKCommand
Definition: MPTKEnum.cs:12

Member Function Documentation

◆ CreateScale()

static MPTKScaleLib MidiPlayerTK.MPTKScaleLib.CreateScale ( MPTKScaleName  index,
bool  log = false 
)
static

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

Parameters
indexScale
log
Returns

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.MPTKScaleLib.Count

Count of notes in the range

◆ Flag

string MidiPlayerTK.MPTKScaleLib.Flag

Some indicator when available.

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

◆ Index

int MidiPlayerTK.MPTKScaleLib.Index

Position in the list (from the library)

◆ Main

bool MidiPlayerTK.MPTKScaleLib.Main

Common scale if true else exotic

◆ Name

string MidiPlayerTK.MPTKScaleLib.Name

Long name of the scale

◆ Short

string MidiPlayerTK.MPTKScaleLib.Short

Short name of the scale

Property Documentation

◆ RangeCount

int MidiPlayerTK.MPTKScaleLib.RangeCount
staticget

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

◆ this[int index]

int MidiPlayerTK.MPTKScaleLib.this[int index]
get

Indexer on an instance if this classe
This provides access to each count of Intervals in semitones from the tonic.
From a Major Melodic, each index will return 0, 2, 4, 5, 7, 9, 11 First position (index=0) always return 0 because it is the ibterval count from the tonic xD.

Parameters
indexIndex in the scale. If greater than interval count in the scale, the interval in semitones is taken from the next octave.
Returns
Intervals in semitones from 0
// Create a scale from the first scale found in the library: "Major melodic"
// Log enabled to display the content of the scale.
mptkScale = MPTKRangeLib.Range(indexScale:0, log:true);
Debug.Log(mptkScale[0]) // display 0
Debug.Log(mptkScale[4]) // display 7