Full SuperCollider script #
The complete Swelling Pulse Pad instrument uses stock SuperCollider units. Set ~soundStage from 1 to 4 and evaluate the entire block again to select a cumulative stage. Wait for the ready message; ~soundNote.(60, 0.8, 1) plays MIDI 60 at velocity 0.8 with a one-second held duration. Held duration controls when release begins, while each source's decay and modulation continue independently. ~soundStop.() frees the active instrument and its effects. This block replaces the previously installed PlayGrid instrument in the same interpreter.
(
~soundStage = 4;
~soundOutputScale = 1.745925;
~soundRelease = 2.4;
~soundNames = (motion: \pgSwellingPulsePadMotion, voice: \pgSwellingPulsePadVoice, effects: \pgSwellingPulsePadEffects);
~soundDefs = [
SynthDef(\pgSwellingPulsePadMotion, { |out=0| Out.kr(out, DC.kr(0)) }),
SynthDef(\pgSwellingPulsePadVoice, { |out=0, midi=60, velocity=0.8, gate=1, startMidi=60|
var stage = ~soundStage;
var aL = 0, aP0 = 0, aP1 = 0, aP2 = 0, aQ0 = 0, aQ1 = 0, aQ2 = 0, aR = 0;
var aSource = 0, aV0 = 0, aV1 = 0, aV2 = 0, iHz = 0, iVelocity = 0, kAmp = 0, kCut = 0;
var kFilter = 0, kHz = 0;
iHz = (midi).midicps;
iVelocity = (velocity).clip(0, 1);
kHz = (iHz * 0.5);
aP0 = (Pulse.ar((kHz * (2 ** ((0 - 2.4) / 1200))), 0.33) * ((0 - 6)).dbamp);
aQ0 = (Pulse.ar((kHz * (2 ** ((0 - 9.4) / 1200))), 0.36) * ((0 - 9)).dbamp);
aV0 = (aP0 + aQ0);
aP1 = (Pulse.ar((kHz * (2 ** (0 / 1200))), 0.33) * ((0 - 6)).dbamp);
aQ1 = (Pulse.ar((kHz * (2 ** ((0 - 7) / 1200))), 0.36) * ((0 - 9)).dbamp);
aV1 = (aP1 + aQ1);
aP2 = (Pulse.ar((kHz * (2 ** (2.4 / 1200))), 0.33) * ((0 - 6)).dbamp);
aQ2 = (Pulse.ar((kHz * (2 ** ((0 - 4.6) / 1200))), 0.36) * ((0 - 9)).dbamp);
aV2 = (aP2 + aQ2);
aSource = (((aV0 + aV1) + aV2) / 3);
kFilter = EnvGen.kr(Env([0, 1, 0.14, 0], [1.71, 2.37, 2.1], \lin, releaseNode: 2), gate);
kCut = ((1360 * (2 ** ((1.25 * kFilter) + ((midi - 60) / 12))))).clip(30, 18000);
aSource = MoogFF.ar(aSource, (kCut).clip(20, 18000), (0 * 4).clip(0, 3.95));
kAmp = EnvGen.kr(Env([0, 1, 1, 0], [1.95, 2.1, 2.4], \lin, releaseNode: 2), gate);
aL = (((aSource * kAmp) * ((0 - 11)).dbamp) * (0.5 + (0.5 * iVelocity)));
aR = aL;
Out.ar(out, [aL, aR]);
EnvGen.kr(Env.asr(0.0001, 1, 2.4), gate, doneAction: 2);
}),
SynthDef(\pgSwellingPulsePadEffects, { |in=0, out=0|
var stage = ~soundStage;
var outputScale = ~soundOutputScale;
var input = In.ar(in, 2);
var feedback = LocalIn.ar(4);
var aChFbL = 0, aChFbR = 0, aChInL = 0, aChInR = 0, aChMid = 0, aChSide = 0, aChTimeL = 0, aChTimeR = 0;
var aDelFbL = 0, aDelFbR = 0, aDelSendL = 0, aDelSendR = 0, aDelTimeL = 0, aDelTimeR = 0, aEchoL = 0, aEchoR = 0;
var aL = 0, aR = 0, aTapL = 0, aTapR = 0, kCh = 0, kDelCenter = 0, kDelMotion = 0;
aL = input[0];
aR = input[1];
if((stage >= 2)) {
aChFbL = feedback[0];
aChFbR = feedback[1];
aChInL = aL;
aChInR = aR;
kCh = (SinOsc.kr(0.65, 0 * 2pi) * 1);
aChTimeL = K2A.ar((7 + (13.0 * kCh)));
aChTimeR = K2A.ar((7 - (13.0 * kCh)));
aTapL = DelayC.ar((aChInL + (aChFbL * 0)), 80 / 1000, (aChTimeL / 1000).clip(0.00002, 80 / 1000));
aTapR = DelayC.ar((aChInR + (aChFbR * 0)), 80 / 1000, (aChTimeR / 1000).clip(0.00002, 80 / 1000));
aChFbL = aTapL;
aChFbR = aTapR;
aL = ((aL * 0.7) + (aTapL * 0.3));
aR = ((aR * 0.7) + (aTapR * 0.3));
aChMid = ((aL + aR) * 0.5);
aChSide = (((aL - aR) * 0.5) * 1);
aL = (aChMid + aChSide);
aR = (aChMid - aChSide);
};
if((stage >= 3)) {
aL = BLowShelf.ar(aL, 75, 1 / 0.71, (((0 - 5)).dbamp).ampdb);
aL = BPeakEQ.ar(aL, 160, 1 / 0.8, ((2).dbamp).ampdb);
aL = BPeakEQ.ar(aL, 392, 1 / 4, ((4.5).dbamp).ampdb);
aL = BPeakEQ.ar(aL, 523, 1 / 4, (((0 - 2.5)).dbamp).ampdb);
aR = BLowShelf.ar(aR, 75, 1 / 0.71, (((0 - 5)).dbamp).ampdb);
aR = BPeakEQ.ar(aR, 160, 1 / 0.8, ((2).dbamp).ampdb);
aR = BPeakEQ.ar(aR, 392, 1 / 4, ((4.5).dbamp).ampdb);
aR = BPeakEQ.ar(aR, 523, 1 / 4, (((0 - 2.5)).dbamp).ampdb);
};
if((stage >= 4)) {
aDelFbL = feedback[2];
aDelFbR = feedback[3];
kDelMotion = 0;
aDelTimeL = K2A.ar((300.0 * (1 + (0 * kDelMotion))));
aDelTimeR = K2A.ar((325.0 * (1 - (0 * kDelMotion))));
aDelSendL = aL;
aDelSendR = aR;
aEchoL = DelayC.ar((aDelSendL + (aDelFbL * 0.12)), 2200 / 1000, (aDelTimeL / 1000).clip(0.00002, 2200 / 1000));
aEchoR = DelayC.ar((aDelSendR + (aDelFbR * 0.12)), 2200 / 1000, (aDelTimeR / 1000).clip(0.00002, 2200 / 1000));
kDelCenter = (900 * (2 ** (0 * kDelMotion)));
aEchoL = HPF.ar(aEchoL, ((kDelCenter / (2 ** 2.5))).clip(20, 18000));
aEchoL = LPF.ar(aEchoL, ((18000).min((kDelCenter * (2 ** 2.5)))).clip(20, 18000));
aEchoR = HPF.ar(aEchoR, ((kDelCenter / (2 ** 2.5))).clip(20, 18000));
aEchoR = LPF.ar(aEchoR, ((18000).min((kDelCenter * (2 ** 2.5)))).clip(20, 18000));
aDelFbL = aEchoL;
aDelFbR = aEchoR;
aL = ((aL * 0.86) + (aEchoL * 0.14));
aR = ((aR * 0.86) + (aEchoR * 0.14));
};
LocalOut.ar([aChFbL, aChFbR, aDelFbL, aDelFbR].collect { |channel| channel + DC.ar(0) });
Out.ar(out, [((aL * 1) * outputScale), ((aR * 1) * outputScale)]);
})
];
~soundStop = {
if(~cirrusGroup.notNil) { ~cirrusGroup.free; ~cirrusGroup = nil };
if(~cirrusAudio.notNil) { ~cirrusAudio.free; ~cirrusAudio = nil };
if(~cirrusMotion.notNil) { ~cirrusMotion.free; ~cirrusMotion = nil };
if(~pgGroup.notNil) { ~pgGroup.free; ~pgGroup = nil };
if(~pgAudio.notNil) { ~pgAudio.free; ~pgAudio = nil };
if(~pgMotion.notNil) { ~pgMotion.free; ~pgMotion = nil };
};
~soundInstall = {
s.waitForBoot {
~soundStop.();
~soundDefs.do { |definition| definition.add };
s.sync;
~pgAudio = Bus.audio(s, 2);
~pgMotion = Bus.control(s, 1);
~pgGroup = Group.head(s);
~pgLastMidi = 60;
Synth.head(~pgGroup, ~soundNames.motion, [\out, ~pgMotion]);
~pgVoices = Group.tail(~pgGroup);
Synth.tail(~pgGroup, ~soundNames.effects, [\in, ~pgAudio]);
"Swelling Pulse Pad ready".postln;
};
};
~soundNote = { |midi=60, velocity=0.8, hold=1|
var note = Synth.head(~pgVoices, ~soundNames.voice, [
\out, ~pgAudio, \midi, midi, \velocity, velocity.clip(0, 1),
\startMidi, ~pgLastMidi
]);
~pgLastMidi = midi;
SystemClock.sched(hold, { note.set(\gate, 0); nil });
note;
};
if(~soundOffline != true) { ~soundInstall.() };
)