Maestro - Midi Player Tool Kit for Unity Version 2.19.0
Loading...
Searching...
No Matches
MidiPlayerTK.MPTKScaleLib

Scale interval library loaded from GammeDefinition.csv. Can be used in any music-generation workflow. More...

Static Public Member Functions

static MPTKScaleLib CreateScale (MPTKScaleName index, bool log=false)
 Gets a scale from an index. Scales are read from GammeDefinition.csv in Resources/GeneratorTemplate.

Public Attributes

int Index
 Zero-based index in the loaded library.
string Name
 Long name of the scale.
string Short
 Short name of the scale.
string Flag
 Family indicator when available.
bool Main
 True for a common scale; otherwise, exotic.
int Count
 Number of notes in the scale.

Properties

int this[int index] [get]
 Indexer for scale intervals in semitones from the tonic. For a Major Melodic scale, each index returns 0, 2, 4, 5, 7, 9, 11. The first position (index = 0) always returns 0.
static int RangeCount [get]
 Number of scales available in GammeDefinition.csv (Resources/GeneratorTemplate).

Detailed Description

Scale interval library loaded from GammeDefinition.csv. Can be used in any music-generation workflow.

Version
Maestro Pro See examples in TestMidiStream.cs and ExtStreamPlayerPro.cs.
// Example target: a MidiStreamPlayer prefab in the scene hierarchy.
public MidiStreamPlayer midiStreamPlayer;
new void Start()
{
// Find MidiStreamPlayer. It can also be assigned directly in the Inspector.
midiStreamPlayer = FindFirstObjectByType<MidiStreamPlayer>();
}
private void PlayScale()
{
// Get the currently selected scale
MPTKScaleLib scale = MPTKScaleLib.CreateScale(CurrentScale, true);
for (int ecart = 0; ecart < scale.Count; ecart++)
{
NotePlaying = new MPTKEvent()
{
Command = MPTKCommand.NoteOn, // MIDI command
Value = CurrentNote + scale[ecart], // 0..127, 48 = C3, 60 = C4
Channel = StreamChannel, // 0..15, channel 9 reserved for drums
Duration = DelayPlayScale, // note duration in milliseconds, -1 to play indefinitely, MPTK_StopEvent to stop
Velocity = Velocity, // 0..127
Delay = ecart * DelayPlayScale, // delay in milliseconds before playing the note
};
midiStreamPlayer.MPTK_PlayEvent(NotePlaying);
}
}
Represents a MIDI event used throughout MPTK. This class is central to script-based MIDI workflows in...
Definition MPTKEvent.cs:59
Scale interval library loaded from GammeDefinition.csv. Can be used in any music-generation workflow.
Definition MPTKScaleLib.cs:46
static MPTKScaleLib CreateScale(MPTKScaleName index, bool log=false)
Gets a scale from an index. Scales are read from GammeDefinition.csv in Resources/GeneratorTemplate.
Definition MPTKScaleLib.cs:128
int Count
Number of notes in the scale.
Definition MPTKScaleLib.cs:78
Builds and plays real-time music in response to user actions or algorithmic logic....
Definition MidiStreamPlayer.cs:44
void MPTK_PlayEvent(MPTKEvent mptkEvent)
Plays one MIDI event from an instance of MPTKEvent. Runs in a thread so the call returns immediately....
Definition MidiStreamPlayer.cs:121
MPTKCommand
MIDI command codes. Defines the action performed by the message: note on/off, patch change,...
Definition MPTKEnum.cs:16

Member Function Documentation

◆ CreateScale()

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

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

Parameters
indexEnum identifier in MPTKScaleName.
logTrue to log debug details while loading/building.
Returns
The matching MPTKScaleLib instance.

Member Data Documentation

◆ Flag

string MidiPlayerTK.MPTKScaleLib.Flag

Family indicator when available.

  • M = major family
  • m = minor family
  • _ = unspecified/other

Property Documentation

◆ this[int index]

int MidiPlayerTK.MPTKScaleLib.this[int index]
get

Indexer for scale intervals in semitones from the tonic. For a Major Melodic scale, each index returns 0, 2, 4, 5, 7, 9, 11. The first position (index = 0) always returns 0.

Parameters
indexIndex in the scale. If greater than Count, intervals continue in the next octave(s).
Returns
Interval in semitones from the tonic.
// Create a scale from the first scale found in the library: "Major melodic"
// Log enabled to display the content of the scale.
mptkScale = MPTKScaleLib.CreateScale(index: MPTKScaleName.MajorMelodic, log: true);
Debug.Log(mptkScale[0]) // display 0
Debug.Log(mptkScale[4]) // display 7
MPTKScaleName
List of available scale presets loaded from GammeDefinition.csv. Each enum value maps to one CSV row ...
Definition MPTKScaleLib.cs:258