diff --git a/src/wrapper/standalone/context.rs b/src/wrapper/standalone/context.rs index 8e12d4bc..565a6334 100644 --- a/src/wrapper/standalone/context.rs +++ b/src/wrapper/standalone/context.rs @@ -33,9 +33,11 @@ pub(crate) struct WrapperInitContext<'a, P: Plugin, B: Backend> { pub(crate) struct WrapperProcessContext<'a, P: Plugin, B: Backend> { #[allow(dead_code)] pub(super) wrapper: &'a Wrapper, - // TODO: Events - // pub(super) input_events_guard: AtomicRefMut<'a, VecDeque>, - // pub(super) output_events_guard: AtomicRefMut<'a, VecDeque>, + pub(super) input_events: &'a [NoteEvent], + // The current index in `input_events`, since we're not actually popping anything from a queue + // here to keep the standalone backend implementation a bit more flexible + pub(super) input_events_idx: usize, + pub(super) output_events: &'a mut Vec, pub(super) transport: Transport, } @@ -100,16 +102,19 @@ impl ProcessContext for WrapperProcessContext<'_, P, B> { } fn next_event(&mut self) -> Option { - nih_debug_assert_failure!("TODO: WrapperProcessContext::next_event()"); + // We'll pretend we're a queue, choo choo + if self.input_events_idx < self.input_events.len() { + let event = self.input_events[self.input_events_idx]; + self.input_events_idx += 1; - // self.input_events_guard.pop_front() - None + Some(event) + } else { + None + } } - fn send_event(&mut self, _event: NoteEvent) { - nih_debug_assert_failure!("TODO: WrapperProcessContext::send_event()"); - - // self.output_events_guard.push_back(event); + fn send_event(&mut self, event: NoteEvent) { + self.output_events.push(event); } fn set_latency_samples(&self, _samples: u32) { diff --git a/src/wrapper/standalone/wrapper.rs b/src/wrapper/standalone/wrapper.rs index d0fd34c7..95444a7a 100644 --- a/src/wrapper/standalone/wrapper.rs +++ b/src/wrapper/standalone/wrapper.rs @@ -14,6 +14,7 @@ use super::backend::Backend; use super::config::WrapperConfig; use super::context::{WrapperGuiContext, WrapperInitContext, WrapperProcessContext}; use crate::context::Transport; +use crate::midi::NoteEvent; use crate::param::internals::{ParamPtr, Params}; use crate::param::ParamFlags; use crate::plugin::{ @@ -372,8 +373,6 @@ impl Wrapper { return false; } - // TODO: Do something with the input and output events - let sample_rate = self.buffer_config.sample_rate; let mut transport = Transport::new(sample_rate); transport.pos_samples = Some(num_processed_samples); @@ -389,7 +388,7 @@ impl Wrapper { inputs: &mut [], outputs: &mut [], }, - &mut self.make_process_context(transport), + &mut self.make_process_context(transport, input_events, output_events), ) { nih_error!("The plugin returned an error while processing:"); nih_error!("{}", err); @@ -481,9 +480,17 @@ impl Wrapper { WrapperInitContext { wrapper: self } } - fn make_process_context(&self, transport: Transport) -> WrapperProcessContext<'_, P, B> { + fn make_process_context<'a>( + &'a self, + transport: Transport, + input_events: &'a [NoteEvent], + output_events: &'a mut Vec, + ) -> WrapperProcessContext<'a, P, B> { WrapperProcessContext { wrapper: self, + input_events, + input_events_idx: 0, + output_events, transport, } }