From 9a3998330fe8bc09ead35e0fb941ad304957477c Mon Sep 17 00:00:00 2001 From: Ben Marx Date: Sat, 16 Sep 2023 22:42:32 +0200 Subject: [PATCH] Finalised gated synths --- SYNTH_DESIGN.md | 2 +- ...scsyndef => sonic-pi-piano_gated.scsyndef} | Bin 2447 -> 2447 bytes .../overtone/sonic-pi/src/sonic_pi/core.clj | 4 +-- .../supercollider/gated/piano_gated.scd | 30 ++++++++++++++++++ 4 files changed, 33 insertions(+), 3 deletions(-) rename etc/synthdefs/compiled/gated/{sonic-pi-piano-gated.scsyndef => sonic-pi-piano_gated.scsyndef} (94%) create mode 100644 etc/synthdefs/designs/supercollider/gated/piano_gated.scd diff --git a/SYNTH_DESIGN.md b/SYNTH_DESIGN.md index b9aa019de1..ee9dd948a0 100644 --- a/SYNTH_DESIGN.md +++ b/SYNTH_DESIGN.md @@ -266,4 +266,4 @@ Some final notes: - Some synths have been left out on purpose. The `:dull_bell` and `:pretty_bell` synths depend on the interrelations of the envelopes of their partials and no reasonable way of adding a gate parameter was found. Also, merely percussive synths like the SC808 group of synths were not enabled to be used with a gate. -- On some synths, e. g. `:kalimba` it is necessary to reduce the default `:release` in order for the gate to take effect. \ No newline at end of file +- On some synths, e. g. `:kalimba`, it is necessary to reduce the default `:release` in order for the gate to take effect. \ No newline at end of file diff --git a/etc/synthdefs/compiled/gated/sonic-pi-piano-gated.scsyndef b/etc/synthdefs/compiled/gated/sonic-pi-piano_gated.scsyndef similarity index 94% rename from etc/synthdefs/compiled/gated/sonic-pi-piano-gated.scsyndef rename to etc/synthdefs/compiled/gated/sonic-pi-piano_gated.scsyndef index d75482d62557d343788233459c492b5dc2538fea..026eaf412980148878d47b334215726541d8c3a9 100644 GIT binary patch delta 17 YcmeAd?iZdQ$rwLT%8fB*W1=1>04`Ys04ym4rvLx| diff --git a/etc/synthdefs/designs/overtone/sonic-pi/src/sonic_pi/core.clj b/etc/synthdefs/designs/overtone/sonic-pi/src/sonic_pi/core.clj index 42607d4a81..d7c0624bd1 100644 --- a/etc/synthdefs/designs/overtone/sonic-pi/src/sonic_pi/core.clj +++ b/etc/synthdefs/designs/overtone/sonic-pi/src/sonic_pi/core.clj @@ -16,13 +16,13 @@ ;; brother. See: http://overtone.github.io (ns sonic-pi.core - (:use [overtone.core]) + (:use [overtone.live]) (:require [clojure.string :as str])) ;; Utility functions (for creating and storing synthdefs) -(def path-to-synthdefs "/home/bmarx/tmp/overtone/overtone/synthdefs") +(def path-to-synthdefs "/Users/sam/Development/sonic-pi/etc/synthdefs") (+ 1 2) (defn save-synthdef [sdef] (let [compiled (str path-to-synthdefs "/compiled/" (last (str/split (-> sdef :sdef :name) #"/")) ".scsyndef") diff --git a/etc/synthdefs/designs/supercollider/gated/piano_gated.scd b/etc/synthdefs/designs/supercollider/gated/piano_gated.scd new file mode 100644 index 0000000000..4be2277d7a --- /dev/null +++ b/etc/synthdefs/designs/supercollider/gated/piano_gated.scd @@ -0,0 +1,30 @@ +SynthDef('sonic-pi-piano_gated', {| + note = 52, amp = 1, amp_slide = 0, amp_slide_shape = 1, amp_slide_curve = 0, + pan = 0, pan_slide = 0, pan_slide_shape = 1, pan_slide_curve = 0, + attack = 0, decay = 0, sustain = 0, release = 1, + attack_level = 1, decay_level = -1, sustain_level = 1, env_curve = 1, + vel = 0.2, hard = 0.5, velcurve = 0.8, stereo_width = 0, + gate = 1, + out_bus = 0 | + + var snd, env; + var rounded = round(note, 1); + + decay_level = Select.kr(decay_level < 0, [decay_level, sustain_level]); + amp = amp.varlag(amp_slide, amp_slide_curve, amp_slide_shape); + pan = pan.varlag(pan_slide, pan_slide_curve, pan_slide_shape); + + snd = MdaPiano.ar(freq: rounded.midicps, tune: note - rounded + 0.5, gate: 1, + vel: vel.clip(0, 1).linlin(0, 1, 0, 127), + hard: hard.clip(0, 1).linlin(0, 1, -3, 3), + decay: decay, release: release, velhard: 0.8, + muffle: 0.8, velmuff: 0.8, velcurve: velcurve, stereo: stereo_width, + random: 0, stretch: 0, sustain: 0.1); + snd = Balance2.ar(snd[0], snd[1], pan, amp) * 60; + + env = Env.new([0, attack_level, decay_level, sustain_level, 0], + [attack, decay, 0, release], + env_curve, 3); + Out.ar(out_bus, snd * EnvGen.kr(env, gate, doneAction: 2))} + +).writeDefFile("/Users/sam/Development/RPi/sonic-pi/etc/synthdefs/compiled/")