This math is somewhat above my head, so I'm not able to produce a simple test
case either, right now, but at least I can try to explain the reason
behind the modifications
I did to filter.lib. I don't know if it's helpfull though.
Using the normal filter.dsp,
"
process = lowpass(2,fc) with{
fc = vslider("[1] Eq1 Freq [unit:Hz] [style:knob]",
315, 40, 20000, 1);
};
"
Faust produces:
"
virtual void compute (int count, FAUSTFLOAT** input, FAUSTFLOAT** output) {
float fSlow0 = tanf((fConst0 * fslider0));
float fSlow1 = (2 * (1 - (1.0f / faustpower<2>(fSlow0))));
float fSlow2 = (1.0f / fSlow0);
float fSlow3 = (1 + ((fSlow2 - 1.414213562373095f) / fSlow0));
float fSlow4 = (1.0f / (1 + ((1.414213562373095f + fSlow2) / fSlow0)));
FAUSTFLOAT* input0 = input[0];
FAUSTFLOAT* output0 = output[0];
for (int i=0; i<count; i++) {
fRec0[0] = ((float)input0[i] - (fSlow4 * ((fSlow3 * fRec0[2]) +
(fSlow1 * fRec0[1]))));
output0[i] = (FAUSTFLOAT)(fSlow4 * (fRec0[2] + (fRec0[0] + (2 *
fRec0[1]))));
// post processing
fRec0[2] = fRec0[1]; fRec0[1] = fRec0[0];
}
}
"
. And if we add smoothing to the slider:
"
process = lowpass(2,fc) with{
fc = vslider("[1] Eq1 Freq [unit:Hz] [style:knob]",
315, 40, 20000, 1) : smooth(0.999);
};
"
, Faust produces:
"
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; 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));
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];
fRec0[1] = fRec0[0];
}
}
"
. But by changing the definition of c in filter.tf2s from
c = 1/tan(w1*0.5/SR)
to
c = 1/tan(w1*0.5/SR) : smooth(0.999);
The (start bold text) input signal for smooth isn't any longer computed out of
any sample rated signal (end bold text), and we get this version of
compute instead:
virtual void compute (int count, FAUSTFLOAT** input, FAUSTFLOAT** output) {
float fSlow0 = (0.0010000000000000009f / tanf((fConst0 * fslider0)));
FAUSTFLOAT* input0 = input[0];
FAUSTFLOAT* output0 = output[0];
for (int i=0; i<count; i++) {
fRec0[0] = (fSlow0 + (0.999f * fRec0[1]));
float fTemp0 = (1 + (fRec0[0] * (1.414213562373095f + fRec0[0])));
fRec1[0] = ((float)input0[i] - (((fRec1[2] * (1 + (fRec0[0] *
(fRec0[0] - 1.414213562373095f)))) + (2 * (fRec1[1] * (1 -
faustpower<2>(fRec0[0]))))) / fTemp0));
output0[i] = (FAUSTFLOAT)((fRec1[2] + (fRec1[0] + (2 * fRec1[1])))
/ fTemp0);
// post processing
fRec1[2] = fRec1[1]; fRec1[1] = fRec1[0];
fRec0[1] = fRec0[0];
}
}
. This version is much faster, most likely, because the call to tanf
has been moved
out of the inner loop.
I wonder if the side effect of doing this, is that the smoothing time
depends on the lowpass
frequency... Think I remember something like that happening, but maybe
it was for a different effect.
On Thu, Dec 5, 2013 at 11:07 PM, Julius Smith <[email protected]> wrote:
> Hi All,
>
> I am having trouble reproducing this optimization problem in a simple
> isolated case. It sounds like the optimization rules do not yet always
> compute things at the control rate as far as possible in the graph.
>
> - Julius
>
>
> At 06:09 AM 12/5/2013, Jonatan Liljedahl wrote:
>>
>> Thanks, indeed that works! I went from 30% to 8% cpu usage, and no clicks.
>>
>> This seems to be a pretty common problem, I wonder if there is a way
>> to fix it except having a "smooth" version of every component?
>>
>> On Thu, Dec 5, 2013 at 2:43 PM, Kjetil Matheussen
>> <[email protected]> wrote:
>> > On Thu, Dec 5, 2013 at 2:41 PM, Kjetil Matheussen
>> > <[email protected]> wrote:
>> >> On Thu, Dec 5, 2013 at 2:26 PM, Jonatan Liljedahl <[email protected]>
>> >> wrote:
>> >>> Hi,
>> >>>
>> >>> I have a parametric EQ with lowshelf, two midbands and a highshelf,
>> >>> which gives a total of 10 parameters. In the original I get around 7%
>> >>> cpu usage. If I run each parameter slider through a smooth(0.999)
>> >>> filter, the cpu usage goes up to around 30%. That's quite a lot to
>> >>> just get rid of some subtle clicks while moving a slider.. Any ideas
>> >>> if this could be done more efficiently?
>> >>>
>> >>
>> >> Hi,
>> >>
>> >> I had the same problem in Radium over a year ago, and (if I remember
>> >> correctly),
>> >> spent some time moving the smooth calls to get them out of the inner
>> >> loop.
>> >> I don't remember exactly what I did, but I think there were some other
>> >> side effects (not clicks), although those were not a problem for
>> >> radium.
>> >> I don't remember right now what difference they made to the sound
>> >> though.
>> >
>> > Oh, I wrote it down in the file:
>> >
>> > "
>> > // Changes:
>> > // I have inserted some smooth calls here and there to make parameter
>> > changes smooth.
>> > // Just putting the smooth calls directly after slider input causes
>> > many calls to powf,
>> > // tan, cos and sqrt to be inserted into the inner DSP loop.
>> > // This version should be faster (although I don't know how much
>> > faster). -Kjetil
>> > "
>>
>>
>>
>> --
>> /Jonatan
>> http://kymatica.com
>>
>>
>> ------------------------------------------------------------------------------
>> Sponsored by Intel(R) XDK
>> Develop, test and display web and hybrid apps with a single code base.
>> Download it for free now!
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Faudiostream-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/faudiostream-users
>
>
>
> Julius O. Smith III <[email protected]>
> Professor of Music and, by courtesy, Electrical Engineering
> CCRMA, Stanford University
> http://ccrma.stanford.edu/~jos/
------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Faudiostream-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/faudiostream-users