Skip to content

API Reference


API Reference / AnalyzerEventMap

Type Alias: AnalyzerEventMap ​

ts
type AnalyzerEventMap = {
  statechange: StateChange;
  reading: Reading;
  progress: Progress;
  error: AnalyzerError;
  debug: DebugInfo;
  kick: Kick;
};

Defined in: contract/types.ts:403

The analyzer's events. May grow in a minor release: a new event type is additive, as nobody listens to it yet.

Remarks ​

Dispatch order, for each analysis step: state is updated, then statechange fires if the status, the listening reason or the epoch changed, then reading (settling, locked) or progress (listening). Never both a reading and a progress for one step. A reset() or stop() called from a listener is queued: it runs once every listener has had every event of the current step, so all listeners see the same sequence.

  • statechange: on every transition, and only then.
  • reading: on each analysis step outside listening that measured something new. A measurement, not a state. The rate is the engine's: peaks measures every 4096-sample buffer, about 11 times a second at 44.1 or 48 kHz, and tempogram on each tempogram update, about twice a second.
  • progress: on each analysis step while listening, and once right after reset(), with 0.
  • error: non-fatal faults. A fatal one is a statechange to stopped with reason failed instead.
  • debug: engine detail, only with debug: true.
  • kick: on each kick drum heard, in listening, settling and locked alike, as soon as it is heard. Apart from the steps: it moves no state, and comes between their events, never inside one step's sequence.

Reserved for a later 6.x: a beat event, on the AudioContext clock (AudioSpan.contextTime). It belongs to the epoch and the stretch of audio it was predicted in: reset() and every move to listening cancel every predicted beat not yet dispatched, so no beat of an older epoch or a lost pulse is ever reported.

Properties ​

PropertyModifierTypeDefined in
statechangereadonlyStateChangecontract/types.ts:404
readingreadonlyReadingcontract/types.ts:405
progressreadonlyProgresscontract/types.ts:406
errorreadonlyAnalyzerErrorcontract/types.ts:407
debugreadonlyDebugInfocontract/types.ts:408
kickreadonlyKickcontract/types.ts:409