mwg API
    Preparing search index...

    Function assertGrooveTemplate

    • Checks every invariant of a GrooveTemplate at once, so a template read from a file or handed in from outside fails here rather than as a misaligned grid several frames later. The engines call it before applying a template, and the JSON import calls it before returning one.

      Parameters

      Returns void

      import { assertGrooveTemplate, subdivisionCount } from '@datamoc/mwg/audio';

      const template = {
      name: 'four-on-the-floor',
      timeSignature: [4, 4] as [number, number],
      ppq: 480,
      tempoBpm: 120,
      subdivision: '16n' as const,
      offsets: Array.from({ length: subdivisionCount([4, 4], '16n') }, (_, index) => ({
      subdivisionIndex: index,
      timeOffsetTicks: 0,
      velocityFactor: 1,
      })),
      };

      assertGrooveTemplate(template); // throws when a slot is missing or a tick is fractional