Skip to content

Commit 5f9fb4c

Browse files
committed
rename Processor to Engine
1 parent b09d51b commit 5f9fb4c

File tree

9 files changed

+75
-77
lines changed

9 files changed

+75
-77
lines changed

examples/gain/src/lib.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ use serde::{Deserialize, Serialize};
44

55
use coupler::format::clap::*;
66
use coupler::format::vst3::*;
7-
use coupler::{
8-
buffers::*, bus::*, editor::*, events::*, host::*, params::*, plugin::*, process::*,
9-
};
7+
use coupler::{buffers::*, bus::*, editor::*, engine::*, events::*, host::*, params::*, plugin::*};
108

119
use coupler_reflector::EditorWindow;
1210

@@ -27,7 +25,7 @@ pub struct Gain {
2725
}
2826

2927
impl Plugin for Gain {
30-
type Processor = GainProcessor;
28+
type Engine = GainEngine;
3129
type Editor = EditorWindow;
3230

3331
fn info() -> PluginInfo {
@@ -80,8 +78,8 @@ impl Plugin for Gain {
8078
Ok(())
8179
}
8280

83-
fn processor(&mut self, _config: Config) -> Self::Processor {
84-
GainProcessor {
81+
fn engine(&mut self, _config: Config) -> Self::Engine {
82+
GainEngine {
8583
params: self.params.clone(),
8684
}
8785
}
@@ -112,19 +110,19 @@ impl ClapPlugin for Gain {
112110
}
113111
}
114112

115-
pub struct GainProcessor {
113+
pub struct GainEngine {
116114
params: GainParams,
117115
}
118116

119-
impl GainProcessor {
117+
impl GainEngine {
120118
fn handle_event(&mut self, event: &Event) {
121119
if let Data::ParamChange { id, value } = event.data {
122120
self.params.set_param(id, value);
123121
}
124122
}
125123
}
126124

127-
impl Processor for GainProcessor {
125+
impl Engine for GainEngine {
128126
fn reset(&mut self) {}
129127

130128
fn flush(&mut self, events: Events) {

src/process.rs src/engine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub struct Config {
99
pub max_buffer_size: usize,
1010
}
1111

12-
pub trait Processor: Send + Sized + 'static {
12+
pub trait Engine: Send + Sized + 'static {
1313
fn reset(&mut self);
1414
fn flush(&mut self, events: Events);
1515
fn process(&mut self, buffers: Buffers, events: Events);

src/format/clap/instance.rs

+27-27
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ use super::host::ClapHost;
1313
use crate::buffers::{BufferData, BufferType, Buffers};
1414
use crate::bus::{BusDir, Format};
1515
use crate::editor::Editor;
16+
use crate::engine::{Config, Engine};
1617
use crate::events::{Data, Event, Events};
1718
use crate::host::Host;
1819
use crate::params::{ParamId, ParamInfo, ParamValue};
1920
use crate::plugin::{Plugin, PluginInfo};
20-
use crate::process::{Config, Processor};
2121
use crate::sync::param_gestures::{GestureStates, GestureUpdate, ParamGestures};
2222
use crate::sync::params::ParamValues;
2323
use crate::util::{copy_cstring, slice_from_raw_parts_checked, DisplayParam};
@@ -57,7 +57,7 @@ pub struct ProcessState<P: Plugin> {
5757
buffer_data: Vec<BufferData>,
5858
buffer_ptrs: Vec<*mut f32>,
5959
events: Vec<Event>,
60-
processor: Option<P::Processor>,
60+
engine: Option<P::Engine>,
6161
}
6262

6363
#[repr(C)]
@@ -69,10 +69,10 @@ pub struct Instance<P: Plugin> {
6969
pub input_bus_map: Vec<usize>,
7070
pub output_bus_map: Vec<usize>,
7171
pub param_map: Arc<HashMap<ParamId, usize>>,
72-
// Processor -> plugin parameter changes
72+
// Engine -> plugin parameter changes
7373
pub plugin_params: ParamValues,
74-
// Plugin -> processor parameter changes
75-
pub processor_params: ParamValues,
74+
// Plugin -> engine parameter changes
75+
pub engine_params: ParamValues,
7676
pub param_gestures: Arc<ParamGestures>,
7777
pub main_thread_state: UnsafeCell<MainThreadState<P>>,
7878
pub process_state: UnsafeCell<ProcessState<P>>,
@@ -125,7 +125,7 @@ impl<P: Plugin> Instance<P> {
125125
output_bus_map,
126126
param_map: Arc::new(param_map),
127127
plugin_params: ParamValues::with_count(info.params.len()),
128-
processor_params: ParamValues::with_count(info.params.len()),
128+
engine_params: ParamValues::with_count(info.params.len()),
129129
param_gestures: Arc::new(ParamGestures::with_count(info.params.len())),
130130
main_thread_state: UnsafeCell::new(MainThreadState {
131131
host_params: None,
@@ -138,7 +138,7 @@ impl<P: Plugin> Instance<P> {
138138
buffer_data: Vec::new(),
139139
buffer_ptrs: Vec::new(),
140140
events: Vec::with_capacity(4096),
141-
processor: None,
141+
engine: None,
142142
}),
143143
}
144144
}
@@ -154,8 +154,8 @@ impl<P: Plugin> Instance<P> {
154154
}
155155
}
156156

157-
fn sync_processor(&self, events: &mut Vec<Event>) {
158-
for (index, value) in self.processor_params.poll() {
157+
fn sync_engine(&self, events: &mut Vec<Event>) {
158+
for (index, value) in self.engine_params.poll() {
159159
events.push(Event {
160160
time: 0,
161161
data: Data::ParamChange {
@@ -357,11 +357,11 @@ impl<P: Plugin> Instance<P> {
357357
max_buffer_size: max_frames_count as usize,
358358
};
359359

360-
// Discard any pending plugin -> processor parameter changes, since they will already be
361-
// reflected in the initial state of the processor.
362-
for _ in instance.processor_params.poll() {}
360+
// Discard any pending plugin -> engine parameter changes, since they will already be
361+
// reflected in the initial state of the engine.
362+
for _ in instance.engine_params.poll() {}
363363

364-
process_state.processor = Some(main_thread_state.plugin.processor(config));
364+
process_state.engine = Some(main_thread_state.plugin.engine(config));
365365

366366
true
367367
}
@@ -371,11 +371,11 @@ impl<P: Plugin> Instance<P> {
371371
let main_thread_state = &mut *instance.main_thread_state.get();
372372
let process_state = &mut *instance.process_state.get();
373373

374-
// Apply any remaining processor -> plugin parameter changes. There won't be any more until
374+
// Apply any remaining engine -> plugin parameter changes. There won't be any more until
375375
// the next call to `activate`.
376376
instance.sync_plugin(main_thread_state);
377377

378-
process_state.processor = None;
378+
process_state.engine = None;
379379
}
380380

381381
unsafe extern "C" fn start_processing(_plugin: *const clap_plugin) -> bool {
@@ -388,16 +388,16 @@ impl<P: Plugin> Instance<P> {
388388
let instance = &*(plugin as *const Self);
389389
let process_state = &mut *instance.process_state.get();
390390

391-
if let Some(processor) = &mut process_state.processor {
392-
// Flush plugin -> processor parameter changes
391+
if let Some(engine) = &mut process_state.engine {
392+
// Flush plugin -> engine parameter changes
393393
process_state.events.clear();
394-
instance.sync_processor(&mut process_state.events);
394+
instance.sync_engine(&mut process_state.events);
395395

396396
if !process_state.events.is_empty() {
397-
processor.flush(Events::new(&process_state.events));
397+
engine.flush(Events::new(&process_state.events));
398398
}
399399

400-
processor.reset();
400+
engine.reset();
401401
}
402402
}
403403

@@ -408,7 +408,7 @@ impl<P: Plugin> Instance<P> {
408408
let instance = &*(plugin as *const Self);
409409
let process_state = &mut *instance.process_state.get();
410410

411-
let Some(processor) = &mut process_state.processor else {
411+
let Some(engine) = &mut process_state.engine else {
412412
return CLAP_PROCESS_ERROR;
413413
};
414414

@@ -471,7 +471,7 @@ impl<P: Plugin> Instance<P> {
471471
}
472472

473473
process_state.events.clear();
474-
instance.sync_processor(&mut process_state.events);
474+
instance.sync_engine(&mut process_state.events);
475475
instance.process_param_events(process.in_events, &mut process_state.events);
476476

477477
let last_sample = process.frames_count.saturating_sub(1);
@@ -482,7 +482,7 @@ impl<P: Plugin> Instance<P> {
482482
last_sample,
483483
);
484484

485-
processor.process(
485+
engine.process(
486486
Buffers::from_raw_parts(
487487
&process_state.buffer_data,
488488
&process_state.buffer_ptrs,
@@ -800,9 +800,9 @@ impl<P: Plugin> Instance<P> {
800800
let process_state = &mut *instance.process_state.get();
801801

802802
// If we are in the active state, flush will be called on the audio thread.
803-
if let Some(processor) = &mut process_state.processor {
803+
if let Some(engine) = &mut process_state.engine {
804804
process_state.events.clear();
805-
instance.sync_processor(&mut process_state.events);
805+
instance.sync_engine(&mut process_state.events);
806806
instance.process_param_events(in_, &mut process_state.events);
807807
instance.process_gestures(
808808
&mut process_state.gesture_states,
@@ -811,7 +811,7 @@ impl<P: Plugin> Instance<P> {
811811
0,
812812
);
813813

814-
processor.flush(Events::new(&process_state.events));
814+
engine.flush(Events::new(&process_state.events));
815815
}
816816
// Otherwise, flush will be called on the main thread.
817817
else {
@@ -933,7 +933,7 @@ impl<P: Plugin> Instance<P> {
933933
if main_thread_state.plugin.load(&mut StreamReader(stream)).is_ok() {
934934
for (index, param) in instance.info.params.iter().enumerate() {
935935
let value = main_thread_state.plugin.get_param(param.id);
936-
instance.processor_params.set(index, value);
936+
instance.engine_params.set(index, value);
937937

938938
if let Some(editor) = &mut main_thread_state.editor {
939939
editor.param_changed(param.id, value);

src/format/clap/tests.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ use crate::events::Events;
88
use clap_sys::plugin_factory::{clap_plugin_factory, CLAP_PLUGIN_FACTORY_ID};
99
use clap_sys::version::CLAP_VERSION;
1010

11+
use crate::engine::{Config, Engine};
1112
use crate::host::Host;
1213
use crate::params::{ParamId, ParamValue};
1314
use crate::plugin::{Plugin, PluginInfo};
14-
use crate::process::{Config, Processor};
1515

1616
use super::{ClapInfo, ClapPlugin, Factory};
1717

@@ -25,7 +25,7 @@ const ID: &str = "com.example.plugin";
2525
struct TestPlugin;
2626

2727
impl Plugin for TestPlugin {
28-
type Processor = TestProcessor;
28+
type Engine = TestEngine;
2929
type Editor = TestEditor;
3030

3131
fn info() -> PluginInfo {
@@ -54,8 +54,8 @@ impl Plugin for TestPlugin {
5454
fn load(&mut self, _input: &mut impl Read) -> io::Result<()> {
5555
Ok(())
5656
}
57-
fn processor(&mut self, _config: Config) -> Self::Processor {
58-
TestProcessor
57+
fn engine(&mut self, _config: Config) -> Self::Engine {
58+
TestEngine
5959
}
6060
fn editor(&mut self, _host: EditorHost, _parent: &ParentWindow) -> Self::Editor {
6161
TestEditor
@@ -73,9 +73,9 @@ impl ClapPlugin for TestPlugin {
7373
}
7474
}
7575

76-
struct TestProcessor;
76+
struct TestEngine;
7777

78-
impl Processor for TestProcessor {
78+
impl Engine for TestEngine {
7979
fn reset(&mut self) {}
8080
fn flush(&mut self, _events: Events) {}
8181
fn process(&mut self, _buffers: Buffers, _events: Events) {}

src/format/vst3/buffers.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use vst3::Steinberg::Vst::ProcessData;
66

77
use crate::buffers::{BufferData, BufferType, Buffers};
88
use crate::bus::{BusDir, BusInfo};
9-
use crate::process::Config;
9+
use crate::engine::Config;
1010
use crate::util::slice_from_raw_parts_checked;
1111

1212
pub struct ScratchBuffers {
@@ -87,7 +87,7 @@ impl ScratchBuffers {
8787
self.moves.reserve(in_out_channels);
8888
}
8989

90-
/// Set up buffer pointers for the processor given a VST3 `ProcessData` struct.
90+
/// Set up buffer pointers for the engine given a VST3 `ProcessData` struct.
9191
///
9292
/// This method is responsible for detecting if any of the buffers for an input bus are aliased
9393
/// by a output buffer and, if so, copying those inputs to scratch buffers. It is also
@@ -98,7 +98,7 @@ impl ScratchBuffers {
9898
/// the buffer's length exceeds the maximum buffer size. It will return `Ok(None)` if the
9999
/// buffer's length is 0, as hosts are not guaranteed to provide the correct number of inputs
100100
/// and outputs in that case, and we don't need to construct a `Buffers` object as we will be
101-
/// calling `Processor::flush` instead of `Processor::process`.
101+
/// calling `Engine::flush` instead of `Engine::process`.
102102
pub unsafe fn get_buffers(
103103
&mut self,
104104
buses: &[BusInfo],

0 commit comments

Comments
 (0)