Hello there! I am new here and need help for a supercollider class project:
I am writing a tool consisting of multiple loop pedal style recorders, each going through a different effect.
The recorders are based off the Eli Fieldstell Tutorial : Live Recording & Looping in week 4 of his intermidiate supercollider course. I think I have a good understanding of the code and my loopers work as expected. However, a problem comes up when I try to use his method of using a Sweep to set a maximum for a Phasor through a dedicated Bus. It works fine for the loopers, but when I try to use this same Bus to send the max point to a UGen within a synthDef containing GrainBuf, indicating the pos of the GrainBuf, it doesn’t seem to pick up the value.
I am struggling to understand why this is, especially since the method is very similar to the working one. My GrainBuf SynthDef Nodes are correctly placed ahead of the Sweep Nodes.
Code for the Looper:
SynthDef(\sweep, {
var sig, trigSig;
trigSig = In.ar(\inTrig.ir(0), 1); //entrée du trig bus
sig = Sweep.ar(\trig.tr(0) + trigSig, SampleRate.ir * \run.kr(1));
Out.ar(\out.ir(0), sig);
}).add;
//ptr suit le sweep et lorsque sweep est arrêté, place le maximum du phasor à la valuer du sweep (la grosseur de la boucle)
SynthDef(\ptr, {
var sig, max, trigSig;
trigSig = In.ar(\inTrig.ir(0), 1);
max = In.ar(\inMax.ir(0), 1);
sig = Phasor.ar(\trig.tr(0) + trigSig, 1, 0, max, 0);
Out.ar(\out.ir(0), sig);
}).add;
Code for my own Synthdef
SynthDef(\granSynth,{
arg grFreq, trigRandomness, dur, durMod, rate, rateMod, pan, panSpread, amp, ptrRate, ptrMod, scrub;
var sig, max;
max = In.ar(\inMax.ir(0), 1);
trigSig = In.ar(\inTrig.ir(0), 1);
grFreq = grFreq.linexp(0.0, 1.0, 1, 500);
dur = dur.linexp(0.0, 1.0, 0.01, 2);
durMod = durMod.bilin(0.5, 0.0, 1.0, 0.2, 0, 2 );
rate = rate.linexp(0.0, 1.0, 0.25, 4);
rateMod = rateMod.linexp(0.0, 1.0, 1, 4);
ptrRate = ptrRate.linlin(0.0, 1.0, 1, 2);
ptrMod = ptrMod.linlin(0.0, 1.0, 0, max);
scrub = scrub.linlin(0.0, 1.0, 0, max) ;
trig = CoinGate.ar((1 - trigRandomness), Impulse.ar(grFreq)) + Dust.ar(trigRandomness * grFreq);
sig = GrainBuf.ar(
numChannels: 2,
trigger: trig,
dur: dur + TRand.ar(-1.0 * durMod, durMod, trig),
sndbuf: \bufnum.ir(0),
rate: rate * TRand.ar(1.0 / rateMod, rateMod, trig) * BufRateScale.kr(\bufnum.ir(0)),
pos: Fold.ar(scrub + TRand.ar(-1.0 * ptrMod, ptrMod, trig), 0.0 , max), //-->> NOT WORKING**
interp: 4,
pan: Fold.ar((pan + TRand.ar(-1panSpread, panSpread, trig))), //voir commentaire de pos
envbufnum: -1,
maxGrains: 1024,
);
sig = sig amp.varlag(\ampLag.kr(5), -2) * \playButton.kr(0); //all effects must end with this to enable play/mute functionality
Out.ar(\out.ir(0), sig);
}).add;