I wanted to make something a bit like rand~ in msp or randi in csound. Linearly
interpolated random function at a specified frequency. See code below for what
i came up with.
It seems what i made is a bit wasteful since the random number element appears
to be calculated per sample, when we only need random numbers once per “period”
of the clocked noise
is there a more efficient way to do this in faust?
thanks
oli
// randi.dsp
import("music.lib");
import("maxmsp.lib");
import("oscillator.lib");
rand(f) = sah(trigger, noise)
with {
sah(t, x) = select2(t, _, x) ~ _;
trigger = lf_imptrain(f);
};
randi(f) = line(rand(f), 1000/f);
process(f)=randi(f);
// generated c++
virtual void compute (int count, FAUSTFLOAT** input, FAUSTFLOAT** output) {
FAUSTFLOAT* input0 = input[0];
FAUSTFLOAT* output0 = output[0];
for (int i=0; i<count; i++) {
float fTemp0 = (float)input0[i];
fRec3[0] = fmodf((1.0f + fRec3[1]),(fConst1 / fTemp0));
float fTemp1 = (fTemp0 * fRec3[0]);
fVec0[0] = fTemp1;
iRec4[0] = (12345 + (1103515245 * iRec4[1]));
fRec2[0] = ((int(((fConst2 * (fVec0[0] - fVec0[1])) <
0)))?(4.656612875245797e-10f * iRec4[0]):fRec2[1]);
float fTemp2 = ((int((fRec2[0] !=
fRec2[1])))?(float(iConst0) / fTemp0):(fRec0[1] - 1));
fRec0[0] = fTemp2;
fRec1[0] = ((int((fTemp2 <= 0)))?fRec2[0]:(fRec1[1] +
((fRec2[0] - fRec1[1]) / fTemp2)));
output0[i] = (FAUSTFLOAT)fRec1[0];
// post processing
fRec1[1] = fRec1[0];
fRec0[1] = fRec0[0];
fRec2[1] = fRec2[0];
iRec4[1] = iRec4[0];
fVec0[1] = fVec0[0];
fRec3[1] = fRec3[0];
}
}
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
Faudiostream-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/faudiostream-users