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

    Function generateRhythm

    • Generate a deterministic rhythmic pattern over bars bars of a time signature. A grid is built at the chosen subdivision; each slot becomes an onset when the draw belonging to that slot falls under its metric weight scaled by the density dial. Because the draw belongs to the slot rather than to the order the slots were visited, raising the dial only adds onsets: everything already sounding stays where it was. Every bar's downbeat is always an onset, so a pattern of any length has a reliable pulse independent of the seed. Each event's duration extends to the next onset, and the last event extends to the end of the span.

      Parameters

      Returns RhythmEvent[]

      Onset events sorted by position, non-overlapping, covering the span.

      import { generateRhythm } from '@libraz/libcantus';
      generateRhythm('4/4', { ctx: { seed: 42, complexity: { rhythmic: 0.6 } } });
      // onset events over one bar