From 629e41bc9455d01098e55d2e424d3db447ba0760 Mon Sep 17 00:00:00 2001 From: Pete Shadbolt Date: Mon, 3 May 2021 18:59:36 -0700 Subject: [PATCH] Nice, nice --- audio.scd | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/audio.scd b/audio.scd index 9a9876d..761847b 100644 --- a/audio.scd +++ b/audio.scd @@ -10,18 +10,26 @@ s.waitForBoot { // Create the synth definition and load it module = SynthDef.new("module", { - arg hue, saturation, value; - var oscillator, noise, filter, panner, mixer; + arg hue, saturation, value, pan; + var oscillator, noise, filter, panner, mixer, frequency, qfactor, noise_level, osc_level; + + // Calculate some parameters + frequency = 200 + 800*hue; + qfactor = (1 - saturation)**4; + osc_level = saturation; + noise_level = 1 - osc_level; + + // Generate some sounds noise = WhiteNoise.ar(1); - filter = BPF.ar(noise, MouseX.kr(220, 1000), MouseY.kr(0, 1)**4, MouseY.kr(2, 0.1)); - oscillator = SinOsc.ar(MouseX.kr(220, 1000)) * MouseY.kr(0.5, 0); + filter = BPF.ar(noise, frequency, qfactor) * noise_level; + oscillator = SinOsc.ar(frequency) * osc_level; mixer = Mix.ar([filter, oscillator]); - panner = LinPan2.ar(mixer, 0.0); - Out.ar(0, mixer); + panner = LinPan2.ar(mixer, 2*pan - 1, value); + Out.ar(0, panner); }); module.load(s); s.sync; // Make a sound - sound = Synth.new("module", [\hue, 440, \saturation, 100, \value, 500]); + sound = Synth.new("module", [\hue, 0.5, \saturation, 0.1, \value, 0.5, \pan, 0.5]); };