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

    Type Alias KeyContext

    KeyContext: KeyLike | ((beat: number) => KeyScale)

    A key that applies to the whole voice, or the key in force at a given beat.

    The callback form is what a piece that modulates needs: it is asked for the key at a specific beat, the same way a chord is asked for with chordAtBeat.

    import { majorKey } from '@libraz/libcantus';
    const wholePiece = majorKey(0); // C major throughout
    const modulating = (beat: number) => (beat < 8 ? majorKey(5) : majorKey(0));