@libraz/libcantus - v1.1.0
    Preparing search index...

    Function spellPitch

    • Spell a MIDI pitch relative to a key, keeping its octave.

      The octave-less sibling of this function, spellPitchClass, is enough for chord and scale spelling; this one is for naming actual sounding pitches (a generated line, an imported track) without losing the register.

      The octave is the one that reproduces pitch from the chosen spelling, so a context that changes the letter changes the octave with it: MIDI 60 spelled B# is B#3, not B#4.

      Parameters

      • pitch: number

        The MIDI pitch; rounded to the nearest integer.

      • tonic: NoteLike

        The spelled tonic of the key, as a note name, a MIDI number, note data, or a Note.

      • key: KeyLike

        The key/scale, as a key name, a key/scale, or a Key.

      • Optionalcontext: SpellingContext

        Optional surrounding evidence, weighed exactly as spellPitchClass weighs it.

      Returns NoteData

      The spelled note, carrying the octave that reproduces pitch.

      If tonic does not sound the key's root pitch class.

      import { spellPitch, formatNote, parseNote, majorKey } from '@libraz/libcantus';
      formatNote(spellPitch(70, parseNote('Eb'), majorKey(3))); // 'Bb4'