1
0
Fork 0

Add a stub for poly_mod_synth

This will serve as an example implementation for polyphonic modulation.
This commit is contained in:
Robbert van der Helm 2022-07-06 13:55:53 +02:00
parent ec77d3b450
commit 89b2d0a66c
5 changed files with 103 additions and 1 deletions

7
Cargo.lock generated
View file

@ -2934,6 +2934,13 @@ dependencies = [
"winapi",
]
[[package]]
name = "poly_mod_synth"
version = "0.1.0"
dependencies = [
"nih_plug",
]
[[package]]
name = "ppv-lite86"
version = "0.2.16"

View file

@ -25,6 +25,7 @@ members = [
"plugins/examples/gain_gui_iced",
"plugins/examples/gain_gui_vizia",
"plugins/examples/midi_inverter",
"plugins/examples/poly_mod_synth",
"plugins/examples/sine",
"plugins/examples/stft",

View file

@ -170,9 +170,12 @@ examples.
[egui](plugins/examples/gain_gui_egui),
[iced](plugins/examples/gain_gui_iced), and
[VIZIA](plugins/examples/gain_gui_vizia).
- [**midi-inverter**](plugins/examples/midi-inverter) takes note/MIDI events and
- [**midi_inverter**](plugins/examples/midi_inverter) takes note/MIDI events and
flips around the note, channel, expression, pressure, and CC values. This
example demonstrates how to receive and output those events.
- [**poly_mod_synth**](plugins/examples/poly_mod_synth) is a simple polyphonic
synthesizer with support for polyphonic modulation in supported CLAP hosts.
This demonstrates how polyphonic modulation can be used in NIH-plug.
- [**sine**](plugins/examples/sine) is a simple test tone generator plugin with
frequency smoothing that can also make use of MIDI input instead of generating
a static signal based on the plugin's parameters.

View file

@ -0,0 +1,12 @@
[package]
name = "poly_mod_synth"
version = "0.1.0"
edition = "2021"
authors = ["Robbert van der Helm <mail@robbertvanderhelm.nl>"]
license = "ISC"
[lib]
crate-type = ["cdylib"]
[dependencies]
nih_plug = { path = "../../../", features = ["assert_process_allocs"] }

View file

@ -0,0 +1,79 @@
use nih_plug::prelude::*;
use std::sync::Arc;
/// A simple polyphonic synthesizer with support for CLAP's polyphonic modulation. See
/// `NoteEvent::PolyModulation` for another source of information on how to use this.
struct PolyModSynth {
params: Arc<PolyModSynthParams>,
}
#[derive(Default, Params)]
struct PolyModSynthParams {}
impl Default for PolyModSynth {
fn default() -> Self {
Self {
params: Arc::new(PolyModSynthParams::default()),
}
}
}
impl Plugin for PolyModSynth {
const NAME: &'static str = "Poly Mod Synth";
const VENDOR: &'static str = "Moist Plugins GmbH";
const URL: &'static str = "https://youtu.be/dQw4w9WgXcQ";
const EMAIL: &'static str = "info@example.com";
const VERSION: &'static str = "0.0.1";
const DEFAULT_NUM_INPUTS: u32 = 2;
const DEFAULT_NUM_OUTPUTS: u32 = 2;
// We won't need any MIDI CCs here, we just want notes and polyphonic modulation
const MIDI_INPUT: MidiConfig = MidiConfig::Basic;
const MIDI_OUTPUT: MidiConfig = MidiConfig::Basic;
const SAMPLE_ACCURATE_AUTOMATION: bool = true;
fn params(&self) -> Arc<dyn Params> {
self.params.clone()
}
fn process(
&mut self,
_buffer: &mut Buffer,
_aux: &mut AuxiliaryBuffers,
context: &mut impl ProcessContext,
) -> ProcessStatus {
// TODO: Split blocks, so something cool
while let Some(event) = context.next_event() {
match event {
_ => (),
}
}
ProcessStatus::Normal
}
}
impl ClapPlugin for PolyModSynth {
const CLAP_ID: &'static str = "com.moist-plugins-gmbh.poly-mod-synth";
const CLAP_DESCRIPTION: Option<&'static str> =
Some("A simple polyphonic synthesizer with support for polyphonic modulation");
const CLAP_MANUAL_URL: Option<&'static str> = Some(Self::URL);
const CLAP_SUPPORT_URL: Option<&'static str> = None;
const CLAP_FEATURES: &'static [ClapFeature] = &[
ClapFeature::Instrument,
ClapFeature::Synthesizer,
ClapFeature::Stereo,
];
}
// The VST3 verison of this plugin isn't too interesting as it will not support polyphonic
// modulation
impl Vst3Plugin for PolyModSynth {
const VST3_CLASS_ID: [u8; 16] = *b"PolyM0dSynth1337";
const VST3_CATEGORIES: &'static str = "Instrument|Synth";
}
nih_export_clap!(PolyModSynth);
nih_export_vst3!(PolyModSynth);