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

    Function deform

    • Apply the complexity dials to a figure.

      This is the one place complexity touches vocabulary: genre has already chosen the material, and the ceiling has not been consulted yet.

      Type Parameters

      Parameters

      • events: readonly T[]

        The figure.

      • opts: DeformOptions

        What the dials say.

      • draw: Draw

        The position-addressed sampler.

      • ...path: readonly (string | number)[]

        Where the figure sits.

      Returns T[]

      The deformed figure, sorted by position.

      import { deform, resolveContext } from '@libraz/libcantus';
      const figure = [
      { step: 0, velocity: 1, limb: 'kick' },
      { step: 4, velocity: 0.9, limb: 'snare' },
      { step: 8, velocity: 1, limb: 'kick' },
      { step: 12, velocity: 0.9, limb: 'snare' },
      ];
      const draw = resolveContext(7).part('drums');
      const busier = deform(figure, { rhythmic: 0.9 }, draw, 'bar', 0);
      // Above the neutral middle the figure is syncopated: onsets are added off
      // the beat, and the result comes back sorted by position.
      busier.length; // 7
      busier.map((event) => event.step); // [0, 3, 4, 7, 8, 11, 12]