Would anyone code a RIAA correction plugin?

Discussion in 'Effects and the DSP' started by TravelRec., Jul 28, 2004.

  1. TravelRec.

    TravelRec. Alternative Audioproductions

    Joined:
    Sep 8, 2003
    Messages:
    1,710
    Likes Received:
    3
    Trophy Points:
    0
    Hi all DSP gurus!

    Do you have some time and are you willing to code a RIAA EQ plugin? I thinking about the idea of another forum member to do this completely in DSP, but a bit different: I´ve built a linear low noise 40db amp and now the phono level is on line level and only the EQ´ing is necessary. I think this could be a nice solution for digitalizing old records without any special preamps and also with good quality (tweakable to match different turntable pickup systems...).

    What do you think???


    Greetings and regards!

    TravelRec. :)

    P.S.: Le/Mury and TigerM, you don´t have to reply - I know you are busy atm.
     
  2. StArSeEd

    StArSeEd New Member

    Joined:
    Apr 15, 2003
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    0
    If it helps, here's a typed-out version of the inverse RIAA curve's formula (the inversion is necessary on playback to compensate for the record cutter's curve.. without the minus before it, you'd effectively be doubling the record's cutting curve, making it even more unlistenable in its "raw" form):

    y = -((10log (1+(4*(Pi^2)*(x^2)*(0.000075^2))))-(10log (1+(1/(4*(Pi^2)*(x^2)*(0.000318^2)))))-(10log (1+(1/(4*(Pi^2)*(x^2)*(0.00318^2))))))

    Works OK with http://humblestar.net/GCalc/'s graphing calculator, though it would look heaps better if the X-scale were logarithmic.

    X-scale: 0 to 24000, 1200 stepping
    Y-scale: -20 to 20, 3 stepping

    I can't seem to find a LOG function in Dane. I realize that there's a "LOG" instruction, but it totally isn't what we'd need here... at least it doesn't look like it. I think this DSP coding thing is outside of my ability at the moment.

    More resources are available in the other thread.
     
  3. dj_stick

    dj_stick Apple Fanboy?

    Joined:
    Jun 3, 2003
    Messages:
    17,575
    Likes Received:
    204
    Trophy Points:
    88
    afaik to get the log value to standard form… it is a number to the power of the log value… so log10(7) is 10^7… i may be wrong though
     
  4. StArSeEd

    StArSeEd New Member

    Joined:
    Apr 15, 2003
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    0
    Actually, there seems to be a lot of incorrect information on the web about the RIAA curve! Lots of mixed up time constants, lots of missing time constant inversions, subtracting instead of adding, etc. The most accurate information I've found so far exists at:

    http://www.bonavolta.ch/hobby/en/audio/riaa.htm

    More good information is available at:

    http://www.euronet.nl/~mgw/background/riaa/uk_riaa_background_1.html

    ...though the formulae themselves seem to be partially incorrect.

    Using the above, I've edited the spreadsheet from the bonavolta site to include the HF enhancement for both the RIAA and IEC curves, verified the accuracy of the equations, and extended the frequency range to 48kHz (Audigy2's are capable of 96kHz recording, after all) for the gains at example frequencies.

    http://starseed.dyndns.org/riaa-enh.htm

    The formula in my previous post, and on the website I've relied upon for quite a long time, is incorrect. The frequency vs. gain chart is correct, but the formula doesn't yield the chart's results (at the low end of the freq spectrum, not even *close*).

    What would be nice would be a DSP plugin with toggle switches for enabling/disabling the IEC time constant (7950µs) and the HF enhancement time constant (3.18µs), making it a four-in-one utility. :)

    Now, would it be possible to feed the equations themselves to the plugin (requiring C++, I can only assume, do to the requirement of a logarithm function), or would a boatload of predefined gains be required (in dB format for adding, or linear coefficients for multiplying?)?
     
  5. StArSeEd

    StArSeEd New Member

    Joined:
    Apr 15, 2003
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    0
    10^log10(7)=7. Still really nasty... I hate Log: it's big; it's heavy; it's wood.
     
  6. Tiger M

    Tiger M kX user

    Joined:
    Apr 14, 2004
    Messages:
    851
    Likes Received:
    0
    Trophy Points:
    0
    Hey, why don't you try to program that thing yourself, you've made quite a bit of research.
     
  7. TravelRec.

    TravelRec. Alternative Audioproductions

    Joined:
    Sep 8, 2003
    Messages:
    1,710
    Likes Received:
    3
    Trophy Points:
    0

    Beee....cause I know to handle hardware that I can see with my eyes and touch with my hands - and I know about mixing some channels in DSP, but leave me alone with programming, specially logarithmic filter stuff. There´s nobody who will make all things come true - there are much better programmers than me, really!!!

    But thanks for the suggestion :hmm: !

    TravelRec. :)
     
  8. StArSeEd

    StArSeEd New Member

    Joined:
    Apr 15, 2003
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    0
    I've tried; I suck. I'm a network administrator, not a programmer... :D

    I've written up a header and everything, with like four hundred statics declared (100 selected frequency points 20Hz-48kHz x 4 different settings: RIAA, RIAA-Enhanced, IEC, IEC-Enhanced, which can probably be trimmed to just 3 sets if necessary - RIAA base, IEC adjustment, HF enhancement adjustment - requiring more in the actually programming, I think), but have no idea what to do next. I'm register-dumb.
     
  9. TravelRec.

    TravelRec. Alternative Audioproductions

    Joined:
    Sep 8, 2003
    Messages:
    1,710
    Likes Received:
    3
    Trophy Points:
    0
    Yeah, and that is it, that I try to avoid. :D

    Greetings!

    TravelRec. :)
     
  10. ROBSCIX

    ROBSCIX New Member

    Joined:
    Mar 28, 2004
    Messages:
    1,732
    Likes Received:
    4
    Trophy Points:
    0
    I do have programming experience..nothing as extensive though..where I would start would be..get some numbers coming in from the inputs, you will need to use registers though..then figure out what equation to apply. Just my opinion though
     
  11. 2ndhannes

    2ndhannes New Member

    Joined:
    Jan 12, 2005
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    in the thread

    Need help with filter implementation

    I posted an inverse RIAA filter for testing...

    This is my first attempt at dsp programming and I needed some help,
    but all in all, I think it works now. The filter has a gain of 0dB at 1kHz,
    so you must amplify the signal before or after filtering by something like
    +40 .. +45 dB.

    Bye,
    Hannes
     
  12. John Lodge

    John Lodge New Member

    Joined:
    Feb 15, 2005
    Messages:
    71
    Likes Received:
    0
    Trophy Points:
    0
    Several comments:

    1. The RIAA response posted further back in the thread is OK but not complete. As well there is the Neumann or Sculley cutoff. That is the signal to the cutter lathe was usually attenuated to 50Khz to stop the cutter head getting too hot. So that for completeness there is a single pole cuttoff at that frequency as well. Not all that significant but it blends in well with the needs of follower circuits on analog side.

    2. If you look at the unequalised output of you average 30year old mistreated LP you will find (on some) impulse noise that is in the order of 21dB above reference level. For general software or DSP code to be able to properly detect and correct impulse noise (Pops & Clicks) these peaks need to be preserved. This means throwing in another 3dB or so for even worse LP's since I did not do an exhaustive search that reference level needs to be something like 26dB below clipping leveling the low frequency level very low indeed.

    As a consequence at least some of the RIAA equalisation needs to be done in analog before getting to the sound card. That is to say the signal level at low frequencies is going to be at least 26+26=52dB down and running through the Philips UDA (about 85dB with Audigy 2 for example) not the AC97 (which is less) leaves about 33dB; and at 6dB per bit only about 5 to 6 bits of good information.

    ....

    So that getting the signal from analog to digital without loosing data is a critical issue, unless you have an ADC where the analog input S/N is of the order of 114dB or so. Then 114-52=62dB or 10bits of good data. As I recall that, in the context of this forum, puts unequalised input into an Audigy 4 discussion.

    One thing you can do is just do the 50Hz rolloff in analog. Simple, less components and most of the audio is defined by a single value (well the gain is defined by a resistor*capacitor product). This has the added benefit of (relatively) reducing the HF by a further 12.55dB so that the additional headroom needed for impulse noise is reduced.

    The sound card DSP could then add the 500Hz the 2122Hz 12.55dB boost to produce equalised signal; there is of course within the DSP; the full 24 bits available so that the signal level reduction to allow for the headroom for HF audio and impulse noise is not an issue.

    But for intensive processing of the signal to clean it up, general purpose software that works in floating point is probably required.
     
  13. 2ndhannes

    2ndhannes New Member

    Joined:
    Jan 12, 2005
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    I know that the implemented filter does not satisfy highend needs...
    All I wanted to accomplish for now was to be able to connect the turn-
    table to the line-in, because I didn't want to set up my mixer...

    The filter coefficients I am using have been found on the web, and the guy
    who calculated them quoted a reference that has the 50kHz time constant.
    I must check this, but I think the filter thus implements the correct (enhanced)
    curve. Though I am not sure if this has an effect at all, as the frequency range
    of the dsp ends at 24kHz anyway because of the 48kHz sampling rate.

    Google knows of an IEEE paper that describes a much better implementation
    using an analog 1st order filter/amplifier stage and a dsp that does the rest of
    the filtering - this sounds like your idea with the analog implementation of the
    rolloff. Unfortunately, this document is only available to IEEE subscribers :(

    Bye,
    Hannes
     
  14. John Lodge

    John Lodge New Member

    Joined:
    Feb 15, 2005
    Messages:
    71
    Likes Received:
    0
    Trophy Points:
    0
    Hannes,

    For analog followers (as distinct from inverters) the gain limits to unity as the feedback resistor is bypassed by a capacitor. The 50Khz turnover gives a good place for that to happen but the sound difference will not be effected much. At least it is not lower where it will have an effect nor is there any good reason to struggle for a higher turnover.

    ...John
     
  15. TravelRec.

    TravelRec. Alternative Audioproductions

    Joined:
    Sep 8, 2003
    Messages:
    1,710
    Likes Received:
    3
    Trophy Points:
    0
    What an old thread ;) , never thought to see it once more - BTW - independent of all suggestions, I´ve digitalized some LPs in the past using one EQ 10 and (afaik) one EQ P5 with some extreme settings. The sound was quite cool as I can remember, so for the few albums I have to re-work, this solution is okay. I´m still impressed of the quality of sound the DSP reproduces with some good plugins, so guys - keep up the good work!
     
  16. peate

    peate Active Member

    Joined:
    Oct 31, 2003
    Messages:
    513
    Likes Received:
    18
    Trophy Points:
    28
    TravelRec, what was your turntable cartridge and did you use AC97 input through a pre-amp? I was thinking of doing the same thing but I don't have a dedicated phono amp. I think my friend's turntable has a Shure M-75 or something like that. Do you remember your EQ settings?

    Thanks
     
  17. 2ndhannes

    2ndhannes New Member

    Joined:
    Jan 12, 2005
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    I did something like TravelRec, too, before coding my own plugin. I took the
    'EQ P5' plugin out of the UFX set by Max (which unfortunately does not work
    with kX version 3538 yet) and set it to provice one low-shelf boosted by +18dB
    and a high-shelf attenuated by -18dB.

    Then I fiddled with the freq. and bandwidth settings of the two filters to
    get a zero-cross at 1000Hz and a curve shape that resembles the reference
    RIAA curve. This can be done without hassles because P5 gives a graphic
    plot of the curve given by the filters.

    I used a turntable with an Ortofon Pro S cartridge plugged directly into the
    line-in with a +44dB GainHQ between AC97 and the equalizer. For listening,
    this was ok, but I would not use it for recording to cd.

    When there is no signal from the record, the noise floor becomes quite audible,
    so I used the dynamic processor fine-tuned to cut off the noise and leave the
    music. This works most of the time, only becomes obvious when a song fades
    in or out from/to silence...

    Bye,
    Hannes
     
  18. TravelRec.

    TravelRec. Alternative Audioproductions

    Joined:
    Sep 8, 2003
    Messages:
    1,710
    Likes Received:
    3
    Trophy Points:
    0
    I use an old "DUAL" turntable with my self-made linear phono amp (available on www.electricstart.de ) and one of the analog to SPDIF converters to feed the signal with as less a possible noise into the soundcard. I can´t remember my own settings, but my computer can :D , download the pic here: http://www.electricstart.de/pic/phondsp.jpg , both EQs are chained.
     
  19. John Lodge

    John Lodge New Member

    Joined:
    Feb 15, 2005
    Messages:
    71
    Likes Received:
    0
    Trophy Points:
    0
    ADC's typically clip at around 2Vrms (for example the Philips UDA used in Audigy 2 etc., does). So that a preamp is needed. With a reasonable arrangement of gain the noise floor from the preamp in without a record playing should be able to be arranged to be quite a bit lower than that in the LP.

    With my setup the UDA input gives a noise input (with needle not on LP) of:
    -93dB above 1Khz
    -78dB below 1Khz (from memory.

    The former number is changed very little by turning the preamp off. The latter is.

    Signal comes in at around -20dB peaking to 4dB.

    I conclude that the HF preamp noise is probably a little below the ADC noise but at LF the combination of 1/f noise and LF equalisation dominates. I am using an AD6820 which is of course JFet 1/f to get better one could use bipolar but it is good enough that it does not matter.

    The noise with needle on moving LP is greater by quite a few dB.

    One thing to look out for is to drive the ADC hard enough that in some sense you are matching 0dB digital with analog clipping or you will be knee deep in noise floor.
     
  20. igor_levicki

    igor_levicki Intel Black Belt

    Joined:
    Dec 3, 2003
    Messages:
    128
    Likes Received:
    0
    Trophy Points:
    0
    It is much easier to do this in real hardware. But I would be interested in dbx decoder to restore some old tapes. Unfortunately I don't have any clue where to find exact coefficients and frequencies for dbx.
     

Share This Page

visited