Skip to content

Commit

Permalink
remove #[derive(Smooth)] macro for now
Browse files Browse the repository at this point in the history
  • Loading branch information
micahrj committed Feb 18, 2024
1 parent 984521c commit 6693ef6
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 384 deletions.
12 changes: 0 additions & 12 deletions coupler-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ use syn::{parse_macro_input, DeriveInput};

mod enum_;
mod params;
mod smooth;

use enum_::expand_enum;
use params::expand_params;
use smooth::expand_smooth;

#[proc_macro_derive(Params, attributes(param))]
pub fn derive_params(input: TokenStream) -> TokenStream {
Expand All @@ -28,13 +26,3 @@ pub fn derive_enum(input: TokenStream) -> TokenStream {
Err(err) => return err.into_compile_error().into(),
}
}

#[proc_macro_derive(Smooth, attributes(param, smooth))]
pub fn derive_smooth(input: TokenStream) -> TokenStream {
let input: DeriveInput = parse_macro_input!(input as DeriveInput);

match expand_smooth(&input) {
Ok(expanded) => expanded.into(),
Err(err) => return err.into_compile_error().into(),
}
}
233 changes: 0 additions & 233 deletions coupler-derive/src/smooth.rs

This file was deleted.

18 changes: 6 additions & 12 deletions examples/gain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ use serde::{Deserialize, Serialize};

use coupler::format::clap::*;
use coupler::format::vst3::*;
use coupler::{
buffers::*, bus::*, editor::*, events::*, params::smooth::*, params::*, plugin::*, process::*,
};
use coupler::{buffers::*, bus::*, editor::*, events::*, params::*, plugin::*, process::*};

#[derive(Params, Smooth, Serialize, Deserialize, Clone)]
#[derive(Params, Serialize, Deserialize, Clone)]
struct GainParams {
#[param(id = 0, name = "Gain", range = 0.0..1.0, format = "{:.2}")]
#[smooth(Exp, ms = 10.0)]
gain: f32,
}

Expand Down Expand Up @@ -81,7 +78,7 @@ impl Plugin for Gain {

fn processor(&self, config: Config) -> Self::Processor {
GainProcessor {
params: self.params.smoothed(config.sample_rate),
params: self.params.clone(),
}
}

Expand All @@ -107,17 +104,15 @@ impl ClapPlugin for Gain {
}

pub struct GainProcessor {
params: Smoothed<GainParams>,
params: GainParams,
}

impl Processor for GainProcessor {
fn set_param(&mut self, id: ParamId, value: ParamValue) {
self.params.set_param(id, value);
}

fn reset(&mut self) {
self.params.reset();
}
fn reset(&mut self) {}

fn process(&mut self, buffers: Buffers, events: Events) {
let buffer: BufferMut = buffers.try_into().unwrap();
Expand All @@ -132,9 +127,8 @@ impl Processor for GainProcessor {
}

for sample in buffer.samples() {
let gain = self.params.gain.next();
for channel in sample {
*channel *= gain;
*channel *= self.params.gain;
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::str::FromStr;
pub use coupler_derive::{Enum, Params};

mod range;
pub mod smooth;

pub use range::{Encode, Log, Range};

Expand Down
Loading

0 comments on commit 6693ef6

Please sign in to comment.