Fully implement MIDI support in standalone wrapper
This commit is contained in:
parent
54f4b8a026
commit
0b6be4de1c
|
@ -33,9 +33,11 @@ pub(crate) struct WrapperInitContext<'a, P: Plugin, B: Backend> {
|
||||||
pub(crate) struct WrapperProcessContext<'a, P: Plugin, B: Backend> {
|
pub(crate) struct WrapperProcessContext<'a, P: Plugin, B: Backend> {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub(super) wrapper: &'a Wrapper<P, B>,
|
pub(super) wrapper: &'a Wrapper<P, B>,
|
||||||
// TODO: Events
|
pub(super) input_events: &'a [NoteEvent],
|
||||||
// pub(super) input_events_guard: AtomicRefMut<'a, VecDeque<NoteEvent>>,
|
// The current index in `input_events`, since we're not actually popping anything from a queue
|
||||||
// pub(super) output_events_guard: AtomicRefMut<'a, VecDeque<NoteEvent>>,
|
// here to keep the standalone backend implementation a bit more flexible
|
||||||
|
pub(super) input_events_idx: usize,
|
||||||
|
pub(super) output_events: &'a mut Vec<NoteEvent>,
|
||||||
pub(super) transport: Transport,
|
pub(super) transport: Transport,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,16 +102,19 @@ impl<P: Plugin, B: Backend> ProcessContext for WrapperProcessContext<'_, P, B> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn next_event(&mut self) -> Option<NoteEvent> {
|
fn next_event(&mut self) -> Option<NoteEvent> {
|
||||||
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()
|
Some(event)
|
||||||
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn send_event(&mut self, _event: NoteEvent) {
|
fn send_event(&mut self, event: NoteEvent) {
|
||||||
nih_debug_assert_failure!("TODO: WrapperProcessContext::send_event()");
|
self.output_events.push(event);
|
||||||
|
|
||||||
// self.output_events_guard.push_back(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_latency_samples(&self, _samples: u32) {
|
fn set_latency_samples(&self, _samples: u32) {
|
||||||
|
|
|
@ -14,6 +14,7 @@ use super::backend::Backend;
|
||||||
use super::config::WrapperConfig;
|
use super::config::WrapperConfig;
|
||||||
use super::context::{WrapperGuiContext, WrapperInitContext, WrapperProcessContext};
|
use super::context::{WrapperGuiContext, WrapperInitContext, WrapperProcessContext};
|
||||||
use crate::context::Transport;
|
use crate::context::Transport;
|
||||||
|
use crate::midi::NoteEvent;
|
||||||
use crate::param::internals::{ParamPtr, Params};
|
use crate::param::internals::{ParamPtr, Params};
|
||||||
use crate::param::ParamFlags;
|
use crate::param::ParamFlags;
|
||||||
use crate::plugin::{
|
use crate::plugin::{
|
||||||
|
@ -372,8 +373,6 @@ impl<P: Plugin, B: Backend> Wrapper<P, B> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Do something with the input and output events
|
|
||||||
|
|
||||||
let sample_rate = self.buffer_config.sample_rate;
|
let sample_rate = self.buffer_config.sample_rate;
|
||||||
let mut transport = Transport::new(sample_rate);
|
let mut transport = Transport::new(sample_rate);
|
||||||
transport.pos_samples = Some(num_processed_samples);
|
transport.pos_samples = Some(num_processed_samples);
|
||||||
|
@ -389,7 +388,7 @@ impl<P: Plugin, B: Backend> Wrapper<P, B> {
|
||||||
inputs: &mut [],
|
inputs: &mut [],
|
||||||
outputs: &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!("The plugin returned an error while processing:");
|
||||||
nih_error!("{}", err);
|
nih_error!("{}", err);
|
||||||
|
@ -481,9 +480,17 @@ impl<P: Plugin, B: Backend> Wrapper<P, B> {
|
||||||
WrapperInitContext { wrapper: self }
|
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<NoteEvent>,
|
||||||
|
) -> WrapperProcessContext<'a, P, B> {
|
||||||
WrapperProcessContext {
|
WrapperProcessContext {
|
||||||
wrapper: self,
|
wrapper: self,
|
||||||
|
input_events,
|
||||||
|
input_events_idx: 0,
|
||||||
|
output_events,
|
||||||
transport,
|
transport,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue