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

    Function melodicSimilarity

    • How alike two lines are, in [0, 1].

      The number compareMelodies reaches, for callers that only want to rank phrases: 1 for the same line — a transposition of it included, since the measure is built on intervals — and lower the further two lines are from being each other's variant. Symmetric in its arguments, and deterministic.

      Parameters

      Returns number

      The likeness in [0, 1].

      import { melodicSimilarity } from '@libraz/libcantus';
      const line = [
      { pitch: 60, startBeat: 0, durationBeat: 1 },
      { pitch: 62, startBeat: 1, durationBeat: 1 },
      { pitch: 64, startBeat: 2, durationBeat: 1 },
      ];
      melodicSimilarity(line, line); // 1