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

    Function parseNote

    • Parse a note name into a Note, in any supported notation system.

      English (the default when a name could be read in more than one system) accepts a letter (case-insensitive) followed by any number of same-direction accidentals and an optional octave, e.g. "C", "C#4", "Bb", "F##3", "Ebb2". Both # and x (double-sharp) are accepted for sharps; b for flats. Mixing sharps and flats (e.g. "C#b") is rejected.

      Without a system the name is attributed by detectNoteNameSystem, which reads a name any two systems could claim as English: "B" is the B natural, never the German B flat. German is chosen only for a German-only name such as "H", "fis" or "es".

      A scientific octave may follow the name in every system ("gis4", "嬰ト4"), which is what makes formatting and parsing exact inverses for an octave-bearing note.

      Parameters

      • text: string

        The note name.

      • Optionalopts: NoteNameOptions

        system reads the name in that notation system instead of detecting it.

      Returns NoteData

      The parsed note.

      If the text is not a valid note in the given (or detected) system. Use tryParseNote where failure is ordinary, such as a note field read on every keystroke.

      import { parseNote, noteToMidi, noteToPitchClass } from '@libraz/libcantus';
      noteToMidi(parseNote('C#4')); // 61
      noteToPitchClass(parseNote('gis')); // 8 — the German G sharp
      noteToPitchClass(parseNote('B', { system: 'german' })); // 10 — the German B flat