On 06/15, Dario Sanfilippo wrote:
>
> quad_osc(f) = tick ~ (_ , _)
> with {
>   init = 1-1';
> w = 2*ma.PI*f/ma.SR;
>     k1 = tan(.5*w);
>     k2 = 2*k1/(1+k1*k1);
> tick(u, v) = omega-k1*(v+k2*omega) , v+k2*omega
> with {
>   omega = (u+init)-k1*v;
> };
> };

another case when we need to initialize the delay line ;)

Dario, it is not that I suggest to change this code, please ignore,
but just for record... note that in this case we can avoid this hack
and write

        quadosc(f) = tick ~ (_,_) : +(1),_ with {
                k1 = tan(f * ma.PI/ma.SR);
                k2 = 2*k1 / (1 + k1 * k1);

                tick(u_0,v_0) = u_1,v_1 with {
                        tmp = u_0 - k1 *  v_0;
                        v_1 = v_0 + k2 * (tmp + 1);
                        u_1 = tmp - k1 *  v_1;
                };
        };

This generates a slightly better code. And, this allows to add (mem,mem)

        quadosc(f) = tick ~ (_,_) : mem+1,mem with {
                k1 = tan(f * ma.PI/ma.SR);
                k2 = 2*k1 / (1 + k1 * k1);

                tick(u_0,v_0) = u_1,v_1 with {
                        tmp = u_0 - k1 *  v_0;
                        v_1 = v_0 + k2 * (tmp + 1);
                        u_1 = tmp - k1 *  v_1;
                };
        };

to ensure that it always ouputs (1,0) at the very first tick. Not that I
think this is very important, but this matches other oscillators and looks
more clean imo.

Oleg.



_______________________________________________
Faudiostream-users mailing list
Faudiostream-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/faudiostream-users

Reply via email to