use nih_plug::prelude::*;
use std::sync::Arc;
use ureq;
struct ShapemakerVST {
params: Arc<ShapemakerVSTParams>,
}
#[derive(Params)]
struct ShapemakerVSTParams {
#[id = "gain"]
pub gain: FloatParam,
}
impl Default for ShapemakerVST {
fn default() -> Self {
Self {
params: Arc::new(ShapemakerVSTParams::default()),
}
}
}
impl Default for ShapemakerVSTParams {
fn default() -> Self {
Self {
gain: FloatParam::new(
"Gain",
util::db_to_gain(0.0),
FloatRange::Skewed {
min: util::db_to_gain(-30.0),
max: util::db_to_gain(30.0),
factor: FloatRange::gain_skew_factor(-30.0, 30.0),
},
)
.with_smoother(SmoothingStyle::Logarithmic(50.0))
.with_unit(" dB")
.with_value_to_string(formatters::v2s_f32_gain_to_db(2))
.with_string_to_value(formatters::s2v_f32_gain_to_db()),
}
}
}
impl Plugin for ShapemakerVST {
const NAME: &'static str = "Shapemaker VST";
const VENDOR: &'static str = "Gwenn Le Bihan";
const URL: &'static str = env!("CARGO_PKG_HOMEPAGE");
const EMAIL: &'static str = "hey@ewen.works";
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 initialize(
&mut self,
_audio_io_layout: &AudioIOLayout,
_buffer_config: &BufferConfig,
_context: &mut impl InitContext<Self>,
) -> bool {
let _ = ureq::get("http://localhost:8080/haiiiii").call();
true
}
fn reset(&mut self) {
}
fn process(
&mut self,
buffer: &mut Buffer,
_aux: &mut AuxiliaryBuffers,
_context: &mut impl ProcessContext<Self>,
) -> ProcessStatus {
for channel_samples in buffer.iter_samples() {
let gain = self.params.gain.smoothed.next();
for sample in channel_samples {
*sample *= gain;
}
}
ProcessStatus::Normal
}
}
impl ClapPlugin for ShapemakerVST {
const CLAP_ID: &'static str = "works.gwen.shapemakervst";
const CLAP_DESCRIPTION: Option<&'static str> =
Some("A VST plugin for Shapemaker, an experimental audiovisual SVG-based rendering engine");
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::Stereo];
}
impl Vst3Plugin for ShapemakerVST {
const VST3_CLASS_ID: [u8; 16] = *b"gwennlbhshapemak";
const VST3_SUBCATEGORIES: &'static [Vst3SubCategory] =
&[Vst3SubCategory::Fx, Vst3SubCategory::Dynamics];
}
nih_export_clap!(ShapemakerVST);
nih_export_vst3!(ShapemakerVST);