Skip to content

IEventBus

#include "crosspad/event/IEventBus.hpp"

Generated from crosspad/event/IEventBus.hpp in crosspad-core. Edit the header’s doxygen comments to change this page.

Platform-agnostic event bus interface for CrossPad.

Recipes that use it: Play a sample, Tempo and transport, Motion and vibration, UI kit

IEventBus & getEventBus()

Platform-injected singleton (implemented by PlatformServices)

Used in Play a sample, Tempo and transport, Motion and vibration, UI kit.

Declared in crosspad/event/IEventBus.hpp:105.

using crosspad::EventHandler = void (*)(const void* event_data, EventType event_type, void* user_ctx)

Event handler callback signature.

Declared in crosspad/event/IEventBus.hpp:48.

using crosspad::SubscriptionHandle = void*

Opaque handle returned by subscribe(), used for unsubscribe()

Used in Tempo and transport, Motion and vibration, UI kit.

Declared in crosspad/event/IEventBus.hpp:53.

Abstract event bus interface.

Thread-safe, asynchronous event dispatch. Platform implementations provide the actual queue and dispatch mechanism (esp_event, std::queue, etc.)

Used in Play a sample, Tempo and transport, Motion and vibration, UI kit.

Members

MemberDescription
initPlatform only Initialize the event bus (create queue, start dispatch task if needed)
subscribeSubscribe to a specific event type. Returns handle for unsubscribe.
unsubscribeUnsubscribe using the handle returned by subscribe()
postNoteOn
postNoteOff
postPadPressed
postPadReleased
postAppChangedThe Sampler posts it, with "Sampler", after it changes the kit.
postTempoChanged
postLiveModeChanged
postGuiUpdateRequired
postSamplePlayback
postMotionGestureBoard motion the sensor itself recognised.
sendNoteOn
sendNoteOff

Methods

Platform only The platform calls it once at start-up (crosspad_platform_init).

virtual bool init() = 0

Initialize the event bus (create queue, start dispatch task if needed)

virtual SubscriptionHandle subscribe(EventType type, EventHandler handler, void *user_ctx=nullptr) = 0

Subscribe to a specific event type. Returns handle for unsubscribe.

Used in Tempo and transport, Motion and vibration, UI kit.

virtual void unsubscribe(SubscriptionHandle handle) = 0

Unsubscribe using the handle returned by subscribe()

Used in Tempo and transport, Motion and vibration, UI kit.

virtual bool postNoteOn(uint8_t channel, uint8_t note, uint8_t velocity, EventSource source) = 0
virtual bool postNoteOff(uint8_t channel, uint8_t note, uint8_t velocity, EventSource source) = 0
virtual bool postPadPressed(uint8_t padIdx, bool isOn, uint8_t velocity, EventSource source=EventSource::PadManager) = 0
virtual bool postPadReleased(uint8_t padIdx, EventSource source=EventSource::PadManager) = 0

The Sampler posts it, with "Sampler", after it changes the kit.

virtual bool postAppChanged(const char *appName, EventSource source=EventSource::System) = 0
virtual bool postTempoChanged(float bpm, EventSource source=EventSource::SequencerCallback) = 0
virtual bool postLiveModeChanged(bool enabled, EventSource source=EventSource::System) = 0
virtual bool postGuiUpdateRequired(EventSource source=EventSource::Gui) = 0
virtual bool postSamplePlayback(uint8_t note, uint8_t wavIdx, bool isOn, EventSource source=EventSource::SamplePlayback, uint8_t velocity=127, int8_t transpose=0, uint8_t key=kSamplePlaybackOwnKey) = 0

Parameters

  • velocity — 1-127 playback velocity; defaults to full scale so callers that have no velocity (preview, kit stop-all) are unaffected. Ignored when isOn = false.
  • transpose, key — see SamplePlaybackData; a plain pad hit leaves them at 0 and the pad’s own key.

Used in Play a sample.

virtual bool postMotionGesture(MotionGesture gesture, uint8_t orientation=0, EventSource source=EventSource::Imu) = 0

Board motion the sensor itself recognised.

Apps subscribe to EventType::MotionGesture instead of talking to any IMU driver.

virtual bool sendNoteOn(uint8_t channel, uint8_t note, uint8_t velocity, EventSource source=EventSource::System) = 0
virtual bool sendNoteOff(uint8_t channel, uint8_t note, EventSource source=EventSource::System) = 0

Declared in crosspad/event/IEventBus.hpp:61.