diff --git a/src/context.rs b/src/context.rs index f8301d53..682b7378 100644 --- a/src/context.rs +++ b/src/context.rs @@ -24,6 +24,8 @@ mod linux; #[cfg(all(target_family = "unix", not(target_os = "macos")))] pub(crate) use linux::LinuxEventLoop as OsEventLoop; +use crate::plugin::NoteEvent; + pub(crate) const TASK_QUEUE_CAPACITY: usize = 512; // TODO: ProcessContext for parameter automation and sending events @@ -41,6 +43,13 @@ pub trait ProcessContext { /// this may cause audio playback to be restarted. fn set_latency_samples(&self, samples: u32); + /// Return the next note event, if there is one. The event contains the timing + /// + /// TODO: Rethink this API, both in terms of ergonomics, and if we can do this in a way that + /// doesn't require locks (because of the thread safe-ness, which we don't really need + /// here) + fn next_midi_event(&self) -> Option; + // // TODO: Add this next // fn set_parameter

(&self, param: &P, value: P::Plain) // where diff --git a/src/wrapper/vst3.rs b/src/wrapper/vst3.rs index b387d3ab..4322d353 100644 --- a/src/wrapper/vst3.rs +++ b/src/wrapper/vst3.rs @@ -331,6 +331,10 @@ impl ProcessContext for WrapperInner<'_, P> { nih_debug_assert!(task_posted, "The task queue is full, dropping task..."); } } + + fn next_midi_event(&self) -> Option { + self.input_events.write().pop_front() + } } impl IPluginBase for Wrapper<'_, P> {