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
Functions
Section titled “Functions”getEventBus
Section titled “getEventBus”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.
EventHandler
Section titled “EventHandler”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.
SubscriptionHandle
Section titled “SubscriptionHandle”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.
crosspad::IEventBus
Section titled “crosspad::IEventBus”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
| Member | Description |
|---|---|
init | Platform only Initialize the event bus (create queue, start dispatch task if needed) |
subscribe | Subscribe to a specific event type. Returns handle for unsubscribe. |
unsubscribe | Unsubscribe using the handle returned by subscribe() |
postNoteOn | |
postNoteOff | |
postPadPressed | |
postPadReleased | |
postAppChanged | The Sampler posts it, with "Sampler", after it changes the kit. |
postTempoChanged | |
postLiveModeChanged | |
postGuiUpdateRequired | |
postSamplePlayback | |
postMotionGesture | Board motion the sensor itself recognised. |
sendNoteOn | |
sendNoteOff |
Methods
Platform only The platform calls it once at start-up (crosspad_platform_init).
virtual bool init() = 0Initialize the event bus (create queue, start dispatch task if needed)
subscribe
Section titled “subscribe”virtual SubscriptionHandle subscribe(EventType type, EventHandler handler, void *user_ctx=nullptr) = 0Subscribe to a specific event type. Returns handle for unsubscribe.
Used in Tempo and transport, Motion and vibration, UI kit.
unsubscribe
Section titled “unsubscribe”virtual void unsubscribe(SubscriptionHandle handle) = 0Unsubscribe using the handle returned by subscribe()
Used in Tempo and transport, Motion and vibration, UI kit.
postNoteOn
Section titled “postNoteOn”virtual bool postNoteOn(uint8_t channel, uint8_t note, uint8_t velocity, EventSource source) = 0postNoteOff
Section titled “postNoteOff”virtual bool postNoteOff(uint8_t channel, uint8_t note, uint8_t velocity, EventSource source) = 0postPadPressed
Section titled “postPadPressed”virtual bool postPadPressed(uint8_t padIdx, bool isOn, uint8_t velocity, EventSource source=EventSource::PadManager) = 0postPadReleased
Section titled “postPadReleased”virtual bool postPadReleased(uint8_t padIdx, EventSource source=EventSource::PadManager) = 0postAppChanged
Section titled “postAppChanged”The Sampler posts it, with "Sampler", after it changes the kit.
virtual bool postAppChanged(const char *appName, EventSource source=EventSource::System) = 0postTempoChanged
Section titled “postTempoChanged”virtual bool postTempoChanged(float bpm, EventSource source=EventSource::SequencerCallback) = 0postLiveModeChanged
Section titled “postLiveModeChanged”virtual bool postLiveModeChanged(bool enabled, EventSource source=EventSource::System) = 0postGuiUpdateRequired
Section titled “postGuiUpdateRequired”virtual bool postGuiUpdateRequired(EventSource source=EventSource::Gui) = 0postSamplePlayback
Section titled “postSamplePlayback”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) = 0Parameters
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.
postMotionGesture
Section titled “postMotionGesture”virtual bool postMotionGesture(MotionGesture gesture, uint8_t orientation=0, EventSource source=EventSource::Imu) = 0Board motion the sensor itself recognised.
Apps subscribe to EventType::MotionGesture instead of talking to any IMU driver.
sendNoteOn
Section titled “sendNoteOn”virtual bool sendNoteOn(uint8_t channel, uint8_t note, uint8_t velocity, EventSource source=EventSource::System) = 0sendNoteOff
Section titled “sendNoteOff”virtual bool sendNoteOff(uint8_t channel, uint8_t note, EventSource source=EventSource::System) = 0Declared in crosspad/event/IEventBus.hpp:61.