Universal Music Theory Library - v0.12.0
    Preparing search index...

    Class Canon

    Canon and imitation detection / generation tools.

    Index

    Constructors

    Methods

    • Detects imitative entries between voices. Returns matches: which voice, at what beat offset, what transposition, whether inverted.

      Parameters

      Returns { inversion: boolean; offset: number; transposition: number; voice: number }[]

      • inversion: boolean

        The imitation moves by inverted intervals.

      • offset: number

        Note index in that voice where the imitation starts.

      • transposition: number

        Steps from the model's first note to the imitation's first note.

      • voice: number

        Index of the imitating voice (the first voice is the model).

    • Generates a two-voice canon from a theme.

      Parameters

      • theme: Note[]

        The theme notes.

      • interval: number

        Transposition interval in steps for the follower voice.

      • delay: number

        Entry delay in number of notes.

      • inversion: boolean = false

        If true, the follower uses the melodic inversion.

      Returns (Note | null)[][]

      [leader, follower], both theme.length + delay long: the follower opens with delay rests (null) and the leader ends with as many, so index i sounds together.