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

    Function transformMotif

    • Apply a transformation to a motif cell.

      Every transform hands the cell back in onset order, so the note a later transform reads as the first one is the note that sounds first.

      invert reflects pitches about the earliest note (chromatic, self-inverse); retrograde mirrors onsets about the cell span, preserving rests (self-inverse); augment/diminish scale time by amount ?? 2 and its reciprocal; transposeChromatic adds amount semitones; transposeDiatonic shifts by amount scale degrees when a key is given, or — with no key — falls back to a chromatic shift of amount semitones; sequence appends a shifted copy (by amount diatonic degrees with a key, or by amount semitones without one, since it delegates to transposeDiatonic).

      Parameters

      • cell: MotifCell

        The cell to transform.

      • t:
            | "retrograde"
            | "transposeDiatonic"
            | "transposeChromatic"
            | "invert"
            | "augment"
            | "diminish"
            | "sequence"

        The transformation.

      • Optionalamount: number

        Optional parameter (semitones, degrees, or time factor).

      • Optionalkey: KeyLike

        Key context for the diatonic transforms, as a key name such as 'C major' or as a key/scale; without it, transposeDiatonic and sequence shift chromatically by semitones.

      Returns MotifCell

      The transformed cell, its notes in time order whatever order the source cell was written in, so it can be read as a line.

      If a transformed pitch would fall outside the MIDI range 0..127.

      import { generateMotif, transformMotif, majorKey } from '@libraz/libcantus';
      const cell = generateMotif({ key: majorKey(0), bars: 1 });
      const inverted = transformMotif(cell, 'invert');