Universal Music Theory Library - v0.12.0
    Preparing search index...

    Class MelodyAnalysis

    Melodic analysis tools.

    Index

    Constructors

    Methods

    • Finds recurring interval patterns (motifs) in a melody, up to 9 notes long. Occurrences are counted without overlap (in C D C D C, C-D-C occurs once). A pattern that only recurs inside a longer motif, as often as it, is left out. Sorted by number of occurrences, then by length (longest first).

      Parameters

      • notes: Note[]

        Melody notes.

      • minLength: number = 3

        Minimum motif length in notes (default 3).

      Returns Motif[]

    • Returns the contour of a melody as a sequence of direction symbols. '+' = ascending, '-' = descending, '=' = repeated pitch.

      Parameters

      Returns ("+" | "=" | "-")[]

    • Returns the contour reduction of a melody: only local peaks and troughs. The first and last notes are always included.

      Parameters

      Returns Note[]

    • Returns a histogram of interval classes between consecutive notes. Keys are interval sizes in steps (signed); values are occurrence counts.

      Parameters

      Returns Map<number, number>

    • Reduces a melody using durational weight - keeps structurally important notes. Uses a simple approach: notes with longer durations are more likely to be kept.

      Parameters

      • notes: Note[]

        Melody notes.

      • durations: number[]

        Duration of each note (arbitrary units). Must match notes length.

      Returns Note[]

      Reduced note array (roughly half the original length).