On 02/01, Romain Michon wrote:
>
> We're working on a better solution,
Yes, it would be nice to have the ability to initialize delay lines.
And reset/re-initialize too, think of goertzel() from analyzers.lib.
> initState((init)) = R(0,init)
> with{
> R(n,(initn,init)) = +(initn : ba.impulsify@n) : R(n+1,init);
> R(n,initn) = +(initn : ba.impulsify@n);
> };
>
> osc(m,k,z,x0,x1) = equation
> with{
> A = 2 - (k + z)/m;
> B = z/m - 1;
> C = 1/m;
> equation = x
> letrec{
> 'x = A*(x : initState(x0)) + B*(x' : initState(x1)) + *(C);
Hmm. I don't understand ...
Consider osc(m,k,z, 100, 200). At the first "tick" everything looks correct,
(x : initState(x0)) == 100
(x' : initState(x1)) == 200
but at the 2nd tick (x' : initState(x1)) will be zero, not 100?
Shouldn't osc() use B*(x' : initState((x1,x0))) instead ?
-------------------------------------------------------------------------------
can't resist... this could be trivially implemented in fpp. But since attach()
is broken, zinit() below has some nasty limitations.
So,
zinit(z) = _ <: +(zinit(z)) with {
zinit = FPP(z{}, x[outputs(z)]) eval int {
init: $z.for(i, v, $x[i + 1] = v);
exec: 0;
};
};
simply initializes the signal's delay line. Now, osc() can be implemented as
osc(m,k,z,x0,x1) = equation : zinit((x0,x1)) with {
A = 2-(k+z)/m;
B = z/m-1;
C = 1/m;
equation = x letrec {
'x = A*x + B*x' + *(C);
};
};
Say,
process = osc(10,3,2, 100,200);
compiles to
virtual void instanceConstants(int samplingFreq) {
fSamplingFreq = samplingFreq;
fRec0[1] = 100; fRec0[2] = 200;
}
virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT**
outputs) {
FAUSTFLOAT* input0 = inputs[0];
FAUSTFLOAT* output0 = outputs[0];
for (int i = 0; (i < count); i = (i + 1)) {
fRec0[0] = (((1.5f * fRec0[1]) + (0.100000001f *
float(input0[i]))) - (0.800000012f * fRec0[2]));
output0[i] = FAUSTFLOAT((fRec0[0] + 0));
fRec0[2] = fRec0[1];
fRec0[1] = fRec0[0];
}
}
as you can see the run-time code is not penalized, zinit() does
fRec0[1] = 100; fRec0[2] = 200;
at startup time.
Oleg.
_______________________________________________
Faudiostream-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/faudiostream-users