Audacity IIR RIAA Plugins

A place for software, hardware and DSP-based solutions. All things code and the hardware that runs it. Time and amplitude are described in bits and pieces here. Links to interesting gizmos and software.
Post Reply
User avatar
mediatechnology
Posts: 2707
Joined: Sat Aug 11, 2007 2:34 pm
Location: Oak Cliff, Texas
Contact:

Audacity IIR RIAA Plugins

Post by mediatechnology » Sat Apr 29, 2017 2:47 pm

One of the early concerns in the development of the Phono Transfer System was appropriate DSP-based RIAA equalization.

The idea is to record flat and apply de-clicking and noise removal prior to RIAA equalization because some tools work better.
Flat recordings provide an unfiltered examination of the click and the "hole" clicks produce is shorter.
Applying EQ using DSP is a requirement.

My first experiments were with Cool Edit's FFT filter which happens to be FIR and not phase-accurate to the RIAA curve.
The Cool Edit RIAA sounds weird.

Audacity provides vst plugin capability and also offers the Nyquist prompt allowing text entry of filter coefficients.
vst filters are available which are IIR and can follow the RIAA phase response.

My first tests were with the jiiteepee vst filters
http://jiiteepee.tripod.com/
The filter .dll files are found here: viewtopic.php?f=15&t=782
The jiiteepee vst filters only seem to work in Audacity under Win XP but not Win 7.
They are based on the DH-Biquad tool.
The filter coefficients change with sample rate so four files are needed for 44.1, 48, 96 and 192 kHz.

Our own member Olaf Matthes has published vst filters for RIAA
http://www.nullmedium.de/dev/audioplugins/
Olaf's small, compact 136k .dll works at multiple sample rates and switches automatically.
In addition it provides an Inverse RIAA function and slider-selectable gain.
To use, copy the RIAA.dll into Audacity's plugin folder.
Then, with a file loaded, select Effect|Add Remove Plugins scroll to RIAA and Enable.
RIAA will now appear in a list of Effects.
Make sure that you don't confuse this plugin with the FIR RIAA under Effects|Equalization.

Wayne Stegall has this interesting web page which provides a coefficient calculating tool to produce Audacity IIR Nyquist scripts to provide RIAA
http://waynestegall.com/audio/riaaiir.htm

I recommend that you download the Windows riaaiir.exe file.
Also copy the C program listing and save it as a txt file. You can find a copy of the C program as a txt file here: http://www.proaudiodesignforum.com/code ... isting.txt
With these two files you can create your own Nyquist scripts for IIR Biquad coefficients based on sample rate, gain, and the option of a 3.18 µs time constant.

For those that want some ready-to-use Nyquist scripts there are these.
I included the 0 dB (DC Gain) for reference. The 20 dB Gain version is probably the most useful.

96K 0dB http://www.proaudiodesignforum.com/code ... ra_Zero.ny
96K 0db 3.18 µS http://www.proaudiodesignforum.com/code ... ra_Zero.ny

96K 18dB http://www.proaudiodesignforum.com/code ... ra_Zero.ny
96K 18db 3.18 µS http://www.proaudiodesignforum.com/code ... ra_Zero.ny

96K 20dB http://www.proaudiodesignforum.com/code ... ra_Zero.ny
96K 20db 3.18 µS http://www.proaudiodesignforum.com/code ... ra_Zero.ny

96K 24dB http://www.proaudiodesignforum.com/code ... ra_Zero.ny
96K 24db 3.18 µS http://www.proaudiodesignforum.com/code ... ra_Zero.ny

96K 26 dB http://www.proaudiodesignforum.com/code ... ra_Zero.ny
96K 26db 3.18 µS http://www.proaudiodesignforum.com/code ... ra_Zero.ny

The additional 3.18 µs zero serves to correct a rising response error as the RIAA curve approaches fs/2.
It's not used as a "Neumann Pole" correction.
For response error plots see Wayne's site.

To use the Nyquist .ny scripts right-click and save them.
With a file loaded into Audacity click on Effect and open the Audacity Nyquist Prompt.
Click on Load and Navigate to the location of the saved .ny files.
Open the .ny file you want.
Make sure that the Nyquist "Use legacy (version 3) Syntax" is checked.
It will look like this:

Image
Audacity Nyquist Prompt with 96 kHz RIAA IIR Biquad Coefficients

How does the DSP-based (Biquad IIR) RIAA EQ compare to analog?
The answer begins here: http://www.diyaudio.com/forums/analogue ... ost5065570

Analog EQ compares very closely to the Wayne Stegall Biquad and Olaf Matthes' vst plugin.

The Audio Diffmaker correlation null depth between the Nyquist and vst implementations was over 60 dB.
Virtually identical results.

When either was compared to analog the null depth measured only about 10 dB.
Some of this turns out to be Audio Diffmaker (analyzing an partially uncorrelated segment) and convertor errors.
My estimate is about 20 dB null depth which is pretty good.
See: http://www.diyaudio.com/forums/analogue ... ost5066990

The difference file between analog RIAA EQ and the Nyquist EQ sounds like this: http://www.proaudiodesignforum.com/cont ... g_RIAA.mp3 (320 kbps mp3 approx 1.2 Mb)

I'm convinced that the small top-end error is converter differences.
The RAW pass used to apply DSP RIAA and the analog EQ'd were recorded at the same time using two different I/O devices.
The minor LF differences are likely owing to the fact that the DSP-based RIAA EQ has response to DC; the analog RIAA EQ does not.

Image
Spectrum of Analog vs. DSP RIAA EQ Difference File

When the difference spectrum is examined the differences between Analog RIAA EQ and DSP-based appear very small.
Based on listening tests I'm not sure I can hear enough difference to matter.
And then there's the question of which one is right.
I think both are.
"There does seem to be a pattern where, the more difficult a truth is to stomach, the higher the hysteria levels go internally at Google."
Visit RockmoreLabs on Etsy https://www.etsy.com/shop/RockmoreLabs
http://www.ka-electronics.com

User avatar
mediatechnology
Posts: 2707
Joined: Sat Aug 11, 2007 2:34 pm
Location: Oak Cliff, Texas
Contact:

Re: Audacity IIR RIAA Plugins

Post by mediatechnology » Sun Apr 30, 2017 4:49 pm

I decided to try a different test approach inspired in part by George's suggestion over at Diyaudio to wire the cart mono.

The analog RIAA circuit is line level. What I did was simply bridge both channels and fed them line-level pink noise. One output had RIAA EQ applied in analog the other output was RAW (flat). These outputs fed the L and R inputs of the same converter. This eliminates the D/A differences and reduces the A/D differences to the interchannel differences of the convertor which are assumed to be small.

The Analog EQ'd channel was saved as a mono file normalized to -2 dBFS. The RAW file had Olaf Matthes' vst IIR RIAA applied and was saved as a mono file normalized to -2 dBFS.

The two files are identical length, have the same SR and timebase errors.

From these I generated two additional files. One had analog Left, DSP right. The second file was a difference file I created using Cool Edit's paste mix function summing an inverted version of one file with the other.

In an ideal world they should be identical if the RIAA IIR EQ and analog are equivalent. But are they?

Yes. The spectrum of the difference file looks like this:

Image
Analog RIAA vs. IIR-RIAA Difference File Spectrum

Other than low frequencies there is no significant difference between the Analog RIAA and DSP IIR-RIAA.

At low frequencies there is some difference: The analog RIAA does not have DC gain. So what's going on in the lower octaves?

The following persistent goniometer plot (averaged over about 45 seconds) shows spreading due to the LF phase error of the Analog EQ vs the DSP-based RIAA EQ

Image
Analog RIAA vs. IIR-RIAA Phase Error

With a 200 Hz HPF applied the phase error between Analog EQ and DSP-based EQ disappears:

Image
Analog RIAA vs. IIR-RIAA Phase Error WIth 200 Hz HPF. Note the change in scale.

For all practical purposes the results are identical.

A properly designed IIR RIAA can be just as accurate as an analog RIAA network.

If there's phase error above 100-200 Hz its insignificant. Below 200 Hz the analog RIAA's error is due to desirable infrasonic rolloff.
"There does seem to be a pattern where, the more difficult a truth is to stomach, the higher the hysteria levels go internally at Google."
Visit RockmoreLabs on Etsy https://www.etsy.com/shop/RockmoreLabs
http://www.ka-electronics.com

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest