How about updating smooth values each 64th sample?

Writing this:

process = lowpass(2,fc) with{
  fc = vslider("[1] Eq1 Freq [unit:Hz] [style:knob]",
               315, 40, 20000, 1) : block(smooth(0.999)); // Note the
"block" syntax.
};


Creates something like this:


virtual void compute (int count, FAUSTFLOAT** input, FAUSTFLOAT** output) {
    float fSlow0 = (0.0010000000000000009f * fslider0);
    FAUSTFLOAT* input0 = input[0];
    FAUSTFLOAT* output0 = output[0];
    for (int i=0; i<count/64; i++) {
        fRec0[0] = (fSlow0 + (0.999f * fRec0[1]));
        float fTemp0 = tanf((fConst0 * fRec0[0]));
        float fTemp1 = (1.0f / fTemp0);
        float fTemp2 = (1 + ((1.414213562373095f + fTemp1) / fTemp0));
        for (int i2=0;i<64; i++) {
            fRec1[0] = ((float)input0[i] - (((fRec1[2] * (1 + ((fTemp1
- 1.414213562373095f) / fTemp0))) + (2 * (fRec1[1] * (1 - (1.0f /
faustpower<2>(fTemp0)))))) / fTemp2));
            output0[i] = (FAUSTFLOAT)((fRec1[2] + (fRec1[0] + (2 *
fRec1[1]))) / fTemp2);
            // post processing
            fRec1[2] = fRec1[1]; fRec1[1] = fRec1[0];
        }
        // post processing
        fRec0[1] = fRec0[0];
    }
}


On Tue, Dec 10, 2013 at 6:06 PM, Jonatan Liljedahl <[email protected]> wrote:
> On Sat, Dec 7, 2013 at 11:04 PM, Julius Smith <[email protected]> wrote:
>> Ok, I think I see it now.  No, the compiler does not commute smooth() with
>> nonlinear functions, and this is the right thing in general.  However, in
>> many cases such as this, it would be nice to have a smooth primitive that
>> *does* commute with memoryless nonlinear and/or time-varying block diagrams.
>> In other words, some new compiler primitive, perhaps "ismooth()", would be
>> moved by optimization rules to be applied after any memoryless block
>> diagrams in series with it.
>
> I think this sounds like a good idea.
>
>> In this particular case, an alternative is to make a version of tf2s using
>> the approximate bilinear-transform constant c=2*SR/w1 in place of the more
>> exact c = 1/tan(w1*0.5/SR) that preserves w1 mapping exactly (nice for
>> keeping resonators in tune when going from analog to digital).
>>
>> Of course, placing smooth() explicitly after the calculation of c as Kjetil
>> has done is also a perfectly fine solution.
>>
>> Another idea could be for the compiler to eliminate instances of smooth()
>> when it can determine that its input is constant.  That way "c =
>> 1/tan(w1*0.5/SR) : smooth(0.999)" could be used in filter.lib's definition
>> of tf2s() without adding unnecessary smoothing when w1 is constant.
>> However, this would require some kind of explicit indication that a signal
>> is constant, since only the zero signal is truly constant in Faust
>> (otherwise 1-1' would not generate an impulse at time 0).  Since we have
>> int() and float(), why not constant()?  Maybe the 'constant' primitive could
>> be defined as a block diagram having the same number of inputs as outputs,
>> and where the negative-time values of each of its input signals are defined
>> to be its value at time 0 (instead of 0 as now).  Then any smooth()
>> instances after such a "constant block diagram" can be eliminated.  If the
>> value at time zero is not fixed (e.g., there is a slider in the
>> computation), then it would reduce to bus(N) and smooth() would not be
>> eliminated.
>
> I'm not so sure, sometimes you actually don't want smoothing. It could
> be a parameter that will change rarely (like, when loading a preset)
> but that should jump directly to the new value without any lag.
>
> --
> /Jonatan
> http://kymatica.com

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Faudiostream-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/faudiostream-users

Reply via email to