Hi all!
I’m using Dseries and Demand in a synthdef i’m doing, but i don’t know how to deal with multichannel expansion on those cases. I’m also still a bit dumb with arrays in SC.
Can someone point me into the right direction for this synthdef to be able to have different pitches, one per channel, and Dseries and Demand act accordingly?
this is my “full” not working code:
(
SynthDef(\stutter13,{
arg in=0, out=0;
var insig, sig, delayTime, increment, trigger;
var reset=\reset.kr(0);
var delayPitch=\pitch.kr(12!13); //this is basically what doesn't work!!!
var offsetms=\offsetms.kr(0)/1000;
var gatepw=\gatepw.kr(1);
var on=\onoff.kr(0);
var envGen, sustainTime;
var atkTime=0.002, relTime=0.002;
reset=reset*on;
// Convert pitch to delay time in seconds
delayTime = delayPitch.midicps.reciprocal;
// Trigger for incrementing delay time
trigger = Impulse.ar(delayTime.reciprocal);
// Calculate sustain time to ensure envelope stays high for the chunk duration minus attack and release
sustainTime = delayTime - (atkTime + relTime);
// Ensure sustainTime is not negative
sustainTime = max(sustainTime, 0)*gatepw;
// Increment delay time
//This is the part where the multichannel expanded "delayTime" variable doesnt unfold properly.
//How to deal with this?
increment = Dseries(0, delayTime, inf)*on;
increment = Demand.ar(trigger, reset, increment);
// Generate an envelope to soften clicks
envGen = EnvGen.ar(Env([0, 1, 1, 0], [atkTime, sustainTime, relTime], 'lin'), trigger);
// Get input signal
insig = In.ar(in, 13); // Assuming stereo input
// Apply delay
sig = DelayC.ar(insig, 24, increment+offsetms);
// Apply envGen
sig=sig*envGen;
sig=(sig*on)+(insig*(1-on));
// Output
Out.ar(out, sig);
}).writeDefFile(d);
)
And this is the exact part which seems is not unfolding the multichannel expanded “delayTime” variable properly, giving as a result a single channel result for the “increment” variable:
increment = Dseries(0, delayTime, inf)*on;
increment = Demand.ar(trigger, reset, increment);
How should i deal with this?