1
0
Fork 0

Add a function for retrieving the next note event

This commit is contained in:
Robbert van der Helm 2022-02-04 01:56:45 +01:00
parent 0e67c61be0
commit fdfd1b01c2
2 changed files with 13 additions and 0 deletions

View file

@ -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<NoteEvent>;
// // TODO: Add this next
// fn set_parameter<P>(&self, param: &P, value: P::Plain)
// where

View file

@ -331,6 +331,10 @@ impl<P: Plugin> ProcessContext for WrapperInner<'_, P> {
nih_debug_assert!(task_posted, "The task queue is full, dropping task...");
}
}
fn next_midi_event(&self) -> Option<NoteEvent> {
self.input_events.write().pop_front()
}
}
impl<P: Plugin> IPluginBase for Wrapper<'_, P> {