Hello, NOTE: the code examples below use fconstant's just to make the generated code more readable, any compile-time constant like ma.SR lead to the same problem.
------------------------------------------------------------------------------ Lets start with the trivial example: a = fconstant(float a, ""); b = fconstant(float b, ""); c = a / b; process = *(c); compiles to virtual void instanceConstants(int sample_rate) { fSampleRate = sample_rate; fConst0 = a / b; } virtual void compute(int count, FAUSTFLOAT** RESTRICT inputs, FAUSTFLOAT** RESTRICT outputs) { FAUSTFLOAT* input0 = inputs[0]; FAUSTFLOAT* output0 = outputs[0]; for (int i0 = 0; i0 < count; i0 = i0 + 1) { output0[i0] = FAUSTFLOAT(fConst0 * float(input0[i0])); } } Good. Now lets use ffunction() with ffarity() > 0 a = fconstant(float a, ""); b = fconstant(float b, ""); c = a / b; f1 = ffunction(float f1(float), "",""); process = f1 : *(c); the generated code virtual void instanceConstants(int sample_rate) { fSampleRate = sample_rate; fConst0 = a / b; } virtual void compute(int count, FAUSTFLOAT** RESTRICT inputs, FAUSTFLOAT** RESTRICT outputs) { FAUSTFLOAT* input0 = inputs[0]; FAUSTFLOAT* output0 = outputs[0]; for (int i0 = 0; i0 < count; i0 = i0 + 1) { output0[i0] = FAUSTFLOAT(fConst0 * f1(float(input0[i0]))); } } looks good too. However, if ffarity() == 0 a = fconstant(float a, ""); b = fconstant(float b, ""); c = a / b; f0 = ffunction(float f0(), "",""); process = f0 : *(c); then "a / b" is calculated at run time: virtual void instanceConstants(int sample_rate) { fSampleRate = sample_rate; } virtual void compute(int count, FAUSTFLOAT** RESTRICT inputs, FAUSTFLOAT** RESTRICT outputs) { FAUSTFLOAT* output0 = outputs[0]; for (int i0 = 0; i0 < count; i0 = i0 + 1) { output0[i0] = FAUSTFLOAT(f0() * a / b); } } and this looks like performance bug to me. ------------------------------------------------------------------------------ More examples just in case, a = fconstant(float a, ""); b = fconstant(float b, ""); c = a * b; f0 = ffunction(float f0(), "",""); process = f0 : *(c); demonstrates the same problem: output0[i0] = FAUSTFLOAT(f0() * b * a); however, process = f0 * c; // should be equivalent to f0 : *(c) compiles to fConst0 = b * a; ... output0[i0] = FAUSTFLOAT(fConst0 * f0()); ------------------------------------------------------------------------------ Same problem with aterm's, c = a + b; f0 = ffunction(float f0(), "",""); process = f0 : +(c); ---> output0[i0] = FAUSTFLOAT(a + f0() + b); while "process = f0 + c" works correctly. Oleg. _______________________________________________ Faudiostream-devel mailing list Faudiostream-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-devel