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

    Function chordTimelineFromNotes

    • Infer a chord timeline from raw multi-track notes.

      The span [0, totalBeats) is sliced into harmonicRhythm-beat windows; each window's chord is inferred from a pitch-class weight histogram of the notes overlapping it (weight = overlap duration x velocity x metric-accent bonus for onsets in the window). Adjacent windows carrying the identical chord are merged into one segment; windows with no notes produce no segment, so at(beat) returns null there. Each segment carries a confidence in [0, 1]: the fraction of the window weight explained by chord tones, reduced when the match is inexact, and duration-weighted across merged windows.

      Notes with a zero or negative duration never sound, so they are dropped at ingest: they contribute to neither the key inference, the span, nor any window's histogram.

      Parameters

      Returns ChordTimelineResult

      The inferred timeline, the key used, and per-segment confidences.

      If harmonicRhythm is not positive.

      import { chordTimelineFromNotes } from '@libraz/libcantus';
      const notes = [
      { pitch: 60, startBeat: 0, durationBeat: 2 }, // C
      { pitch: 64, startBeat: 0, durationBeat: 2 }, // E
      { pitch: 67, startBeat: 0, durationBeat: 2 }, // G
      ];
      const { timeline, key } = chordTimelineFromNotes(notes);
      timeline.at(0); // the chord inferred over beat 0, or null