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

    Function roleOf

    • Classify a pitch's harmonic role and lock level within a chord.

      The role comes from the pitch's interval class above the chord root: root (0), third (3/4), fifth (6/7/8), seventh (10/11), and 9/11/13 tensions (2/5/9, and the flat ninth 1). The root locks the chord identity, the third locks its quality, and everything else is free voicing. In a suspended chord (a chord whose intervals include a 4th (5) or 2nd (2) but no third), the suspended tone takes the third's place as the quality-defining tone and is locked to quality, since moving it changes the chord. Detecting an octave doubling requires the surrounding voicing, which this single-pitch query does not carry, so doubling is part of the type but not returned here.

      Parameters

      • pitch: number

        MIDI pitch or bare pitch class.

      • chord: ChordData

        The chord providing the root reference.

      • chordId: number = 0

        Identifier stored on the result (defaults to 0).

      Returns VoicedRole

      The pitch's role, lock level, and owning chord id.

      import { roleOf, makeChord } from '@libraz/libcantus';
      roleOf(64, makeChord(0, 'maj')); // E over C major
      // { role: 'third', lock: 'quality', belongsToChordId: 0 }