get_note_as_midi_code


Description:

public static short get_note_as_midi_code (string note) throws MusicalNoteError

Get the note's MIDI code

Algorithm: A note, such as C#3 is decomposed into:

  • the octave (3)
  • the note name (C#)

Each note name receives an index in the range 0..11 . The index is used as the lowest part of the note number and the octave is used as the most significant part of the number. An offset (12) is added so that A0=21. A constraint is added so that the note is between 21 (A0) and 108 (C8), resulting in valid MIDI codes.

Parameters:

note

The note in musical notation (with octave, e.g.: C#3)

Returns:

The associated MIDI code