SynthDevKit::EventEmitter

July 22, 2018 ยท View on GitHub

An Event Emitter.

Methods

EventEmitter( )

Constructor

void EventEmitter::clear(bool all)

Clears all event listeners, if all is set to true, it even clears the EVENT_CLEAR listener.

Parameters

ParameterTypeDescription
allboolwhether to clear all (default: false)

void EventEmitter::on(int16_t event, function)

Sets up a listener for an event.

Parameters

ParameterTypeDescription
eventint16_tevent id (numeric value, from 1 to 2048, or EEType)
functionfunctionfunction accepting int16_t and float arguments

void EventEmitter::removeListener(int16_t event, function)

Removes a listener from an event.

ParameterTypeDescription
eventint16_tevent id (numeric value, from 1 to 2048, or EEType)
functionfunctionfunction accepting int16_t and float arguments

int16_t EventEmitter::listenerCount()

Returns the count of listeners for an event.

ParameterTypeDescription
eventint16_tevent id (numeric value, from 1 to 2048, or EEType)

Returns:

int16_t - number of listeners for the event.

void EventEmitter::emit(int16_t event, float value)

Emits an event to all listeners.

ParameterTypeDescription
eventint16_tevent id (numeric value, from 1 to 2048, or EEType)
valuefloatvalue to emit to the listeners

Event Types

These are predefined events that will emit by default:

  • EVENT_CLEAR - when clear() called
  • EVENT_FIRST - emitted on first event
  • EVENT_EVEN - emitted on all even events
  • EVENT_ODD - emitted on all odd events