Function pitch

  • This function accepts a string representation of a pitch, and returns the MIDI number representation of it.

    An important point to note is that the way shimi uses the term "pitch" isn't technically correct, but does serve to make things less ambiguous in areas where otherwise things could get confusing. In musical terminology, "pitch" is usually measured in hertz as the frequency at which some instrument is producing sound waves, meanwhile a "note" is a musical sound which has some frequency and duration. In MIDI terminology, "pitch" isn't really used, and "note" is a value from 0 - 127 which maps to a frequency (usually within the Western tuning system) that the receiving oscillator should resonate at.

    In order to avoid confusion, and since shimi is very much within the MIDI space and so barely touches upon frequencies, "note" keeps its definition from the musical world (see the Note class). Meanwhile "pitch" refers to the MIDI note number ranging from 0 - 127 that the MIDI specification allows (https://www.inspiredacoustics.com/en/MIDI_note_numbers_and_center_frequencies).

    Returns

    Parameters

    • name: string

      The name parameter accepts 'A', 'B', ..., 'G' to return a value within the lowest octave that MIDI supports (range 0 - 11).

      Accidental symbols ♯, #, ♭, b, ♮, 𝄪 (double sharp), x (also double sharp), 𝄫 (double flat) are also supported, and can be stacked on top of each other, for example: 'C♯', 'Dx#', 'F♭♯'.

      A number can also be added to the end of the string to determine which octave the returned value should be in, for example: 'C5', 'D#7', 'Ab8'

    Returns number

Generated using TypeDoc