Class Metronome

Metronome runs a precise timer that can start, pause, and stop.

It has a tempo and time signature, which control how time is counted.

It keeps track of the current position in these units of measurement:

  • Absolute beat index
  • By measure and beat, based on time signature which can change

It can be given a score of players with events, which will be played in sync with the metronome.

Example

import { Metronome } from 'mooz/metronome'

Hierarchy

Constructors

Properties

audioContext: AudioContext

Audio context

listeners: {} = {}

Type declaration

    loopDuration: number = 0

    Loop duration by absolute beat index

    nextMeasureListeners: Function[] = []

    Listener callbacks for next measure

    position: MetronomePosition = ...

    Metronome position

    resetPositionScheduled: boolean = false

    Reset position is scheduled

    score: Score

    Current score

    tempo: number = 60

    Tempo in beats per minute

    timeSignature: MetronomeTimeSignature = ...

    Time signature

    timer: PreciseTimer

    Precise timer

    Methods

    • Schedule a callback for start of next measure

      Parameters

      • callback: any

      Returns void

    • Start timer loops

      There are two loops to count absolute and metronome beats separately.

      Parameters

      • firstEvent: any

      Returns void