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

    Function rhythmToNoteEvents

    • Turn rhythm events into note events at a fixed pitch.

      RhythmEvent names its fields position/duration because a rhythm has no pitch; every other generator in the library speaks NoteEvent. This is the bridge, so a generated rhythm can be humanized, grooved, or written out like any other line.

      Parameters

      • events: RhythmEvent[]

        The rhythm events to convert.

      • pitch: number

        The MIDI pitch to give every note.

      • velocity: number = DEFAULT_RHYTHM_VELOCITY

        Velocity for every note; defaults to a mezzo-forte 96.

      Returns NoteEvent[]

      The note events, in the order given.

      If the pitch or the velocity is not a whole MIDI value in [0, 127].

      import { generateRhythm, humanize, rhythmToNoteEvents } from '@libraz/libcantus';
      const rhythm = generateRhythm({ numerator: 4, denominator: 4 }, { bars: 2 });
      humanize(rhythmToNoteEvents(rhythm, 38));