The piece's notes, in any order. Notes that never sound are dropped.
Optionalopts: ReferenceProfileOptions
The meter, key, harmony, melody, span end and budget; see ReferenceProfileOptions.
The profile.
import { analyzeReference } from '@libraz/libcantus';
const triad = (pitches: number[], startBeat: number) =>
pitches.map((pitch) => ({ pitch, startBeat, durationBeat: 4 }));
const notes = [
...triad([60, 64, 67], 0),
...triad([65, 69, 72], 4),
...triad([67, 71, 74], 8),
...triad([60, 64, 67], 12),
];
const profile = analyzeReference(notes, { key: 'C major' });
profile.harmony.chords.map((chord) => chord.roman); // ['I', 'IV', 'V', 'I']
profile.span.bars; // 4
Read a piece's structure into a ReferenceProfile: its form, phrase shapes, harmonic function and rhythm, motif derivations and melodic rhythm, without the notes themselves.
The melody is the
melodyoption when given, and otherwise the top line of the notes — notes struck together read as one event, the highest standing for it — so a piano part read whole answers for its upper voice. The harmony is thetimelineoption when given, and otherwise inferred from all the notes. The motif search expects quantized onsets.The sections are cut on the hyperbar grouping the phrase reading settles on, which weighs where the harmony cadences;
sectionsFromNotesalone groups without the cadences, so the two can differ.