@libraz/libcantus - v0.9.3
    Preparing search index...

    Function humanize

    • Humanize a sequence of note events by nudging their timing and velocity with small, deterministic (seeded) randomness plus a metric-accent shape: events on strong beats (see metricWeight) come out louder on average than events on weak ones.

      Each returned event is a copy; startBeat is jittered within [-timing, +timing] beats and clamped to be non-negative, and velocity is the event's own velocity (or baseVelocity if it has none) plus an accent term scaled by the event's metric weight plus a jitter within [-velocity, +velocity], clamped to [1, 127] and rounded. The metric weight is computed from each event's original (pre-jitter) startBeat. pitch and durationBeat pass through unchanged, and the output keeps the input order.

      Parameters

      Returns NoteEvent[]

      Humanized copies of events, in input order.

      import { humanize } from '@libraz/libcantus';
      const events = [{ pitch: 60, startBeat: 0, durationBeat: 1, velocity: 80 }];
      humanize(events, { seed: 1, timing: 0.03 }); // copies with jittered timing and accented velocity