Am 04.12.18 um 18:41 schrieb Joshua Peschke:
i noticed for example that the smoothing of parameters seems to affect 
performance quite much (if there are lots of them..). do you have any 
suggestions on how to minimise this? any hints are very much appreciated!


Hi

some care needs to be taking when you smooth parameters. Smoothing itself isn't really expensive, but in combination with, for example db2linear it could make things worse.

Let's have a look at the generated code, when we use (from the examples)

gain        = vslider("[1]", 0, -70, +4, 0.1) : ba.db2linear : si.smoo;

we get a loop like this:

virtual void compute (int count, FAUSTFLOAT** input, FAUSTFLOAT** output) {
        float     fSlow0 = (0.001f * powf(10,(0.05f * float(fslider0)))); // powf called for db2linear once for each callback
        FAUSTFLOAT* input0 = input[0];
        FAUSTFLOAT* output0 = output[0];
        for (int i=0; i<count; i++) {
            fRec0[0] = (fSlow0 + (0.999f * fRec0[1])); // <- parameter smoothing
            output0[i] = (FAUSTFLOAT)((float)input0[i] * fRec0[0]);
            // post processing
            fRec0[1] = fRec0[0]; // <- parameter smoothing
        }
    }

parameter smoothing is 1 addition and one multiplication and one "memmove", for each sample.

now, when you use it like this:

gain        = vslider("[1]", 0, -70, +4, 0.1) : si.smoo : ba.db2linear;

we get a loop like this:

virtual void compute (int count, FAUSTFLOAT** input, FAUSTFLOAT** output) {
        float     fSlow0 = (0.001f * float(fslider0));
        FAUSTFLOAT* input0 = input[0];
        FAUSTFLOAT* output0 = output[0];
        for (int i=0; i<count; i++) {
            fRec0[0] = (fSlow0 + (0.999f * fRec0[1])); // <- parameter smoothing             output0[i] = (FAUSTFLOAT)((float)input0[i] * powf(10,(0.05f * fRec0[0]))); // additional powf call in inner loop
            // post processing
            fRec0[1] = fRec0[0]; // <- parameter smoothing
        }
    }

Parameter smoothing use the same resources as in the example above, but we've now the pow call in the inner loop, means it will be called for any sample, instead like in the above loop, once at any callback.





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

Reply via email to