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

    Type Alias CounterMelodyOptions

    Options controlling generateCounterMelody.

    type CounterMelodyOptions = {
        melody: readonly NoteEvent[];
        timeline?: ChordTimeline;
        chordAt?: (beat: number) => ChordData | null;
        chordChangeBeats?: number[];
        key: KeyLike;
        ts?: MeterLike;
        register?: "above" | "below";
        rhythm?: "complement" | "follow";
        profile?: "strict" | "pop";
        weights?: Partial<ProfileWeights>;
        pitchLow?: number;
        pitchHigh?: number;
        ctx?: GenerationContextInput;
    }
    Index
    melody: readonly NoteEvent[]

    The lead line to write against, in ascending onset order.

    timeline?: ChordTimeline

    The harmony to write against. A timeline carries its own segment boundaries, so a chord change anywhere — including off the generator's half-beat probe grid — is seen; prefer it over chordAt.

    Exactly one of timeline and chordAt is required; timeline wins when both are given.

    chordAt?: (beat: number) => ChordData | null

    Chord sounding at an absolute beat position, or null when none applies.

    A callback is opaque: the generator cannot see where it changes, so it probes a half-beat grid and otherwise relies on chordChangeBeats. A held counter note that spans an unseen change is not checked against the new chord.

    chordChangeBeats?: number[]

    Exact chord-change beats the chordAt callback does not expose. Ignored when timeline is given, since a timeline lists its own boundaries.

    key: KeyLike

    Key/scale context for scale-tone decisions. A key name such as 'C major' is read as that key.

    Meter used for strong-beat decisions, in any form that names one.

    4/4
    
    register?: "above" | "below"

    Which side of the melody the counter line occupies.

    'below'
    
    rhythm?: "complement" | "follow"

    Onset strategy: 'complement' moves where the melody holds or rests and reinforces some strong beats; 'follow' mirrors melody onsets.

    'complement'
    
    profile?: "strict" | "pop"

    Style profile applied to candidate pitches. It sets what is rejected outright and, through PROFILE_WEIGHTS, what is preferred among the candidates that remain: 'strict' seeks contrary motion and avoids similar, 'pop' treats a run of parallel thirds or sixths as the harmony line an arranger would write.

    'pop'
    

    Per-field overrides of the profile's ranking weights, for a preference the two stock profiles do not express — a line that should leap more freely, or one that should hold a pedal wherever it can. Every field named must be a finite number.

    pitchLow?: number

    Lowest MIDI pitch the counter line may use (default derived from register).

    pitchHigh?: number

    Highest MIDI pitch the counter line may use (default derived from register).

    The generation context, so the counter line is drawn from the same project source as every other part and no two parts collide.

    Its seed places the 'complement' onsets and breaks ties between equally good candidate pitches; the same seed always yields the same line. Where the constraints leave only one good answer — which is common with rhythm: 'follow', whose onsets are fixed by the melody — changing the seed changes nothing.

    { seed: 0 }