Skip to content

Commit

Permalink
Has a pretty good drum kit! Sounds like good perc synths or bad acous…
Browse files Browse the repository at this point in the history
…tic kit.
  • Loading branch information
ckmahoney committed Oct 4, 2024
1 parent 349e1af commit 44f0c1d
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 48 deletions.
27 changes: 22 additions & 5 deletions src/demo/chill_beat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ fn demonstrate() {
use rand::Rng;
let mut rng = rand::thread_rng();

let cps:f32 = 1.15;
let cps:f32 = 1.2;
let cps:f32 = 2.1;
let root:f32 = 1.9;
let labels:Vec<&str> = vec!["vibe", "sine", "brush"];

Expand Down Expand Up @@ -207,12 +208,11 @@ fn demonstrate() {



fn samp() -> SampleBuffer {
fn samp(cps:f32, root:f32) -> SampleBuffer {
use rand::Rng;
let mut rng = rand::thread_rng();

let cps:f32 = 1.15;
let root:f32 = 1.9;


let delays:Vec<DelayParams> = vec![delay::passthrough];

Expand Down Expand Up @@ -256,11 +256,28 @@ fn test_hypnosis() {
let n_versions = 8;
let n_loops = 4;

use rand::Rng;
let mut rng = rand::thread_rng();

let mut root:f32 = rng.gen::<f32>();
let base_cps:f32 = 1.2f32 + rng.gen::<f32>();
let mut cps:f32 = base_cps;

for i in 0..n_versions {
ring = samp();
ring = samp(cps, root);
for j in 0..n_loops {
track.extend(&ring)
}

root *= 1.5f32;
if root > 2f32 {
root /= 2f32;
};

cps *= 1.5f32;
if cps > base_cps * 3f32 {
cps /= 3f32;
};
}

let filename = format!("{}/hypnoloop_{}.wav",location(demo_name), demo_name);
Expand Down
3 changes: 2 additions & 1 deletion src/druid/soid_fx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ pub mod ratio {
use super::*;

/// Add a copy of soids where all mul are multiplied by 'k'
/// gain affects the amplitude of added copies. original sinus are not affected.
pub fn constant(soids:&Soids, k:f32, gain: f32) -> Soids {
let mut ret = soids.clone();
let gain:f32 = gain * 0.5f32; // this adds one mul per mul, so halve the volume of both.
soids.0.iter().enumerate().for_each(|(i,m)|{
ret.0[i] *= gain;
// ret.0[i] *= gain;

ret.0.push(gain);
ret.1.push(m*k);
Expand Down
16 changes: 2 additions & 14 deletions src/presets/ambien/hats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,6 @@ use crate::types::synthesis::{ModifiersHolder,Soids};
use crate::phrasing::{contour::Expr, ranger::KnobMods};
use crate::druid::{self, soids as druidic_soids, soid_fx, noise::NoiseColor};


pub fn expr_noise(arf:&Arf) -> Expr {
(vec![db_to_amp(-15f32)], vec![1f32], vec![0f32])
}

pub fn expr_tonal(arf:&Arf) -> Expr {
(vec![db_to_amp(-15f32)], vec![1f32], vec![0f32])
}


// @art-choice This module would benefit from dynamic selection of knob params
// from the given VEP parameters

/// Selects a short lived impulse for the pink noise component of a closed hi hat
fn amp_knob_noise(visibility:Visibility, energy:Energy, presence:Presence) -> (Knob, fn(&Knob, f32, f32, f32, f32, f32) -> f32) {
let sustain = 0.1f32;
Expand Down Expand Up @@ -63,11 +50,12 @@ pub fn renderable<'render>(melody:&'render Melody<Note>, arf:&Arf) -> Renderable
soid_fx::noise::rank(1, NoiseColor::Equal, 1f32),
]);

let expr:Expr = (vec![db_to_amp(-15f32)], vec![1f32], vec![0f32]);

let mut knob_mods:KnobMods = KnobMods::unit();
let mut rng = thread_rng();
knob_mods.0.push((Knob {a: rng.gen::<f32>(), b: rng.gen::<f32>()/5f32, c:0f32 }, ranger::amod_pluck));
let stem_tonal = (melody, soids, expr_tonal(arf), feel_tonal, knob_mods, vec![delay::passthrough]);
let stem_tonal = (melody, soids, expr, feel_tonal, knob_mods, vec![delay::passthrough]);

Renderable::Group(vec![
stem_tonal
Expand Down
57 changes: 31 additions & 26 deletions src/presets/ambien/kick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,6 @@ use crate::types::synthesis::{ModifiersHolder,Soids};
use crate::phrasing::{contour::Expr, ranger::KnobMods};
use crate::druid::{self, soids as druidic_soids, soid_fx};

/// Softens the overall amplitude
pub fn expr_id(arf:&Arf) -> Expr {
(vec![db_to_amp(-10f32)], vec![1f32], vec![0f32])
}

fn knob_amp() -> (Knob, fn(&Knob, f32, f32, f32, f32, f32) -> f32) {
(Knob { a: 0.11f32, b: 1f32, c: 0f32 }, ranger::amod_pluck)
}

/// noise component
fn stem_hidden<'render>(arf:&Arf, melody:&'render Melody<Note>) -> Stem<'render> {
let soids = druidic_soids::id();
Expand Down Expand Up @@ -44,17 +35,26 @@ fn stem_hidden<'render>(arf:&Arf, melody:&'render Melody<Note>) -> Stem<'render>

/// sine component
fn stem_foreground<'render>(arf:&Arf, melody:&'render Melody<Note>) -> Stem<'render> {
let soids = soid_fx::ratio::constant(&soid_fx::ratio::constant(&druidic_soids::id(), 6f32, 0.22f32), 7f32, 0.1f32);
let soids = soid_fx::ratio::constant(&soids, 2f32, 0.7f32);
let soids = soid_fx::ratio::constant(&soids, 3f32, 0.4f32);
let soids = soid_fx::ratio::constant(&soids, 2f32, 0.7f32);
let soids = soid_fx::ratio::constant(&soids, 3f32, 0.4f32);
let soids = soid_fx::ratio::constant(&soids, 1f32/5f32, 0.6f32);
let soids = soid_fx::ratio::constant(&soids, 1f32/2f32, 0.6f32);
let soids = soid_fx::ratio::constant(&soids, 1f32/3f32, 0.5f32);
let soids = soid_fx::ratio::constant(&soids, 7f32/11f32, 0.3f32);

let feel_id:Feel = Feel {
let mut rng = thread_rng();
let peak1:f32 = 6f32;
let peak2:f32 = 7f32;
let peak3:f32 = (peak1.sqrt() + peak2.sqrt()).powi(2i32);

let mut compound_ratios:Vec<(f32, f32)> = vec![
(peak1, 0.22f32),
(peak2, 0.1f32),
(2f32, 0.7f32),
(3f32, 0.4f32),
(2f32, 0.5f32),
(3f32, 0.4f32),
(0.2f32, 0.6f32),
(0.5f32, 0.6f32),
(0.33f32, 0.5f32),
(0.75f32, 0.3f32),
];

let soids:Soids = compound_ratios.iter().fold(druidic_soids::id(), |soids, (k, gain)| soid_fx::ratio::constant(&soids, *k, *gain));
let feelsoid_fx:Feel = Feel {
bp: (vec![MFf], vec![NFf]),
modifiers: (
vec![],
Expand All @@ -68,20 +68,25 @@ fn stem_foreground<'render>(arf:&Arf, melody:&'render Melody<Note>) -> Stem<'ren
let mut knob_mods:KnobMods = KnobMods::unit();
knob_mods.0.push((
Knob {
a: 1f32,
a: 0.8f32,
b: 0.1f32,
c:0f32
},
ranger::amod_pluck
));
knob_mods.0.push((
Knob {
a: 0.5f32,
b: 0.3f32,
c:0f32
},
ranger::amod_pluck
));
let expr = (vec![visibility_gain(Visibility::Foreground)], vec![1f32], vec![0f32]);
// let soids = soid_fx::detune::reece(&druidic_soids::id(), 12, 0.5f32);
(melody, soids, expr, feel_id, knob_mods, vec![delay::passthrough])
// let soids = soid_fx::detune::reece(&soids, 3, 0.5f32);
(melody, soids, expr, feelsoid_fx, knob_mods, vec![delay::passthrough])
}

/// Defines the constituent stems to create a complex kick drum
/// Components include:
/// - a transient id element
pub fn renderable<'render>(melody:&'render Melody<Note>, arf:&Arf) -> Renderable<'render> {
Renderable::Group(vec![
stem_hidden(arf, melody),
Expand Down
4 changes: 2 additions & 2 deletions src/presets/ambien/perc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn stem_visible<'render>(arf:&Arf, melody:&'render Melody<Note>) -> Stem<'re
let soids:Soids = soid_fx::fmod::square(&soids,3);
// let soids:Soids = soid_fx::fmod::square(&soids,3);

let expr = (vec![visibility_gain(Visibility::Visible)], vec![1f32], vec![0f32]);
let expr = (vec![visibility_gain(Visibility::Foreground)], vec![1f32], vec![0f32]);
let feel:Feel = Feel {
bp: (vec![MFf], vec![NFf]),
modifiers: (
Expand Down Expand Up @@ -102,7 +102,7 @@ pub fn stem_background() {
/// Background component
pub fn stem_hidden<'render>(arf:&Arf, melody:&'render Melody<Note>) -> Stem<'render> {
let soids = druidic_soids::octave(500f32);
let expr = (vec![2f32 * visibility_gain(Visibility::Hidden)], vec![1f32], vec![0f32]);
let expr = (vec![visibility_gain(Visibility::Hidden)], vec![1f32], vec![0f32]);
let feel:Feel = Feel {
bp: (vec![MFf], vec![NFf]),
modifiers: (
Expand Down

0 comments on commit 44f0c1d

Please sign in to comment.