>From https://ccrma.stanford.edu/~jos/aspf/Naming_Output_Signals.html

        Suppose you have a block diagram bd that outputs two signals, and you
        would like to give them names. You cannot simply say ``x,y = bd'' as
        you would in matlab. Instead, use the signal blocking operator `!':

                x = bd : _,!;
                y = bd : !,_;

        This does not result in two instances of bd. The optimization recognizes
        the common subexpression bd and computes it only once.

And this is what compiler/boxes/boxes.cpp:makeRecProjectionsList() does.

Unfortunately, this is not that simple when "bd" has inputs, in this case "This
does not result in two instances of bd" is not true in some sense; and that is
why letrec is buggy imo.

So, iiuc boxWithRecDef() translates this code

        process = x, y letrec {
                'x = expr_x;
                'y = expr_y;
        };

into something like

        process = x,y with {
                // buildRecursiveBodyDef()
                LETRECBODY = \(x, y).(expr_x, expr_y) ~ (_,_);
                // makeRecProjectionsList()
                x = LETRECBODY : _,!;
                y = LETRECBODY : !,_;
        };

just like the doc above suggests. However this means that

        inputs(process) == 2 * (inputs(expr_x) + inputs(expr_y))

and the halve of these inputs will be ignored. This looks wrong to me.

For example,

        process = _ : bug;

        bug = x,y letrec {
                'x = _;
                'y = 0;
        };

doesn't compile because inputs(bug) == 2.

This code

        process = _,_ : bug;

        bug = x,y letrec {
                'x = _;
                'y = 0;
        };

compiles to

        virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** 
outputs) {
                FAUSTFLOAT* input0 = inputs[0];
                FAUSTFLOAT* input1 = inputs[1];
                FAUSTFLOAT* output0 = outputs[0];
                FAUSTFLOAT* output1 = outputs[1];
                for (int i = 0; (i < count); i = (i + 1)) {
                        output0[i] = FAUSTFLOAT(float(input0[i]));
                        output1[i] = FAUSTFLOAT(0);
                }
        }

note that input1 is not used.

Oleg.



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

Reply via email to