Skip to content

Commit bedf550

Browse files
committed
Synths - fix up sc808 rimshot
1 parent 9be6e4b commit bedf550

File tree

3 files changed

+73
-54
lines changed

3 files changed

+73
-54
lines changed

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

Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4292,70 +4292,76 @@ def synth_name
42924292
"sc808_rimshot"
42934293
end
42944294

4295-
def on_start(studio, args_h)
4296-
args_h[:rand_buf] = studio.rand_buf_id
4297-
end
4298-
42994295
def doc
43004296
"Rimshot 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. This is a percussive synth, so it does not use the standard envelope parameters, neither does it feature slideable parameters."
43014297
end
43024298

43034299
def arg_defaults
43044300
{
43054301
:note => 92,
4302+
:detune => -22,
43064303
:amp => 1,
4304+
:amp_slide => 0,
4305+
:amp_slide_shape => 1,
4306+
:amp_slide_curve => 0,
43074307
:pan => 0,
4308-
:note2 => 70,
4309-
:cutoff_lo => 63,
4310-
:cutoff_hi => 118,
4308+
:pan_slide => 0,
4309+
:pan_slide_shape => 1,
4310+
:pan_slide_curve => 0,
4311+
:lpf => 63,
4312+
:lpf_slide => 0,
4313+
:lpf_slide_shape => 1,
4314+
:lpf_slide_curve => 0,
4315+
:hpf => 118,
4316+
:hpf_slide => 0,
4317+
:hpf_slide_shape => 1,
4318+
:hpf_slide_curve => 0,
4319+
:decay => 0.07,
4320+
:decay_curve => -42,
4321+
:click => 1
43114322
}
43124323
end
43134324

4314-
def default_arg_info
4315-
super.merge({
4316-
:note =>
4317-
{
4318-
:doc => "Note to play. Either a MIDI number or a symbol representing a note. For example: `30`, `52`, `:C`, `:C2`, `:Eb4`, or `:Ds3`",
4319-
:validations => [v_positive(:note)],
4320-
:modulatable => false,
4321-
:midi => true
4322-
},
4323-
:amp =>
4325+
def specific_arg_info
4326+
{
4327+
:click =>
43244328
{
4325-
:doc => "The amplitude of the sound. Typically a value between 0 and 1. Higher amplitudes may be used, but won't make the sound louder, they will just reduce the quality of all the sounds currently being played (due to compression.)",
4326-
:validations => [v_positive(:amp)],
4329+
:doc => "Amount of initial click to the rimshot sound. 0 is no click and 1 is a hard click.",
4330+
:validations => [v_between_inclusive(:click, 0, 1)],
43274331
:modulatable => false
43284332
},
4329-
:pan =>
4333+
:decay =>
43304334
{
4331-
:doc => "Position of sound in stereo. With headphones on, this means how much of the sound is in the left ear, and how much is in the right ear. With a value of -1, the sound is completely in the left ear, a value of 0 puts the sound equally in both ears and a value of 1 puts the sound in the right ear. Values in between -1 and 1 move the sound accordingly.",
4332-
:validations => [v_between_inclusive(:pan, -1, 1)],
4335+
:doc => "Amount of decay for the rimshot. Higher numbers increase the decay duration.",
4336+
:validations => [v_positive_not_zero(:decay)],
43334337
:modulatable => false
43344338
},
4335-
})
4336-
end
4337-
4338-
def specific_arg_info
4339-
{
4340-
:note2 =>
4339+
:detune =>
43414340
{
4342-
:doc => "Second base frequency of the sound. Play with both both `:note` and `:note2` for slight changes of timbre and, of course, pitch.",
4343-
:validations => [v_positive(:note2)],
4344-
:modulatable => false,
4345-
:midi => true
4341+
:doc => "Detune in MIDI notes of original pitch for the rimshot's timbre.",
4342+
:validations => [v_positive_not_zero(:detune)],
4343+
:modulatable => false
43464344
},
4347-
:cutoff_lo =>
4345+
:decay_curve =>
43484346
{
4349-
:doc => "MIDI note representing the lowest frequencies allowed to be present in the sound.",
4350-
:validations => [v_positive(:cutoff_lo)],
4347+
:doc => "Curve value for the decay of the tom",
4348+
:validations => [],
43514349
:modulatable => false
43524350
},
4353-
:cutoff_hi =>
4351+
:lpf =>
43544352
{
4355-
:doc => "MIDI note representing the highest frequencies allowed to be present in the sound.",
4356-
:validations => [v_positive(:cutoff_hi)],
4357-
:modulatable => false
4353+
:doc => "Low pass filter cutoff value for the rimshot. A MIDI note representing the highest frequencies allowed to be present in the sound. A low value like 30 makes the sound round and dull, a high value like 100 makes the sound buzzy and crispy.",
4354+
:validations => [v_positive(:lpf), v_less_than(:lpf, 131)],
4355+
:modulatable => true,
4356+
:midi => true
43584357
},
4358+
:hpf =>
4359+
{
4360+
:doc => "High pass filter cutoff value for the rimshot. A MIDI note representing the lowest frequencies allowed to be present in the sound. A high value like 100 makes the sound thin and whispy, a low value like 40 removes just the lower bass components of the sound.",
4361+
:validations => [v_positive(:hpf), v_less_than(:hpf, 119)],
4362+
:modulatable => true,
4363+
:midi => true
4364+
}
43594365
}
43604366
end
43614367
end
Binary file not shown.

etc/synthdefs/designs/supercollider/sc808.scd

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -327,35 +327,48 @@ SynthDef('sonic-pi-sc808_congahi', {|
327327
}).writeDefFile("/Users/sam/Development/sonic-pi/etc/synthdefs/compiled/");
328328
)
329329

330-
330+
(
331331
SynthDef('sonic-pi-sc808_rimshot', {|
332332
note = 92,
333-
note2 = 70,
334-
amp = 1,
335-
pan = 0,
336-
cutoff_lo = 63,
337-
cutoff_hi = 118,
333+
detune = -22,
334+
amp = 1, amp_slide = 0, amp_slide_shape = 1, amp_slide_curve = 0,
335+
pan = 0, pan_slide = 0, pan_slide_shape = 1, pan_slide_curve = 0,
336+
hpf = 63, hpf_slide = 0, hpf_slide_shape = 1, hpf_slide_curve = 1,
337+
lpf = 118, lpf_slide = 0, lpf_slide_shape = 1, lpf_slide_curve = 1,
338+
decay = 0.07,
339+
decay_curve = -42,
340+
click = 1,
338341
out_bus = 0|
339342

340-
var env, sig, punch, tri1, tri2;
343+
var env, sig, punch, tri1, tri2, note2;
341344

345+
note2 = note + detune;
342346
note = note.midicps;
343347
note2 = note2.midicps;
344-
cutoff_lo = cutoff_lo.midicps;
345-
cutoff_hi = cutoff_hi.midicps;
346348

347-
env = EnvGen.kr(Env.new([1, 1, 0], [0.00272, 0.07], -42), doneAction:2);
349+
lpf = lpf.midicps;
350+
hpf = hpf.midicps;
351+
352+
amp = amp.varlag(amp_slide, amp_slide_curve, amp_slide_shape);
353+
pan = pan.varlag(pan_slide, pan_slide_curve, pan_slide_shape);
354+
hpf = hpf.varlag(hpf_slide, hpf_slide_curve, hpf_slide_shape);
355+
lpf = lpf.varlag(lpf_slide, lpf_slide_curve, lpf_slide_shape);
356+
357+
env = EnvGen.kr(Env.new([click, 1, 0], [0.00272, decay], decay_curve), doneAction:2);
348358
tri1 = LFTri.ar(note * 1.1, 1) * env;
349359
tri2 = LFPulse.ar(note2 * 1.1, width:0.8) * env;
350360
punch = WhiteNoise.ar * env * 0.46;
351361
sig = tri1 + tri2 + punch;
352362
sig = BPeakEQ.ar(sig, 464, 0.44, 8);
353-
sig = HPF.ar(sig, cutoff_lo);
354-
sig = LPF.ar(sig, cutoff_hi);
355-
sig = Pan2.ar(sig * amp, pan);
356-
Out.ar(out_bus, sig);
363+
sig = HPF.ar(sig, hpf);
364+
sig = LPF.ar(sig, lpf);
365+
sig = sig * amp;
366+
DetectSilence.ar(sig, doneAction: Done.freeSelf);
367+
Out.ar(out_bus, Pan2.ar(sig, pan));
368+
369+
}).writeDefFile("/Users/sam/Development/sonic-pi/etc/synthdefs/compiled/");
370+
)
357371

358-
}).writeDefFile("/Users/sam/Development/RPi/sonic-pi/etc/synthdefs/compiled/");
359372

360373
SynthDef('sonic-pi-sc808_claves', {|
361374

0 commit comments

Comments
 (0)