Cheers Dizzy will take a look at this, this afternoon, sure has helped. I
need a break from reading up about QT. Im glad you suggested that custom
widget, because it has got me learning about QT, a skill that is probably
essential if im to contribute more to lmms.

My initial thoughts was to have selectable filter types per band so a few
different lp, bell, notch , shelf hp  filters types, selectable by the
user, but im not sure that it benefits the user, as it can be more of a
distraction, I also feel using lmms-stock filters makes it sound more lmms,
if that makes sense. Do you have any thoughts on this?


On 30 November 2014 at 13:05, Vesa <dii....@nbl.fi> wrote:

> On 11/30/2014 12:39 AM, Vesa wrote:
> > On 11/30/2014 12:24 AM, Dave French wrote:
> >> You want me pull to code into a class?
> > No, I can do that...
>
> Ok, it is now done (in master branch).
>
> BasicFilters.h now contains the class BiQuad<ch_cnt_t channels>, where
> ch_cnt_t is a typedef for int that signifies channel count. There's also
> a convenience typedef StereoBiQuad which resolves to BiQuad<2>. That's
> likely what you'll want to use (unless you want your EQ to have separate
> controls for each channel, but I personally find that fairly pointless
> in an EQ...)
>
> To use a StereoBiQuad, #include "BasicFilters.h" and simply construct
> your filter like thus:
>
>     StereoBiQuad sbq = StereoBiQuad();
>     StereoBiQuad * psbq = new StereoBiQuad();
>
> To set coefficients:
>
>     sbq.setCoeffs( a1, a2, b0, b1, b2 );
>
> Both channels will use the same coeffs.
>
> To run the filter for one sampleframe, you have to call each channel
> separately:
>     sampleFrame src, dst;
>     dst[0] = sbq.update( src[0], 0 );
>     dst[1] = sbq.update( src[1], 1 );
>
> Now as for calculating coefficients, I'll leave that up to you, but
> here's a decent-looking algorithm for calculating peak filter coeffs
> that I found, adapted for LMMS:
>
> // peak filter coefficients:
>
>         // input values (all should be floats):
>         // Fc = center freq
>         // Fs = sample rate
>         // Q = Q/resonance
>         // peakGain = peak gain in dBV
>
>         float a1, a2, b0, b1, b2; // coeffs to calculate
>
>         const float V = dbvToAmp( qAbs( peakGain ) ); // convert dBV to
> absolute linear amp
>         const float K = tanf( F_PI * Fc / Fs );
>         const float norm = 1 / (1 + V/Q * K + K * K);
>
>         if ( peakGain >= 0.0f ) // >=0dBV gain
>         {
>                 b0 = (1 + V/Q * K + K * K) * norm;
>                 b1 = 2 * (K * K - 1) * norm;
>                 b2 = (1 - V/Q * K + K * K) * norm;
>                 a1 = b1;
>                 a2 = (1 - 1/Q * K + K * K) * norm;
>         }
>         else // negative gain
>         {
>                 b0 = (1 + 1/Q * K + K * K) * norm;
>                 b1 = 2 * (K * K - 1) * norm;
>                 b2 = (1 - 1/Q * K + K * K) * norm;
>                 a1 = b1;
>                 a2 = (1 - V/Q * K + K * K) * norm;
>         }
>
>
> Let me know if you need shelf filters as well. Or you can just use your
> own algorithms, if you find better/faster ones...
>
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
>
> http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
> _______________________________________________
> LMMS-devel mailing list
> LMMS-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lmms-devel
>
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
LMMS-devel mailing list
LMMS-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lmms-devel

Reply via email to