Skip to content

Commit 430ed09

Browse files
committed
Synths - update sc808 snare based on recent changes
1 parent 91f1cac commit 430ed09

File tree

3 files changed

+106
-113
lines changed

3 files changed

+106
-113
lines changed

app/server/ruby/lib/sonicpi/synths/synthinfo.rb

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3748,10 +3748,6 @@ def synth_name
37483748
"sc808_bassdrum"
37493749
end
37503750

3751-
def on_start(studio, args_h)
3752-
args_h[:rand_buf] = studio.rand_buf_id
3753-
end
3754-
37553751
def doc
37563752
"Bassdrum of the SC808 drum machine based on [Yoshinosuke Horiuchi's](https://www.patreon.com/4H/posts) implementation of the legendary rhythm composer from the early 80s."
37573753
end
@@ -3775,8 +3771,6 @@ def arg_defaults
37753771
:attenuation => 1,
37763772
}
37773773
end
3778-
3779-
37803774
def specific_arg_info
37813775
{
37823776
:decay =>
@@ -3820,17 +3814,14 @@ def synth_name
38203814
"sc808_snare"
38213815
end
38223816

3823-
def on_start(studio, args_h)
3824-
args_h[:rand_buf] = studio.rand_buf_id
3825-
end
3826-
38273817
def doc
38283818
"Snare drum of the SC808 drum machine based on [Yoshinosuke Horiuchi's](https://www.patreon.com/4H/posts) implementation of the legendary rhythm composer from the early 80s. "
38293819
end
38303820

38313821
def arg_defaults
38323822
{
38333823
:note => 65,
3824+
:detune => -11,
38343825
:amp => 1,
38353826
:amp_slide => 0,
38363827
:amp_slide_shape => 1,
@@ -3839,13 +3830,6 @@ def arg_defaults
38393830
:pan_slide => 0,
38403831
:pan_slide_shape => 1,
38413832
:pan_slide_curve => 0,
3842-
:attack => 0,
3843-
:decay => 0,
3844-
:sustain => 0,
3845-
:release => 0.3,
3846-
:attack_level => 1,
3847-
:decay_level => :sustain_level,
3848-
:sustain_level => 1,
38493833
:lpf => 93,
38503834
:lpf_slide => 0,
38513835
:lpf_slide_shape => 1,
@@ -3856,6 +3840,9 @@ def arg_defaults
38563840
:hpf_slide_curve => 0,
38573841
:mix => 0.7,
38583842
:head_hpf => 30,
3843+
:decay => 4.2,
3844+
:decay_curve => -115,
3845+
:click => 0.999
38593846
}
38603847
end
38613848

@@ -3911,6 +3898,31 @@ def specific_arg_info
39113898
:doc => "Ratio of amplitude between the sound of the head of the drum (the boom) and the snare of the drum (the buzz). A value of 1 is 100% snare, a value of 0 is 100% head and 0.5 is 50% of each.",
39123899
:validations => [v_between_inclusive(:mix, 0, 1)],
39133900
:modulatable => false,
3901+
},
3902+
3903+
:click =>
3904+
{
3905+
:doc => "Amount of initial click to the drum sound. 0 is no click and 1 is a hard click.",
3906+
:validations => [v_between_inclusive(:click, 0, 1)],
3907+
:modulatable => false
3908+
},
3909+
:decay =>
3910+
{
3911+
:doc => "Amount of decay for the snare. Higher numbers increase the decay duration.",
3912+
:validations => [v_positive_not_zero(:decay)],
3913+
:modulatable => false
3914+
},
3915+
:detune =>
3916+
{
3917+
:doc => "Detune multiplier of original pitch for the snare's timbre. A value of 1 indicates no deviation from the fundamental pitch",
3918+
:validations => [],
3919+
:modulatable => false
3920+
},
3921+
:decay_curve =>
3922+
{
3923+
:doc => "Curve value for the decay of the snare",
3924+
:validations => [],
3925+
:modulatable => false
39143926
}
39153927
}
39163928
end
@@ -3929,10 +3941,6 @@ def synth_name
39293941
"sc808_clap"
39303942
end
39313943

3932-
def on_start(studio, args_h)
3933-
args_h[:rand_buf] = studio.rand_buf_id
3934-
end
3935-
39363944
def doc
39373945
"Clap of the SC808 drum machine based on [Yoshinosuke Horiuchi's](https://www.patreon.com/4H/posts) implementation of the legendary rhythm composer from the early 80s."
39383946
end
@@ -3947,13 +3955,6 @@ def arg_defaults
39473955
:pan_slide => 0,
39483956
:pan_slide_shape => 1,
39493957
:pan_slide_curve => 0,
3950-
:attack => 0,
3951-
:decay => 0,
3952-
:sustain => 0,
3953-
:release => 0.11,
3954-
:attack_level => 1,
3955-
:decay_level => :sustain_level,
3956-
:sustain_level => 1,
39573958
:lpf => 93,
39583959
:lpf_slide => 0,
39593960
:lpf_slide_shape => 1,
-355 Bytes
Binary file not shown.

etc/synthdefs/designs/supercollider/sc808.scd

Lines changed: 77 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -4,93 +4,85 @@ SuperCollider 808 implementation based on Yoshinosuke Horiuchi's free version. S
44

55
(
66
SynthDef('sonic-pi-sc808_bassdrum', {|
7-
note = 34,
8-
amp = 1, amp_slide = 0, amp_slide_shape = 1, amp_slide_curve = 0,
7+
note = 34,
8+
amp = 1, amp_slide = 0, amp_slide_shape = 1, amp_slide_curve = 0,
99
pan = 0, pan_slide = 0, pan_slide_shape = 1, pan_slide_curve = 0,
1010
click = 0.11
1111
decay = 2,
1212
decay_curve = -7
13-
attenuation=1,
14-
out_bus = 0|
13+
attenuation=1,
14+
out_bus = 0|
1515

16-
var snd, fenv, env, trienv, sig, sub, punch, pfenv;
16+
var snd, fenv, env, trienv, sig, sub, punch, pfenv;
1717

18-
note = note.midicps;
19-
amp = 2 * amp;
18+
note = note.midicps;
19+
amp = 2 * amp;
2020
amp = amp.varlag(amp_slide, amp_slide_curve, amp_slide_shape);
2121
pan = pan.varlag(pan_slide, pan_slide_curve, pan_slide_shape);
2222

2323

24-
env = EnvGen.kr(Env.new([click, 1, 0], [0, decay], decay_curve),doneAction:2);
25-
trienv = EnvGen.kr(Env.new([click, 0.6, 0], [0, decay], -230),doneAction:0);
26-
fenv = Env([note*7, note*1.35, note], [0.05/attenuation, 0.6], -14).kr; // Mod 0.05 -> 0.5
27-
pfenv = Env([note*7, note*1.35, note], [0.03/attenuation, 0.6], -10).kr; // Mod 0.03 -> 0.3
28-
sig = SinOsc.ar(fenv, pi/2) * env;
29-
sub = LFTri.ar(fenv, pi/2) * trienv * 0.05;
30-
punch = SinOsc.ar(pfenv, pi/2) * env * 2;
31-
punch = HPF.ar(punch, 350);
32-
sig = (sig + sub + punch) * 2.5;
33-
sig = Limiter.ar(sig, 0.5) * amp;
24+
env = EnvGen.kr(Env.new([click, 1, 0], [0, decay], decay_curve),doneAction:2);
25+
trienv = EnvGen.kr(Env.new([click, 0.6, 0], [0, decay], -230),doneAction:0);
26+
fenv = Env([note*7, note*1.35, note], [0.05/attenuation, 0.6], -14).kr; // Mod 0.05 -> 0.5
27+
pfenv = Env([note*7, note*1.35, note], [0.03/attenuation, 0.6], -10).kr; // Mod 0.03 -> 0.3
28+
sig = SinOsc.ar(fenv, pi/2) * env;
29+
sub = LFTri.ar(fenv, pi/2) * trienv * 0.05;
30+
punch = SinOsc.ar(pfenv, pi/2) * env * 2;
31+
punch = HPF.ar(punch, 350);
32+
sig = (sig + sub + punch) * 2.5;
33+
sig = Limiter.ar(sig, 0.5) * amp;
3434
DetectSilence.ar(sig, doneAction: Done.freeSelf);
35-
sig = Pan2.ar(sig, pan);
36-
Out.ar(out_bus, sig);
35+
sig = Pan2.ar(sig, pan);
36+
Out.ar(out_bus, sig);
3737

3838
}).writeDefFile("/Users/sam/Development/sonic-pi/etc/synthdefs/compiled/");
3939
)
4040

41-
(
4241
SynthDef('sonic-pi-sc808_snare', {|
4342
note = 65,
43+
detune = -11,
44+
4445
amp = 1, amp_slide = 0, amp_slide_shape = 1, amp_slide_curve = 0,
4546
pan = 0, pan_slide = 0, pan_slide_shape = 1, pan_slide_curve = 0,
46-
attack = 0, decay = 0, sustain = 0, release = 0.15,
47-
attack_level = 1, decay_level = -1, sustain_level = 1,
4847
hpf = 93, hpf_slide = 0, hpf_slide_shape = 1, hpf_slide_curve = 1,
4948
lpf = 121, lpf_slide = 0, lpf_slide_shape = 1, lpf_slide_curve = 1,
5049
mix = 0.7,
5150
head_hpf = 30,
51+
decay = 4.2,
52+
decay_curve = -115,
53+
click = 0.999,
5254
out_bus = 0|
5355

54-
var noiseEnv, atkEnv, snd, noise, osc1, osc2, sum, note2, env, head;
55-
56-
note2 = (note - 11).midicps;
56+
var noiseEnv, atkEnv, sig, noise, osc1, osc2, snd, note2;
57+
mix = Clip.kr(mix, 0, 1);
58+
click = Clip.kr(0.1 - (click / 10.0), 0, 0.1);
59+
note2 = note + detune;
5760
note = note.midicps;
58-
59-
hpf = hpf.varlag(hpf_slide, hpf_slide_curve, hpf_slide_shape);
60-
lpf = lpf.varlag(lpf_slide, lpf_slide_curve, lpf_slide_shape);
61-
61+
note2 = note2.midicps;
6262
lpf = lpf.midicps;
6363
hpf = hpf.midicps;
64-
head_hpf = head_hpf.midicps;
6564

6665
amp = amp.varlag(amp_slide, amp_slide_curve, amp_slide_shape);
6766
pan = pan.varlag(pan_slide, pan_slide_curve, pan_slide_shape);
68-
decay_level = Select.kr(decay_level < 0, [decay_level, sustain_level]);
69-
env = Env.new(
70-
[0, attack_level, decay_level, sustain_level, 0],
71-
[attack,decay,sustain,release],
72-
\lin
73-
);
67+
hpf = hpf.varlag(hpf_slide, hpf_slide_curve, hpf_slide_shape);
68+
lpf = lpf.varlag(lpf_slide, lpf_slide_curve, lpf_slide_shape);
7469

75-
noiseEnv = EnvGen.kr(Env.new(
76-
[0, attack_level, decay_level, sustain_level, 0],
77-
[attack + 0.001,decay,sustain, release],
78-
\lin
79-
), doneAction:0);
70+
noiseEnv = EnvGen.kr(Env.perc(click, decay, 1, decay_curve), doneAction:2);
71+
atkEnv = EnvGen.kr(Env.perc(click, 0.8,curve:-95), doneAction:0);
8072

81-
atkEnv = EnvGen.kr(Env.perc(0.001, 0.8,curve:-95), doneAction:0);
8273
noise = WhiteNoise.ar;
8374
noise = HPF.ar(noise, hpf);
8475
noise = LPF.ar(noise, lpf);
8576
noise = noise * noiseEnv;
8677
osc1 = SinOsc.ar(note2, pi/2) * 0.6;
8778
osc2 = SinOsc.ar(note, pi/2) * 0.7;
88-
head = (osc1+osc2) * atkEnv * 2.5;
89-
snd = (mix * noise) + ((1 - mix) * head);
79+
snd = (osc1+osc2) * atkEnv * 2.5;
80+
snd = (mix * noise) + ((1 - mix) * snd);
9081
snd = amp * snd * 2;
91-
snd = Pan2.ar(Mix(snd) * EnvGen.kr(env, doneAction: 2), pan);
9282
snd = HPF.ar(snd, head_hpf);
93-
Out.ar(out_bus, snd);
83+
DetectSilence.ar(snd, doneAction: Done.freeSelf);
84+
Out.ar(out_bus, Pan2.ar(snd, pan));
85+
9486
}).writeDefFile("/Users/sam/Development/sonic-pi/etc/synthdefs/compiled/");
9587
)
9688

@@ -149,79 +141,79 @@ SynthDef('sonic-pi-sc808_clap', {|
149141
(
150142
SynthDef('sonic-pi-sc808_tomlo', {|
151143
note = 40,
152-
amp = 1, amp_slide = 0, amp_slide_shape = 1, amp_slide_curve = 0,
153-
pan = 0, pan_slide = 0, pan_slide_shape = 1, pan_slide_curve = 0,
154-
decay = 20
155-
click = 0.4
144+
amp = 1, amp_slide = 0, amp_slide_shape = 1, amp_slide_curve = 0,
145+
pan = 0, pan_slide = 0, pan_slide_shape = 1, pan_slide_curve = 0,
146+
decay = 20
147+
click = 0.4
156148
detune1 = 1.25
157149
detune2 = 1.125
158150
decay_curve = -250
159-
out_bus = 0|
151+
out_bus = 0|
160152

161-
var sig, fenv, env;
153+
var sig, fenv, env;
162154

163155
amp = amp.varlag(amp_slide, amp_slide_curve, amp_slide_shape);
164-
pan = pan.varlag(pan_slide, pan_slide_curve, pan_slide_shape);
165-
note = note.midicps;
156+
pan = pan.varlag(pan_slide, pan_slide_curve, pan_slide_shape);
157+
note = note.midicps;
166158

167-
env = EnvGen.kr(Env.new([click, 1, 0], [0, decay], decay_curve),doneAction:2);
168-
fenv = Env([note*detune1, note*detune2, note], [0.1, 0.5], -4).kr;
169-
sig = SinOsc.ar(fenv, pi/2) * env;
170-
sig = sig * amp;
159+
env = EnvGen.kr(Env.new([click, 1, 0], [0, decay], decay_curve),doneAction:2);
160+
fenv = Env([note*detune1, note*detune2, note], [0.1, 0.5], -4).kr;
161+
sig = SinOsc.ar(fenv, pi/2) * env;
162+
sig = sig * amp;
171163
DetectSilence.ar(sig, doneAction: Done.freeSelf);
172-
Out.ar(out_bus, Pan2.ar(sig, pan));
164+
Out.ar(out_bus, Pan2.ar(sig, pan));
173165

174166
}).writeDefFile("/Users/sam/Development/sonic-pi/etc/synthdefs/compiled/");
175167

176168
SynthDef('sonic-pi-sc808_tommid', {|
177169
note = 44,
178-
amp = 1, amp_slide = 0, amp_slide_shape = 1, amp_slide_curve = 0,
179-
pan = 0, pan_slide = 0, pan_slide_shape = 1, pan_slide_curve = 0,
180-
decay = 16
181-
click = 0.4
170+
amp = 1, amp_slide = 0, amp_slide_shape = 1, amp_slide_curve = 0,
171+
pan = 0, pan_slide = 0, pan_slide_shape = 1, pan_slide_curve = 0,
172+
decay = 16
173+
click = 0.4
182174
detune1 = 1.3333
183175
detune2 = 1.125
184176
decay_curve = -250
185-
out_bus = 0|
177+
out_bus = 0|
186178

187-
var sig, fenv, env;
179+
var sig, fenv, env;
188180

189181
amp = amp.varlag(amp_slide, amp_slide_curve, amp_slide_shape);
190-
pan = pan.varlag(pan_slide, pan_slide_curve, pan_slide_shape);
191-
note = note.midicps;
182+
pan = pan.varlag(pan_slide, pan_slide_curve, pan_slide_shape);
183+
note = note.midicps;
192184

193-
env = EnvGen.kr(Env.new([click, 1, 0], [0, decay], decay_curve),doneAction:2);
194-
fenv = Env([note*detune1, note*detune2, note], [0.1, 0.5], -4).kr;
195-
sig = SinOsc.ar(fenv, pi/2) * env;
196-
sig = sig * amp;
185+
env = EnvGen.kr(Env.new([click, 1, 0], [0, decay], decay_curve),doneAction:2);
186+
fenv = Env([note*detune1, note*detune2, note], [0.1, 0.5], -4).kr;
187+
sig = SinOsc.ar(fenv, pi/2) * env;
188+
sig = sig * amp;
197189
DetectSilence.ar(sig, doneAction: Done.freeSelf);
198-
Out.ar(out_bus, Pan2.ar(sig, pan));
190+
Out.ar(out_bus, Pan2.ar(sig, pan));
199191

200192
}).writeDefFile("/Users/sam/Development/sonic-pi/etc/synthdefs/compiled/");
201193

202194
SynthDef('sonic-pi-sc808_tomhi', {|
203195
note = 52,
204-
amp = 1, amp_slide = 0, amp_slide_shape = 1, amp_slide_curve = 0,
205-
pan = 0, pan_slide = 0, pan_slide_shape = 1, pan_slide_curve = 0,
206-
decay = 11
207-
click = 0.4
196+
amp = 1, amp_slide = 0, amp_slide_shape = 1, amp_slide_curve = 0,
197+
pan = 0, pan_slide = 0, pan_slide_shape = 1, pan_slide_curve = 0,
198+
decay = 11
199+
click = 0.4
208200
detune1 = 1.3333
209201
detune2 = 1.121212
210202
decay_curve = -250
211-
out_bus = 0|
203+
out_bus = 0|
212204

213-
var sig, fenv, env;
205+
var sig, fenv, env;
214206

215207
amp = amp.varlag(amp_slide, amp_slide_curve, amp_slide_shape);
216-
pan = pan.varlag(pan_slide, pan_slide_curve, pan_slide_shape);
217-
note = note.midicps;
208+
pan = pan.varlag(pan_slide, pan_slide_curve, pan_slide_shape);
209+
note = note.midicps;
218210

219-
env = EnvGen.kr(Env.new([click, 1, 0], [0, decay], decay_curve),doneAction:2);
220-
fenv = Env([note*detune1, note*detune2, note], [0.1, 0.5], -4).kr;
221-
sig = SinOsc.ar(fenv, pi/2) * env;
222-
sig = sig * amp;
211+
env = EnvGen.kr(Env.new([click, 1, 0], [0, decay], decay_curve),doneAction:2);
212+
fenv = Env([note*detune1, note*detune2, note], [0.1, 0.5], -4).kr;
213+
sig = SinOsc.ar(fenv, pi/2) * env;
214+
sig = sig * amp;
223215
DetectSilence.ar(sig, doneAction: Done.freeSelf);
224-
Out.ar(out_bus, Pan2.ar(sig, pan));
216+
Out.ar(out_bus, Pan2.ar(sig, pan));
225217

226218
}).writeDefFile("/Users/sam/Development/sonic-pi/etc/synthdefs/compiled/");
227219
)

0 commit comments

Comments
 (0)