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

    Function assertReferenceProfile

    • Reject a value that is not a ReferenceProfile.

      A profile is the shape a caller's stored JSON, a config file, or a plugin host most plausibly hands back malformed: a missing field, a distribution that no longer sums to 1, an index a later edit left dangling, a numeral no reader can parse. Every field is checked before compareReferences or a caller's own code reads it, and a violation names the path to the field that is wrong.

      Parameters

      • value: unknown

        The value to check.

      • name: string = 'reference profile'

        What the value is, for the error message.

      Returns ReferenceProfile

      The same profile.

      If the value is not a valid reference profile.

      import { assertReferenceProfile } from '@libraz/libcantus';
      const emptyRhythm = {
      startBeat: 0, endBeat: 0, bars: 0, onsets: 0, onsetDensity: 0,
      barOnsets: [], onsetLevels: [0, 0, 0, 0, 0, 0], barPositions: [],
      interOnsetShares: new Array(17).fill(0), restRatio: 0, syncopation: 0,
      offGridRatio: 0, rationale: 'nothing sounds',
      };
      const profile = {
      profileVersion: 1,
      span: { startBeat: 0, endBeat: 0, bars: 0 },
      meters: [{ startBeat: 0, ts: { numerator: 4, denominator: 4 } }],
      form: { hypermeter: { groupBars: 1, confidence: 0 }, sections: [], phrases: [] },
      harmony: { keys: [], chords: [], rhythm: emptyRhythm },
      melody: { register: null, shape: null, motifs: [], graph: { nodes: [], edges: [] }, rhythm: emptyRhythm },
      };
      assertReferenceProfile(profile); // the profile, unchanged