Hi there, I was diving in the Faust mailing lists when I stumbled upon an example using the enable() function: gen(N) = par(i, N, os.osc(200*(i+1)) : enable(hslider("oscillators",0,0,N,1) : int : >(i))) :> _ <: _,_; process = gen(5);
I wasn't able to find the documentation of enable() and I'm not entirely sure of what it does but I took a look at the C++ code produced. virtual void compute(int count, FAUSTFLOAT** RESTRICT inputs, FAUSTFLOAT** RESTRICT outputs) { FAUSTFLOAT* output0 = outputs[0]; FAUSTFLOAT* output1 = outputs[1]; int iSlow0 = int(float(fHslider0)); float fSlow1 = float((iSlow0 > 0)); int iSlow2 = (fSlow1 != 0.0f); This test seems to be the enable condition in the 1st branch of the par iteration float fTemp0 = fTempPerm0; float fSlow3 = float((iSlow0 > 1)); This test seems to be the enable condition in the 2nd branch of the par int iSlow4 = (fSlow3 != 0.0f); float fTemp1 = fTempPerm1; for (int i0 = 0; (i0 < count); i0 = (i0 + 1)) { if (iSlow2) { This code isn't executed when iSlow2 is false avoiding unnecessary computation relative to the oscillator fRec1[0] = (fConst1 + (fRec1[1] - std::floor((fConst1 + fRec1[1])))); fConst1 equals 200 which is the frequency of the first oscillator fTemp0 = (fSlow1 * ftbl0mydspSIG0[int((65536.0f * fRec1[0]))]); } if (iSlow4) { And here the same for the second enable condition fRec2[0] = (fConst2 + (fRec2[1] - std::floor((fConst2 + fRec2[1])))); fConst2 equals 400 fTemp1 = (fSlow3 * ftbl0mydspSIG0[int((65536.0f * fRec2[0]))]); } float fTemp2 = (fTemp0 + fTemp1); output0[i0] = FAUSTFLOAT(fTemp2); output1[i0] = FAUSTFLOAT(fTemp2); Not sure what the 2 following ifs do (buffer swapping?) if (iSlow2) { fRec1[1] = fRec1[0]; } if (iSlow4) { fRec2[1] = fRec2[0]; } } fTempPerm0 = fTemp0; fTempPerm1 = fTemp1; } So the enable() function (I should say primitive btw) seems to avoid unnecessary computation when it is disabled. Am I right? Best regards, jlp
_______________________________________________ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users