Skip to content

Commit

Permalink
Finalised gated synths
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Marx authored and samaaron committed Oct 9, 2023
1 parent 772127d commit 9a39983
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion SYNTH_DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
- On some synths, e. g. `:kalimba`, it is necessary to reduce the default `:release` in order for the gate to take effect.
Binary file not shown.
4 changes: 2 additions & 2 deletions etc/synthdefs/designs/overtone/sonic-pi/src/sonic_pi/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
30 changes: 30 additions & 0 deletions etc/synthdefs/designs/supercollider/gated/piano_gated.scd
Original file line number Diff line number Diff line change
@@ -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/")

0 comments on commit 9a39983

Please sign in to comment.