SynthMaker

RIAA EQ Filter - possible w/ SM?

Archive · 2006 14 old posts

From the original SynthMaker forum (2004–2014), with its members’ names and dates.

juha_p ·

Hi!

I'm looking after possibilities to build a standalone RIAA EQ, to get rid of need for use some VST host/EQ plugin to do the RIAA EQ compensation (I've connected the turntable through 'flat' pre-amp into soundcard). Atm, I'm using "Slim Slow Sliders Linear Phase Graphics EQ 2", which btw gives quite good results (curve measured w/ Voxengo SPAN).

My goal would be - as accurate as possible stdandard and IEC RIAA compensation curves - select from least those two RIAA type options - capability to be working 24-bit/96-192 kHz 'resolution'

After couple of hours running the SM trial (incl. tried all EQ examples here), I've got a feeling, SM can be used on this, but in which way?

I've found some mathematical equations for some calculations but I don't know if I need these w/ SM or which are the best/easiest way to use them w/ SM and how?

Here are two links for math and other recources: http://www.musicdsp.org/archive.php?classid=3#122 http://www.euronet.nl/~mgw/download/uk_index_body.html#spreadsheets http://www.euronet.nl/~mgw/background/riaa/uk_riaa_background_1.html

Some guidance would be appreciated.

Juha

oddson ·

Hi and welcome... I was leaving this for someone who knows DSP better than I do to answer... but I'll let you know what I know for now.

Standalone RIAA EQ - possible w/ SM? / is math needed?

Possible? Yes. Is math needed? Absolutely.

One year ago all I knew about DSP is what the letters stand for... now I could almost get you what you need from that first post you've provided.

One issue though is the sample rate you've indicated. I don't even know if SM supports 192kHz... but I do know the coeficients given in that first link don't include that rate. But I also notice the filter you're using doesn't either so I think SM and that link will get you to at least 96kHz.

It looks to me like these are biquad coefficients. If so, you can use the Biquad module in SM (recently renamed in 0.9.5y from Low Pass Filter to Biquad Filter). If not someone who understands these thinks better than I do could write code to handle the reverse filter.

Hopefully someone better versed in the subject will respond for you...

One question though... why wouldn't you use an inverse RIAA filter in hardware before you bring signal into the digital domain? I don't think there's any great advantage to going digital for this step...

juha_p ·

oddson wrote:

...

...

...

One issue though is the sample rate you've indicated. I don't even know if SM supports 192kHz... but I do know the coeficients given in that first link don't include that rate. But I also notice the filter you're using doesn't either so I think SM and that link will get you to at least 96kHz.

...

Hopefully someone better versed in the subject will respond for you...

One question though... why wouldn't you use an inverse RIAA filter in hardware before you bring signal into the digital domain? I don't think there's any great advantage to going digital for this step...

Thanks for the reply.

I hate math ... but, would it be possible to calculate using just one instance of formula and not for every certain selected frequencies (as it's needed w/ Linear Phase EQ and those others I tried) when adjusting gains on those selected frequencies (btw, Elevayta FreEq Boy would have been the only EQ letting you define frequencies/gains freely (data would have been there on those excel tables from one of my prev. links) and load those settings from a text file (max 2048 bands), but ... wasn't sure on the quality (demo didn't let to test this))?

Also, 24-bit/96 kHz is good enough resolution for me (for ripping/listening). Well, I managed already to try w/ 24-bit/192 kHz and ... so it would be nice to have this SR for realtime listening (24-bit/192 kHz takes too much space from HD).

Why this method ... well, I did read this article and ofcource since being curious, tried the method (DIYed a HQ 'flat' pre-amp, tried w/ all possible EQ plugins available, ...) --> results (using 24-bit/ 96 kHz), I already can get, are (i.e. sounds) better than what I can get from my Hi-Fi stereo pre-amp w/ RIAA stage (by the manual, the RIAA stage is not very good). I've compared side-by-side using both methods and the original method just leaves something hidden.

Juha

oddson ·

Thanks for the link... I've never been a real audiophile my old amp had a good enough inverse RIAA preamp.

As I understand it digital filters aren't exact either and the guy who figured the coefs admits he has no idea what impact they will have on the phase and makes no claims on the overall accuracy.

If you're going for as 'exact as possible' I think you'll need to learn a whole lot about DSP first.

Do any of the experts here have anything to say on this?

juha_p ·

oddson wrote: Thanks for the link... I've never been a real audiophile my old amp had a good enough inverse RIAA preamp.

As I understand it digital filters aren't exact either and the guy who figured the coefs admits he has no idea what impact they will have on the phase and makes no claims on the overall accuracy.

If you're going for as 'exact as possible' I think you'll need to learn a whole lot about DSP first.

Do any of the experts here have anything to say on this?

Seems, here are no experts on this area I'm after, but no matter --> I'll leave this EQ 'pre-project' w/ SynthMaker, because of, I found an excellent EQ, which by the measures I've made, gives real accurate results and works @ 24-bit/ 192 kHz too.

Juha

juha_p ·

Actually this RIAA EQ (32kHz-192kHz) was not very hard to prepare using Matlab, Delphi+VST+ASIO SDKs.

I think it's possible to do the final VST plug-in/standalone Filter using SynthMaker too but, ... if someone here could try this since, I don't have SM other than a demo available and it seems not include all needed features so I could try this by myself.

Here's the code version (hope it's 100% suitable for SM):

// RIAA EQ Reproduction Filter for 48kHz data monoin inL; monoin inR; monoout outL; monoout outR;

float a0, a1, a2; float b0, b1, b2; float inL1, inL2, inR1, inR2; float outL1, outL2, outR1, outR2;

a0= 1.00000000000000000; // never needed a1=-1.73276550000000020; a2= 0.73455344362250008; b0= 1.00000000000000000; b1=-0.75555209999999995; b2=-0.16462571129709999;

// Proces left channel outL = b0*inL + b1*inL1 + b2*inL2 - a1*outL1 - a2*outL2;

// Process right channel outR = b0*inR + b1*inR1 + b2*inR2 - a1*outR1 - a2*outR2;

// save previous I/Os outL2 = outL1; outL1 = outL; inL2 = inL1; inL1 = inL;

outR2 = outR1; outR1 = outR; inR2 = inR1; inR1 = inR;

I suppose this above functionality can be done w/ SM's biquad component too: - biguad component for left and right channels - float elements for coefficients a0, a1, a2, b1 and b2 - swap a and b coefficients given in my code - etc.

maybe something like this drawing shows out:

Both above 'code' should produce a RIAA reproduction filter for 48kHz data (ONLY), which has RIAA curve error of ~0.14dB and phase error of ~+-24� (both in range 0Hz - 20kHz) but, this accuracy is dependent on how SM handles those original coefficients (does it round them).

Juha

sunsynth ·

Hi JUHA,

good 2 know you are working on it!

TIP: do you see the DEVELOPER-Button right of the Toolbox-Search- Field???

Highlight it and... voila you can check your ideas!!!

Let us know if this works 4 you!

cu, SUNSynth

juha_p ·

sunsynth wrote: Hi JUHA,

good 2 know you are working on it!

TIP: do you see the DEVELOPER-Button right of the Toolbox-Search- Field???

Highlight it and... voila you can check your ideas!!!

Let us know if this works 4 you!

cu, SUNSynth

Thanks for the tip!!

Besides the Delphi version which I made (it's working excellently as standalone and VST), I have got the filter working using CPS (btw, they updated CPS recently to v. 1.5 ... no MS Java VM needed anymore) and with Cycling74 Max/MSP (Trial/Runtime) already so, I suppose it'll work using SM too right away (least when using those ready-made components but supposeingly as coded too).

Actually, it's not a need for me to get the filter working as a SM version (I just wanted to publish this filter here as an example) but, I'll re-check the SM Trial next weekend and see if everything works as I assumed.

I think SM could be suitable enviroment for to finish this project as commercial version but, as the final standalone/VST filter is not goin' to be a commercial product (I just give some versions away), the price tag SM has is too high to get SM for this purpose only.

Juha

juha_p ·

Hmmm... tried w/ the Trial version ... otherwise seemed to work OK but:

Why SM gives worse (Harmonic Distortion) results from same data (no, it's not captured a that moment when hissing sound appears)?

Does the SM round what's given as input (I used 17 decimal accurate coefficients as input in both implementation)?

Juha

infuzion ·

juha_p wrote: Does the SM round what's given as input (I used 17 decimal accurate coefficients as input in both implementation)?

I don't know; I'd like to know also.

I'm wondering if since SM uses 32bit SSE for audio, & perhaps your compiler uses 80bit floats, would make a difference?

juha_p ·

infuzion wrote:

I don't know; I'd like to know also.

I'm wondering if since SM uses 32bit SSE for audio, & perhaps your compiler uses 80bit floats, would make a difference?

For above comparison, I used single precision output and double precision internal calculation for Delphi. Single is equal w/ the Float in accuracy so all differences must come from internal calculations and roundings (see below) done in SM iplementation.

In SM, the assembly listing got by connecting a Text component into code component shows data become rounded from 17 decimal accuracy to 0 or more decimals accuracy (max 6 'meaningful' numbers).

If the value in SM is set to 1.00000000893526 it is rounded to 1 1.00000500893526 becomes 1.00001 etc.

so, I suppose this is the reason for worse results got w/ SM. Maybe I'll plot the magnitude data as numbers (dB) for both and compare the 'error' coming from that rounding.

I'm running both enviroments in a PC w/ P4 procesor. In Delphi, I have set coefficient data type to double. I'll try to find info for the compiler (Delpihi is 'new' to me (well, I did use D2 in some project long time ago), so I have not looked this type matters since there is much more needed to do with it ... ).

Juha

EDIT: Checked the possible rounding effect in SM using two 44.1kHz RIAA filters, one made using Delphi (all internal calculations using double ... output data format was single precision) and the other SM 1.04 Trial (all calculations using float data types) ... there is max -0.002dB difference @ lowest frequencies when 0dB @ 1kHz is adjusted as close as ~-0.000005dB from each other. Difference @ higher frequencies is normally around -0.00004dB. So it seems like the datatype/roundings has meaningful effect for Harmonic Distortion only.

infuzion ·

juha_p wrote: In Delphi, I have set coefficient data type to double.

"It supports approximately 15 digits of precision in a range from 2.23 x 10-308 to 1.79 x 10308." http://www.delphibasics.co.uk/RTL.asp?Name=Double

Hmmm... there are ASM commands to switch the rounding type, commands not available in SM right now.

edit: Good sleuthing juha by the way, with your graphs & all!

juha_p ·

FYI, here are some filter coefficients for biquad implementation of

44.1kHz: a0= 1.0000000000 a1=-1.7007240000 a2= 0.7029381524 b0= 1.0000000000 b1=-0.7218922000 b2=-0.1860520545

48kHz: a0= 1.0000000000 a1=-1.7327655000 a2= 0.7345534436 b0= 1.0000000000 b1=-0.7555521000 b2=-0.1646257113

88.2kHz: a0= 1.0000000000 a1=-1.8554648000 a2= 0.8559721393 b0= 1.0000000000 b1=-0.8479577000 b2=-0.1127631993

and 96kHz: a0= 1.0000000000 a1=-1.8666083000 a2= 0.8670382873 b0= 1.0000000000 b1=-0.8535331000 b2=-0.1104595113

RIAA EQ reproduction filters.

By swapping the a1<->b1 and a2<->b2 you'll get the production filter. Production filter can be used as for an example if you need to check how your mix for vinyl mediaformat (yes, it's quite rarely used format today) sits (-> mixdown through production filter, transfer the mix into some media (CD/Cassette) which you can use with your device (w/RIAA stage) or just playback driectly from PC through hardware RIAA stage found in Hi-Fi systems, audio interfaces, mixer tables, etc.). It's not fully comparable w/ vinyl mastering/vinyl playback but, it can give some directions.

EDIT: All those given coefficients gives a bit gained filter (~+12.5dB) so, if you like to adjust the 1kHz point to hit 0dB line, it can be done quite accurately by finding those linear differences using Tobybear's FilterExplorer. Just enter those coefficients into FilterExplorer, find/point the ~1kHz position in magnitude plot and then check the magnitude value (value inside the brackets) found in info field. Use this value as divider for b coefficients (i.e. for a coefficients in SM implementation if you use biquad objects).

Juha

infuzion ·

juha_p wrote: Does the SM round what's given as input (I used 17 decimal accurate coefficients as input in both implementation)?

Yes: you get only 6 digits, since that SM for the most part uses 32bit floats in a 4x-array (SSE). So, 1.73276550000000020 will round to 1.73277 in SM (& other SSE programs). The advantage is that SSE allows 4 numbers to be worked on with one command: a great CPU saver if you can handle the rounding.

I think some ASM FPU commands with greater accuracy are available, but a bit beyond my understanding now. [old link]

Wrote something here? To have a post removed or your name hidden, write to [email protected].

Before your first post

A few rules keep this a friendly place. You agree to them once.

Shown next to what you post, here and in the app. It doesn’t have to be your real name: 3–24 lower-case letters, digits or _ (capitals become lower case, spaces become _).

    Then your post goes up straight away.

    Delete this reply?

    Open it in SynthMaker?

    It goes on the track you’re editing there, in place of that track’s sound, and into My sounds. Your other tracks stay as they are.

    Want to keep that track’s sound? Start a new song in SynthMaker first (Song › New song), then open this.

    Report this reply?

    Only the developer reads reports. The person isn’t told who reported them.

    What’s wrong with it?

    Block this person?

    You won’t see their posts and replies here any more. They aren’t told, and you can unblock them at any time.

    People you’ve blocked

    Their posts and replies are hidden from you. Unblock someone to see them again.

    The community rules

    A few rules keep this a friendly place. Everyone agrees to them once, before their first post.