Store the processing mode in BufferConfig
Instead of having a function on ProcessContext.
This commit is contained in:
parent
ee3b0bf8e6
commit
783dc2245e
|
@ -13,6 +13,11 @@ code then it will not be listed here.
|
|||
`param.hide()`, while `param.non_automatable()` simply makes it so that the
|
||||
parameter can only be changed manually and not through automation or
|
||||
modulation.
|
||||
- The current processing mode is now stored in `BufferConfig`. Previously this
|
||||
could be fetched through a function on the `ProcessContext`, but this makes
|
||||
more sense as it remains constant until a plugin is deactivated. The
|
||||
`BufferConfig` now contains a field for the minimum buffer size that may or
|
||||
may not be set depending on the plugin API.
|
||||
|
||||
## ...
|
||||
|
||||
|
|
|
@ -24,9 +24,6 @@ pub trait ProcessContext {
|
|||
/// Get information about the current transport position and status.
|
||||
fn transport(&self) -> &Transport;
|
||||
|
||||
/// The current processing mode. The host will reinitialize the plugin any time this changes.
|
||||
fn process_mode(&self) -> ProcessMode;
|
||||
|
||||
/// Returns the next note event, if there is one. Use [`NoteEvent::timing()`] to get the event's
|
||||
/// timing within the buffer. Only available when
|
||||
/// [`Plugin::MIDI_INPUT`][crate::prelude::Plugin::MIDI_INPUT] is set.
|
||||
|
@ -207,22 +204,6 @@ pub enum PluginApi {
|
|||
Vst3,
|
||||
}
|
||||
|
||||
/// The plugin's current processing mode. Can be queried through [`ProcessContext::process_mode()`].
|
||||
/// The host will reinitialize the plugin whenever this changes.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ProcessMode {
|
||||
/// The plugin is processing audio in real time at a fixed rate.
|
||||
Realtime,
|
||||
/// The plugin is processing audio at a real time-like pace, but at irregular intervals. The
|
||||
/// host may do this to process audio ahead of time to loosen realtime constraints and to reduce
|
||||
/// the chance of xruns happening. This is only used by VST3.
|
||||
Buffered,
|
||||
/// The plugin is rendering audio offline, potentially faster than realtime ('freewheeling').
|
||||
/// The host will continuously call the process function back to back until all audio has been
|
||||
/// processed.
|
||||
Offline,
|
||||
}
|
||||
|
||||
impl Display for PluginApi {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
|
|
|
@ -300,6 +300,8 @@ pub struct BufferConfig {
|
|||
/// sized buffers up to this size, or between the minimum and the maximum buffer size if both
|
||||
/// are set.
|
||||
pub max_buffer_size: u32,
|
||||
/// The current processing mode. The host will reinitialize the plugin any time this changes.
|
||||
pub process_mode: ProcessMode,
|
||||
}
|
||||
|
||||
/// Indicates the current situation after the plugin has processed audio.
|
||||
|
@ -317,3 +319,19 @@ pub enum ProcessStatus {
|
|||
/// infite tail.
|
||||
KeepAlive,
|
||||
}
|
||||
|
||||
/// The plugin's current processing mode. Can be queried through [`ProcessContext::process_mode()`].
|
||||
/// The host will reinitialize the plugin whenever this changes.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ProcessMode {
|
||||
/// The plugin is processing audio in real time at a fixed rate.
|
||||
Realtime,
|
||||
/// The plugin is processing audio at a real time-like pace, but at irregular intervals. The
|
||||
/// host may do this to process audio ahead of time to loosen realtime constraints and to reduce
|
||||
/// the chance of xruns happening. This is only used by VST3.
|
||||
Buffered,
|
||||
/// The plugin is rendering audio offline, potentially faster than realtime ('freewheeling').
|
||||
/// The host will continuously call the process function back to back until all audio has been
|
||||
/// processed.
|
||||
Offline,
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ pub use crate::formatters;
|
|||
pub use crate::util;
|
||||
|
||||
pub use crate::buffer::Buffer;
|
||||
pub use crate::context::{GuiContext, ParamSetter, PluginApi, ProcessContext, ProcessMode};
|
||||
pub use crate::context::{GuiContext, ParamSetter, PluginApi, ProcessContext};
|
||||
// This also includes the derive macro
|
||||
pub use crate::midi::{control_change, MidiConfig, NoteEvent};
|
||||
pub use crate::param::enums::{Enum, EnumParam};
|
||||
|
@ -20,7 +20,7 @@ pub use crate::param::range::{FloatRange, IntRange};
|
|||
pub use crate::param::smoothing::{Smoothable, Smoother, SmoothingStyle};
|
||||
pub use crate::param::{BoolParam, FloatParam, IntParam, Param, ParamFlags};
|
||||
pub use crate::plugin::{
|
||||
BufferConfig, BusConfig, ClapPlugin, Editor, ParentWindowHandle, Plugin, ProcessStatus,
|
||||
Vst3Plugin,
|
||||
BufferConfig, BusConfig, ClapPlugin, Editor, ParentWindowHandle, Plugin, ProcessMode,
|
||||
ProcessStatus, Vst3Plugin,
|
||||
};
|
||||
pub use crate::wrapper::state::PluginState;
|
||||
|
|
|
@ -4,7 +4,7 @@ use std::sync::atomic::Ordering;
|
|||
use std::sync::Arc;
|
||||
|
||||
use super::wrapper::{OutputParamEvent, Task, Wrapper};
|
||||
use crate::context::{GuiContext, PluginApi, ProcessContext, ProcessMode, Transport};
|
||||
use crate::context::{GuiContext, PluginApi, ProcessContext, Transport};
|
||||
use crate::event_loop::EventLoop;
|
||||
use crate::midi::NoteEvent;
|
||||
use crate::param::internals::ParamPtr;
|
||||
|
@ -104,10 +104,6 @@ impl<P: ClapPlugin> ProcessContext for WrapperProcessContext<'_, P> {
|
|||
&self.transport
|
||||
}
|
||||
|
||||
fn process_mode(&self) -> ProcessMode {
|
||||
self.wrapper.current_process_mode.load()
|
||||
}
|
||||
|
||||
fn next_event(&mut self) -> Option<NoteEvent> {
|
||||
self.input_events_guard.pop_front()
|
||||
}
|
||||
|
|
|
@ -78,13 +78,13 @@ use super::context::{WrapperGuiContext, WrapperProcessContext};
|
|||
use super::descriptor::PluginDescriptor;
|
||||
use super::util::ClapPtr;
|
||||
use crate::buffer::Buffer;
|
||||
use crate::context::{ProcessMode, Transport};
|
||||
use crate::context::Transport;
|
||||
use crate::event_loop::{EventLoop, MainThreadExecutor, TASK_QUEUE_CAPACITY};
|
||||
use crate::midi::{MidiConfig, NoteEvent};
|
||||
use crate::param::internals::{ParamPtr, Params};
|
||||
use crate::param::ParamFlags;
|
||||
use crate::plugin::{
|
||||
BufferConfig, BusConfig, ClapPlugin, Editor, ParentWindowHandle, ProcessStatus,
|
||||
BufferConfig, BusConfig, ClapPlugin, Editor, ParentWindowHandle, ProcessMode, ProcessStatus,
|
||||
};
|
||||
use crate::util::permit_alloc;
|
||||
use crate::wrapper::state::{self, PluginState};
|
||||
|
@ -1517,6 +1517,7 @@ impl<P: ClapPlugin> Wrapper<P> {
|
|||
sample_rate: sample_rate as f32,
|
||||
min_buffer_size: Some(min_frames_count),
|
||||
max_buffer_size: max_frames_count,
|
||||
process_mode: wrapper.current_process_mode.load(),
|
||||
};
|
||||
|
||||
// Befure initializing the plugin, make sure all smoothers are set the the default values
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::sync::Arc;
|
|||
|
||||
use super::backend::Backend;
|
||||
use super::wrapper::{GuiTask, Wrapper};
|
||||
use crate::context::{GuiContext, PluginApi, ProcessContext, ProcessMode, Transport};
|
||||
use crate::context::{GuiContext, PluginApi, ProcessContext, Transport};
|
||||
use crate::midi::NoteEvent;
|
||||
use crate::param::internals::ParamPtr;
|
||||
use crate::plugin::Plugin;
|
||||
|
@ -81,11 +81,6 @@ impl<P: Plugin, B: Backend> ProcessContext for WrapperProcessContext<'_, P, B> {
|
|||
&self.transport
|
||||
}
|
||||
|
||||
fn process_mode(&self) -> ProcessMode {
|
||||
// TODO: Detect JACK freewheeling and report it here
|
||||
ProcessMode::Realtime
|
||||
}
|
||||
|
||||
fn next_event(&mut self) -> Option<NoteEvent> {
|
||||
nih_debug_assert_failure!("TODO: WrapperProcessContext::next_event()");
|
||||
|
||||
|
|
|
@ -15,7 +15,9 @@ use super::context::{WrapperGuiContext, WrapperProcessContext};
|
|||
use crate::context::Transport;
|
||||
use crate::param::internals::{ParamPtr, Params};
|
||||
use crate::param::ParamFlags;
|
||||
use crate::plugin::{BufferConfig, BusConfig, Editor, ParentWindowHandle, Plugin, ProcessStatus};
|
||||
use crate::plugin::{
|
||||
BufferConfig, BusConfig, Editor, ParentWindowHandle, Plugin, ProcessMode, ProcessStatus,
|
||||
};
|
||||
use crate::util::permit_alloc;
|
||||
use crate::wrapper::state::{self, PluginState};
|
||||
|
||||
|
@ -202,6 +204,8 @@ impl<P: Plugin, B: Backend> Wrapper<P, B> {
|
|||
sample_rate: config.sample_rate,
|
||||
min_buffer_size: None,
|
||||
max_buffer_size: config.period_size,
|
||||
// TODO: Detect JACK freewheeling and report it here
|
||||
process_mode: ProcessMode::Realtime,
|
||||
},
|
||||
config,
|
||||
|
||||
|
|
|
@ -117,10 +117,6 @@ impl<P: Vst3Plugin> ProcessContext for WrapperProcessContext<'_, P> {
|
|||
&self.transport
|
||||
}
|
||||
|
||||
fn process_mode(&self) -> crate::context::ProcessMode {
|
||||
self.inner.current_process_mode.load()
|
||||
}
|
||||
|
||||
fn next_event(&mut self) -> Option<NoteEvent> {
|
||||
self.input_events_guard.pop_front()
|
||||
}
|
||||
|
|
|
@ -16,12 +16,12 @@ use super::param_units::ParamUnits;
|
|||
use super::util::{ObjectPtr, VstPtr, VST3_MIDI_PARAMS_END, VST3_MIDI_PARAMS_START};
|
||||
use super::view::WrapperView;
|
||||
use crate::buffer::Buffer;
|
||||
use crate::context::{ProcessMode, Transport};
|
||||
use crate::context::Transport;
|
||||
use crate::event_loop::{EventLoop, MainThreadExecutor, OsEventLoop};
|
||||
use crate::midi::{MidiConfig, NoteEvent};
|
||||
use crate::param::internals::{ParamPtr, Params};
|
||||
use crate::param::ParamFlags;
|
||||
use crate::plugin::{BufferConfig, BusConfig, Editor, ProcessStatus, Vst3Plugin};
|
||||
use crate::plugin::{BufferConfig, BusConfig, Editor, ProcessMode, ProcessStatus, Vst3Plugin};
|
||||
use crate::wrapper::state::{self, PluginState};
|
||||
use crate::wrapper::util::{hash_param_id, process_wrapper};
|
||||
|
||||
|
|
|
@ -23,10 +23,10 @@ use super::util::{
|
|||
u16strlcpy, VstPtr, VST3_MIDI_CCS, VST3_MIDI_NUM_PARAMS, VST3_MIDI_PARAMS_START,
|
||||
};
|
||||
use super::view::WrapperView;
|
||||
use crate::context::{ProcessMode, Transport};
|
||||
use crate::context::Transport;
|
||||
use crate::midi::{MidiConfig, NoteEvent};
|
||||
use crate::param::ParamFlags;
|
||||
use crate::plugin::{BufferConfig, BusConfig, ProcessStatus, Vst3Plugin};
|
||||
use crate::plugin::{BufferConfig, BusConfig, ProcessMode, ProcessStatus, Vst3Plugin};
|
||||
use crate::util::permit_alloc;
|
||||
use crate::wrapper::state;
|
||||
use crate::wrapper::util::process_wrapper;
|
||||
|
@ -692,6 +692,7 @@ impl<P: Vst3Plugin> IAudioProcessor for Wrapper<P> {
|
|||
sample_rate: setup.sample_rate as f32,
|
||||
min_buffer_size: None,
|
||||
max_buffer_size: setup.max_samples_per_block as u32,
|
||||
process_mode: self.inner.current_process_mode.load(),
|
||||
}));
|
||||
|
||||
let mode = match setup.process_mode {
|
||||
|
|
Loading…
Reference in a new issue