-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlib.rs
More file actions
111 lines (89 loc) · 2.97 KB
/
lib.rs
File metadata and controls
111 lines (89 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
use cyma::prelude::*;
use nih_plug::prelude::*;
use std::sync::Arc;
use vizia_plug::ViziaState;
mod editor;
pub struct PeakGraphPlugin {
params: Arc<DemoParams>,
bus: Arc<MonoBus>,
}
#[derive(Params)]
struct DemoParams {
#[persist = "editor-state"]
editor_state: Arc<ViziaState>,
}
impl Default for PeakGraphPlugin {
fn default() -> Self {
Self {
params: Arc::new(DemoParams::default()),
bus: Arc::new(Default::default()),
}
}
}
impl Default for DemoParams {
fn default() -> Self {
Self {
editor_state: editor::default_state(),
}
}
}
impl Plugin for PeakGraphPlugin {
const NAME: &'static str = "CymaPeakGraph";
const VENDOR: &'static str = "223230";
const URL: &'static str = env!("CARGO_PKG_HOMEPAGE");
const EMAIL: &'static str = "223230@pm.me";
const VERSION: &'static str = env!("CARGO_PKG_VERSION");
const AUDIO_IO_LAYOUTS: &'static [AudioIOLayout] = &[AudioIOLayout {
main_input_channels: NonZeroU32::new(2),
main_output_channels: NonZeroU32::new(2),
aux_input_ports: &[],
aux_output_ports: &[],
names: PortNames::const_default(),
}];
const MIDI_INPUT: MidiConfig = MidiConfig::None;
const MIDI_OUTPUT: MidiConfig = MidiConfig::None;
const SAMPLE_ACCURATE_AUTOMATION: bool = true;
type SysExMessage = ();
type BackgroundTask = ();
fn params(&self) -> Arc<dyn Params> {
self.params.clone()
}
fn editor(&mut self, _async_executor: AsyncExecutor<Self>) -> Option<Box<dyn Editor>> {
editor::create(self.params.editor_state.clone(), self.bus.clone())
}
fn initialize(
&mut self,
_audio_io_layout: &AudioIOLayout,
buffer_config: &BufferConfig,
_context: &mut impl InitContext<Self>,
) -> bool {
self.bus.set_sample_rate(buffer_config.sample_rate);
true
}
fn process(
&mut self,
buffer: &mut nih_plug::buffer::Buffer,
_: &mut AuxiliaryBuffers,
_: &mut impl ProcessContext<Self>,
) -> ProcessStatus {
// Push samples into the bus, only if the editor is currently open.
if self.params.editor_state.is_open() {
self.bus.send_buffer_summing(buffer);
}
ProcessStatus::Normal
}
}
impl ClapPlugin for PeakGraphPlugin {
const CLAP_ID: &'static str = "org.cyma.peak_graph";
const CLAP_DESCRIPTION: Option<&'static str> = Some("A peak graph built using Cyma");
const CLAP_MANUAL_URL: Option<&'static str> = Some(Self::URL);
const CLAP_SUPPORT_URL: Option<&'static str> = None;
const CLAP_FEATURES: &'static [ClapFeature] =
&[ClapFeature::AudioEffect, ClapFeature::Analyzer];
}
impl Vst3Plugin for PeakGraphPlugin {
const VST3_CLASS_ID: [u8; 16] = *b"CYMA000PEAKGRAPH";
const VST3_SUBCATEGORIES: &'static [Vst3SubCategory] = &[Vst3SubCategory::Analyzer];
}
nih_export_clap!(PeakGraphPlugin);
nih_export_vst3!(PeakGraphPlugin);