@libraz/libcantus - v0.9.3
    Preparing search index...

    Class Note

    An immutable spelled note: a diatonic letter plus a chromatic alteration and an optional octave. Wraps the plain note object and delegates to the pitch module; every transformation returns a new instance.

    import { Note } from '@libraz/libcantus';
    Note.of('C4').transpose(7).name; // 'G4'
    Index
    • get name(): string

      The note rendered as scientific pitch notation, e.g. 'G4' or 'Bb'.

      Returns string

    • get pitchClass(): number

      The pitch class (0..11), ignoring octave.

      Returns number

    • get midi(): number

      The MIDI number (middle C = C4 = 60).

      Returns number

      If the note has no octave and therefore no fixed pitch.

    • get letter(): number

      The diatonic letter number: 0..6 for C..B.

      Returns number

    • get alter(): number

      The chromatic alteration in semitones: -1 flat, 0 natural, +1 sharp, ...

      Returns number

    • get octave(): number | undefined

      The octave (scientific pitch notation), or undefined for a bare pitch class.

      Returns number | undefined

    • Parse scientific pitch notation (e.g. 'C#4', 'Bb', 'F##3').

      Parameters

      • name: string

        The note text.

      Returns Note

      The parsed note.

      If the text is not a valid note.

    • Name a MIDI number (middle C = C4 = 60) as a note.

      Parameters

      • midi: number

        The MIDI number.

      • spelling: "flat" | "sharp" = 'sharp'

        Whether to prefer sharps or flats for black keys.

      Returns Note

      The spelled note, with octave.

    • Transpose by a signed number of semitones.

      When the note carries an octave the transposition happens in MIDI space and the result is spelled with a sharp preference. An octave-less note stays octave-less: only its pitch class is moved. Transposing by zero is the identity: the original spelling is preserved (no enharmonic respelling).

      Parameters

      • semitones: number

        The signed semitone offset.

      Returns Note

      The transposed note.

    • Whether another note has the same letter, alteration, and octave.

      Parameters

      • other: Note

        The note to compare.

      Returns boolean

      True if the spellings are identical.

    • The plain note data, for JSON serialization.

      Private class fields do not serialize, so an explicit toJSON keeps JSON.stringify(note) from collapsing to {}.

      Returns NoteData

      A copy of the underlying plain note object.