···11+pub mod beacon;
22+pub mod vst;
33+44+use nih_plug::{nih_export_clap, nih_export_vst3};
55+pub use vst::*;
66+77+nih_export_clap!(ShapemakerVST);
88+nih_export_vst3!(ShapemakerVST);
+25-28
src/vst/vst.rs
···11use nih_plug::prelude::*;
22+use rand::Rng;
23use std::sync::Arc;
33-use ureq;
4455-// This is a shortened version of the gain example with most comments removed, check out
66-// https://github.com/robbert-vdh/nih-plug/blob/master/plugins/examples/gain/src/lib.rs to get
77-// started
55+use super::beacon::{self, Probe};
8699-struct ShapemakerVST {
77+pub struct ShapemakerVST {
108 params: Arc<ShapemakerVSTParams>,
99+ probe: Probe,
1110}
12111312#[derive(Params)]
1413struct ShapemakerVSTParams {
1515- /// The parameter's ID is used to identify the parameter in the wrappred plugin API. As long as
1616- /// these IDs remain constant, you can rename and reorder these fields as you wish. The
1717- /// parameters are exposed to the host in the same order they were defined. In this case, this
1818- /// gain parameter is stored as linear gain while the values are displayed in decibels.
1919- #[id = "gain"]
2020- pub gain: FloatParam,
1414+ /// Used to send automation data to Shapemaker
1515+ #[id = "automation"]
1616+ pub automation: FloatParam,
2117}
22182319impl Default for ShapemakerVST {
2420 fn default() -> Self {
2521 Self {
2622 params: Arc::new(ShapemakerVSTParams::default()),
2323+ probe: Probe {
2424+ id: rand::thread_rng().gen_range(1..=u32::MAX),
2525+ added_at: chrono::Utc::now().to_rfc3339(),
2626+ automation_name: "".to_string(),
2727+ midi_name: "".to_string(),
2828+ audio_name: "".to_string(),
2929+ },
2730 }
2831 }
2932}
···3134impl Default for ShapemakerVSTParams {
3235 fn default() -> Self {
3336 Self {
3434- // This gain is stored as linear gain. NIH-plug comes with useful conversion functions
3535- // to treat these kinds of parameters as if we were dealing with decibels. Storing this
3636- // as decibels is easier to work with, but requires a conversion for every sample.
3737- gain: FloatParam::new(
3838- "Gain",
3737+ automation: FloatParam::new(
3838+ "Send automation data",
3939 util::db_to_gain(0.0),
4040 FloatRange::Skewed {
4141 min: util::db_to_gain(-30.0),
···5959}
60606161impl Plugin for ShapemakerVST {
6262- const NAME: &'static str = "Shapemaker VST";
6262+ const NAME: &'static str = "Shapemaker VST b3";
6363 const VENDOR: &'static str = "Gwenn Le Bihan";
6464 const URL: &'static str = env!("CARGO_PKG_HOMEPAGE");
6565- const EMAIL: &'static str = "hey@ewen.works";
6565+ const EMAIL: &'static str = "gwenn.lebihan7@gmail.com";
66666767 const VERSION: &'static str = env!("CARGO_PKG_VERSION");
6868···8181 names: PortNames::const_default(),
8282 }];
83838484- const MIDI_INPUT: MidiConfig = MidiConfig::None;
8484+ const MIDI_INPUT: MidiConfig = MidiConfig::MidiCCs;
8585 const MIDI_OUTPUT: MidiConfig = MidiConfig::None;
86868787 const SAMPLE_ACCURATE_AUTOMATION: bool = true;
···105105 _buffer_config: &BufferConfig,
106106 _context: &mut impl InitContext<Self>,
107107 ) -> bool {
108108- // Resize buffers and perform other potentially expensive initialization operations here.
109109- // The `reset()` function is always called right after this function. You can remove this
110110- // function if you do not need it.
111111- // Make a debug request to localhost:8080
112112- let _ = ureq::get("http://localhost:8080/haiiiii").call();
108108+ let _ = beacon::requests::register_probe(self.probe.with_added_at_now());
113109 true
114110 }
115111···118114 // allocate. You can remove this function if you do not need it.
119115 }
120116117117+ fn deactivate(&mut self) {
118118+ let _ = beacon::requests::unregister_probe(self.probe.id);
119119+ }
120120+121121 fn process(
122122 &mut self,
123123 buffer: &mut Buffer,
···126126 ) -> ProcessStatus {
127127 for channel_samples in buffer.iter_samples() {
128128 // Smoothing is optionally built into the parameters themselves
129129- let gain = self.params.gain.smoothed.next();
129129+ let gain = self.params.automation.smoothed.next();
130130131131 for sample in channel_samples {
132132 *sample *= gain;
···155155 const VST3_SUBCATEGORIES: &'static [Vst3SubCategory] =
156156 &[Vst3SubCategory::Fx, Vst3SubCategory::Dynamics];
157157}
158158-159159-nih_export_clap!(ShapemakerVST);
160160-nih_export_vst3!(ShapemakerVST);