Skip to content

Commit

Permalink
Uses new presets!
Browse files Browse the repository at this point in the history
  • Loading branch information
ckmahoney committed Jun 23, 2024
1 parent 5b35aea commit a0477ec
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/demo/trio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down Expand Up @@ -348,7 +348,7 @@ mod test {
use super::*;
#[test]
fn test() {
demonstrate( Some(1));
demonstrate( None);
// enumerate();
}
}
38 changes: 35 additions & 3 deletions src/presets/lead_smoother.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) ],
Expand All @@ -34,6 +58,14 @@ fn choose_pmod(e:&Energy) -> WRangers {
}
}

fn choose_fmod(v:&Visibility) -> Option<WRangers> {
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);
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/presets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

0 comments on commit a0477ec

Please sign in to comment.