From a0477ec3f7d302d5ae32242b581fa43e5bd2609e Mon Sep 17 00:00:00 2001 From: ckmahoney Date: Sat, 22 Jun 2024 22:25:02 -0400 Subject: [PATCH] Uses new presets! --- src/demo/trio.rs | 4 ++-- src/presets/lead_smoother.rs | 38 +++++++++++++++++++++++++++++++++--- src/presets/mod.rs | 2 +- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/demo/trio.rs b/src/demo/trio.rs index 7456f0f..56426d9 100644 --- a/src/demo/trio.rs +++ b/src/demo/trio.rs @@ -216,7 +216,7 @@ fn get_arfs() -> [Arf;3] { role: Role::Lead, register: 7, visibility: Visibility::Foreground, - energy: Energy::High, + energy: Energy::Medium, presence: Presence::Legato, }; @@ -348,7 +348,7 @@ mod test { use super::*; #[test] fn test() { - demonstrate( Some(1)); + demonstrate( None); // enumerate(); } } diff --git a/src/presets/lead_smoother.rs b/src/presets/lead_smoother.rs index 924bfd7..8d49616 100644 --- a/src/presets/lead_smoother.rs +++ b/src/presets/lead_smoother.rs @@ -26,6 +26,30 @@ fn pmod_detune(k:usize, x:f32, d:f32) -> f32 { (x * pi2 * applied_rate).sin() } +// offset_above_zero is computed from vib range +static vib_a:f32 = 30f32; +static vib_b:f32 = 12f32; +static vib_c:f32 = pi/3f32; +fn fmod_vibrato(k:usize, x:f32, d:f32) -> f32 { + let vib_range:f32 = 2f32.powf(2f32/12f32) / 32f32; + let offset_center_1:f32 = 1f32 + (vib_range/2f32); + let y =((vib_a/(vib_b*x+vib_c).powf(3f32))).sin(); + vib_range * y+offset_center_1 +} + + +// offset_above_zero is computed from vib range +static vib_d:f32 = 50f32; +static vib_e:f32 = 12f32; +static vib_f:f32 = pi/2f32; +fn fmod_vibrato2(k:usize, x:f32, d:f32) -> f32 { + let vib_range:f32 = 2f32 / 3f32; + let offset_center_1:f32 = 1f32 + (vib_range/2f32); + let y =((vib_d/(vib_e*x+vib_f).powf(3f32))).sin(); + vib_range * y+offset_center_1 +} + + fn choose_pmod(e:&Energy) -> WRangers { match e { Energy::Low => vec![ (0.33f32, pmod_shimmer) ], @@ -34,6 +58,14 @@ fn choose_pmod(e:&Energy) -> WRangers { } } +fn choose_fmod(v:&Visibility) -> Option { + match v { + Visibility::Visible => Some(vec![ (0.33f32, fmod_vibrato) ]), + Visibility::Foreground => Some(vec![ (0.33f32, fmod_vibrato2) ]), + _ => None + } +} + fn melodic_el(fund:f32, vis:&Visibility, energy:&Energy, presence:&Presence) -> Element { let muls = melodic::muls_sawtooth(fund); let amps = melodic::amps_sawtooth(fund); @@ -48,11 +80,11 @@ fn melodic_el(fund:f32, vis:&Visibility, energy:&Energy, presence:&Presence) -> Some(vec![ (0.65f32, lifespan::mod_pluck) ]), - None, - Some(choose_pmod(&energy)), + Some(vec![(1f32, fmod_vibrato)]), + choose_fmod(&vis), ]; - Element { + Element { mode: Mode::Melodic, amps, muls, diff --git a/src/presets/mod.rs b/src/presets/mod.rs index 1161c83..9a532e0 100644 --- a/src/presets/mod.rs +++ b/src/presets/mod.rs @@ -82,7 +82,7 @@ pub fn select(arf:&Arf) -> SynthGen { Role::Perc => snare_hard::synth, Role::Hats => hats_hard::synth, Role::Bass => bass_smoother::synth, - Role::Chords => chords::synth, + Role::Chords => chords_smoother::synth, Role::Lead => lead_smoother::synth, } }