Function midiToNoteName

  • Given a midi number, returns a note name. The altered notes will have flats unless explicitly set with the optional useSharps parameter.

    Parameters

    • midi: number

      the midi note number

    • options: ToNoteNameOptions = {}

      = default: { sharps: false, pitchClass: false }

    Returns string

    the note name

    Function

    Example

    import { midiToNoteName } from '../midi'
    midiToNoteName(61) // => "Db4"
    midiToNoteName(61, { pitchClass: true }) // => "Db"
    midiToNoteName(61, { sharps: true }) // => "C#4"
    midiToNoteName(61, { pitchClass: true, sharps: true }) // => "C#"
    // it rounds to nearest note
    midiToNoteName(61.7) // => "D4"