midiNoteNumber property
int
get
midiNoteNumber
Implementation
int get midiNoteNumber {
int baseNoteNumber = 12 + octave * 12;
if (isFlat) {
switch (noteIndex) {
case 1: // Db/C#
return baseNoteNumber + 1;
case 2: // Eb/D#
return baseNoteNumber + 3;
case 4: // Gb/F#
return baseNoteNumber + 6;
case 5: // Ab/G#
return baseNoteNumber + 8;
case 6: // Bb/A#
return baseNoteNumber + 10;
}
} else {
switch (noteIndex) {
case 0: // C
return baseNoteNumber;
case 1: // D
return baseNoteNumber + 2;
case 2: // E
return baseNoteNumber + 4;
case 3: // F
return baseNoteNumber + 5;
case 4: // G
return baseNoteNumber + 7;
case 5: // A
return baseNoteNumber + 9;
case 6: // B
return baseNoteNumber + 11;
}
}
throw Exception("Invalid noteIndex or flat parameter!");
}