Oops ... on second look, I see the problem. You want to subtract 9.4298 dB from each biquad, so your multiplication factor is 10^(-9.4298/20) = 0.33768
Ah, perfect. Yeah, I tried distributing the 18 dB gain in a different manner just now and it made a grossly-loud result in a different manner. Will try that now.
I think the gain is still too high. It looks generally reasonable, but hard to compare properly A/B with my raw file because of the gain differences.
My working "solution"
(biquad-m track 2.96136732e+00 -1.95948911e+00 -5.37749983e-01 1.000000e+00 03.655731e-01 1.499662e-02)
(biquad-m track 2.96136732e+00 -1.79014924e+00 -1.1577345e+00 1.000000e+00 -5.7552742e-01 -3.7960478e-01)
The solution from user JP at the Steve Hoffman forum. Will have to ask for a bit more background on the math and the accuracy.
(biquad-m track 5.196122e+00 -6.324336e+00 1.253910e+00 1.000000e+00 -7.206742e-01 0.000000e+00)
My working "solution"
(biquad-m track 2.96136732e+00 -1.95948911e+00 -5.37749983e-01 1.000000e+00 03.655731e-01 1.499662e-02)
(biquad-m track 2.96136732e+00 -1.79014924e+00 -1.1577345e+00 1.000000e+00 -5.7552742e-01 -3.7960478e-01)
The solution from user JP at the Steve Hoffman forum. Will have to ask for a bit more background on the math and the accuracy.
(biquad-m track 5.196122e+00 -6.324336e+00 1.253910e+00 1.000000e+00 -7.206742e-01 0.000000e+00)
I think I'm missing some key concepts here. For example, this isn't making sense:
The gains given for the two parts can be used to compute a net gain in order to adjust for the desired gain at 1 kHz. I would recommend splitting the difference i.e. if the gains for the two filters are 5dB and 7dB and you want a gain of 20dB at 1 kHz you would add 4dB to each (9dB and 11dB), so the sets of b coefficients would be multiplied by 2.8184 and 3.5481 respectively.
I think Scott made a mistake here. He should multiply the numerator (b) coefficients of both biquads by 104/20 to get the gain of each biquad to increase by 4 dB. That's including the first of the b coefficients, the one that is 1. before gain scaling.
Having entered the thread late, I assumed that the original 5 dB and 7 dB values were added gains that needed to be modified to 9 dB and 11 dB, respectively. If they were actually just the natural response values of the two biquads, then you are correct -- only 4 dB needs to be added to each.I think Scott made a mistake here. He should multiply the numerator (b) coefficients of both biquads by 104/20 to get the gain of each biquad to increase by 4 dB. That's including the first of the b coefficients, the one that is 1. before gain scaling.
I've partially figured this out. With the Wayne Stegall riaair program, you just need to select the reverse option and then use a gain of -0.1, which of course is the exponential decibel calculation. That results in:
(biquad-m track -7.599067e+000 1.418787e+001 -6.592028e+000 1.000000e+000 -9.677739e-001 0.000000e+000)
On his website, it looks like the gain of his reverse curve is 20dB at 1kHz. Not sure that's exactly correct, but pretty close, anyway. Would like to know if it's actually a different value.
When applied to a RIAA-transferred acoustical recording, the result is virtually the same as the same record transferred flat.
I'm still confused about the dual-biquad calculation. I've tried a few things and nothing quite works. I think I can live with the Wayne Stegall solution, but would like to figure this out.
-13.73dB (RIAA)
a coefficients = [ 1. -0.66168391 -0.18158841]
b coefficients = [ 1. 0.3655731 0.01499662]
Gain at 1kHz = 18.0272664045 dB
50.05 Hz and 500.5 Hz (RIAA)
a coefficients = [ 1. -0.60450091 -0.39094593]
b coefficients = [ 1. -0.57552742 -0.37960478]
Gain at 1kHz = 0.832424759841 dB
I think this might be intended for use in a preamp capacity. Not sure why an RIAA curve would otherwise have positive gain with a rolloff. If I reduce the gain 18 dB, it's virtually inaudible. If I boost the gain, it's sort of close but not quite right. I'm pretty sure the gain changes need to be applied directly to the biquad responsible for that part of the gain rather than split apart.
(biquad-m track -7.599067e+000 1.418787e+001 -6.592028e+000 1.000000e+000 -9.677739e-001 0.000000e+000)
On his website, it looks like the gain of his reverse curve is 20dB at 1kHz. Not sure that's exactly correct, but pretty close, anyway. Would like to know if it's actually a different value.
When applied to a RIAA-transferred acoustical recording, the result is virtually the same as the same record transferred flat.
I'm still confused about the dual-biquad calculation. I've tried a few things and nothing quite works. I think I can live with the Wayne Stegall solution, but would like to figure this out.
-13.73dB (RIAA)
a coefficients = [ 1. -0.66168391 -0.18158841]
b coefficients = [ 1. 0.3655731 0.01499662]
Gain at 1kHz = 18.0272664045 dB
50.05 Hz and 500.5 Hz (RIAA)
a coefficients = [ 1. -0.60450091 -0.39094593]
b coefficients = [ 1. -0.57552742 -0.37960478]
Gain at 1kHz = 0.832424759841 dB
I think this might be intended for use in a preamp capacity. Not sure why an RIAA curve would otherwise have positive gain with a rolloff. If I reduce the gain 18 dB, it's virtually inaudible. If I boost the gain, it's sort of close but not quite right. I'm pretty sure the gain changes need to be applied directly to the biquad responsible for that part of the gain rather than split apart.
I just found these values after swapping and gain scaling. I scale each biquad's gain to 0 dB at 1 kHz for convenience; I assume it will all be done in floating point with no overload issues anyway.
I want to (mathematically) check it against an ideal RIAA recording curve, but I haven't got that far yet.
I want to (mathematically) check it against an ideal RIAA recording curve, but I haven't got that far yet.
I tried this, but it reduces the gain of the track--either I made a typo or a syntax error or got something backwards, but doesn't seem to work like the Stegall curve. I tried it with the biquads reversed, too, and that doesn't seem to work, either.
(biquad-m track 7.96825677e+00 -5.2724672934e+00 -1.4469430768e+00 1.0000000e+00 3.655731e-01 1.499662e-02)
(biquad-m track 1.10057904e+00 -6.653010318e-01 -4.302668967e-01 1.000000000e+00 -5.7552742e-01 -3.7960478e-01)
Reversing the order of the biquads looks a bit closer to correct, but the bass is louder than it should be. The treble half of the curve looks correct.
(biquad-m track 7.96825677e+00 -5.2724672934e+00 -1.4469430768e+00 1.0000000e+00 3.655731e-01 1.499662e-02)
(biquad-m track 1.10057904e+00 -6.653010318e-01 -4.302668967e-01 1.000000000e+00 -5.7552742e-01 -3.7960478e-01)
Reversing the order of the biquads looks a bit closer to correct, but the bass is louder than it should be. The treble half of the curve looks correct.
Last edited:
Is anyone sure that both biquads actually process the signal?
Ideally, reversing should make no difference at all. If the latter biquad unintendedly overwrites the output of the first instead of the two working in cascade, you can choose between having the bass or the treble correct, but not both.
Ideally, reversing should make no difference at all. If the latter biquad unintendedly overwrites the output of the first instead of the two working in cascade, you can choose between having the bass or the treble correct, but not both.
I've checked the values from post #47 by calculating the biquad responses and multiplying them with each other and with an ideal RIAA response. They are spot on.
Magnitude error in dB versus frequency in Hz:
Phase error in degrees versus frequency in Hz, after subtracting a constant delay:
The calculations are in the attached spreadsheet (zipped to pass the forum software). I've stored it in Excel format, but it was actually made with LibreOffice Calc.
I think something is wrong with the cascade of two biquad sections, like I suggested in post #49. It's a pity I don't speak Audacity Nyquist.
Magnitude error in dB versus frequency in Hz:
Phase error in degrees versus frequency in Hz, after subtracting a constant delay:
The calculations are in the attached spreadsheet (zipped to pass the forum software). I've stored it in Excel format, but it was actually made with LibreOffice Calc.
I think something is wrong with the cascade of two biquad sections, like I suggested in post #49. It's a pity I don't speak Audacity Nyquist.
Attachments
Thanks! I'll have to try to figure out the syntax for cascading two biquads in Audacity Nyquist. At first glance it looks rather confusing.
Would it be possible for you to also check this one against ideal RIAA response, i.e. Wayne Stegall's formula? Gary Galo just sent me some advance work on some other digital phono EQ work he's preparing for the upcoming ARSC conference, and I'd like to share this with him.
Filter calculated for:
Sampling frequency: 96000
Gain: -0.1
Extra zero: 0
Inverse: 1
Coefficients for H(z)
num[0] = -7.599067e+000, [1] = 1.418787e+001, [2] = -6.592028e+000
-------------------------------------------------------------------
den[0] = 1.000000e+000, [1] = -9.677739e-001
Audacity Nyquist biquad equations (LISP format)
(biquad s b0 b1 b2 a0 a1 a2)
(biquad s -7.599067e+000 1.418787e+001 -6.592028e+000 1.0 9.677739e-001 -0.000000e+000)
(biquad-m s b0 b1 b2 a0 a1 a2)
(biquad-m s -7.599067e+000 1.418787e+001 -6.592028e+000 1.000000e+000 -9.677739e-001 0.000000e+000)
Would it be possible for you to also check this one against ideal RIAA response, i.e. Wayne Stegall's formula? Gary Galo just sent me some advance work on some other digital phono EQ work he's preparing for the upcoming ARSC conference, and I'd like to share this with him.
Filter calculated for:
Sampling frequency: 96000
Gain: -0.1
Extra zero: 0
Inverse: 1
Coefficients for H(z)
num[0] = -7.599067e+000, [1] = 1.418787e+001, [2] = -6.592028e+000
-------------------------------------------------------------------
den[0] = 1.000000e+000, [1] = -9.677739e-001
Audacity Nyquist biquad equations (LISP format)
(biquad s b0 b1 b2 a0 a1 a2)
(biquad s -7.599067e+000 1.418787e+001 -6.592028e+000 1.0 9.677739e-001 -0.000000e+000)
(biquad-m s b0 b1 b2 a0 a1 a2)
(biquad-m s -7.599067e+000 1.418787e+001 -6.592028e+000 1.000000e+000 -9.677739e-001 0.000000e+000)
I've checked the values from post #47 by calculating the biquad responses and multiplying them with each other and with an ideal RIAA response. They are spot on.
Magnitude error in dB versus frequency in Hz:
[...]
Phase error in degrees versus frequency in Hz, after subtracting a constant delay:
[...]
That is really fantastic performance -- matches not only magnitude, but phase, as well. Naive bilinear transform doesn't perform anywhere near as well. Any indication of what method was used to approximate the Laplace domain RIAA response?
The constant delay that I subtracted from the phase error is 3.92428090377698 microseconds, by the way. When you don't subtract the constant part and plot the phase versus frequency with a linear horizontal axis, you see almost a straight line.
In the article, Scott Wurcer also found that a FIR approximation can be much shorter when you don't make it minimum phase, but minimum phase except for a small constant delay.
In the article, Scott Wurcer also found that a FIR approximation can be much shorter when you don't make it minimum phase, but minimum phase except for a small constant delay.
Scott Wurcer also published single-biquad digital RIAA correction filters. When you take the 96 kHz sample rate version, swap its a and b coefficients and scale it for unity gain at 1 kHz, you get this:
Magnitude error in dB versus frequency in Hz:
Phase error in degrees versus frequency in Hz, 4.08693129921226 microsecond delay subtracted:
Magnitude error in dB versus frequency in Hz:
Phase error in degrees versus frequency in Hz, 4.08693129921226 microsecond delay subtracted:
Wayne Stegall's single-biquad approximation scaled for unity gain at 1 kHz:
Phase error after subtracting a 5.11831105704433 microsecond delay:
Phase error after subtracting a 5.11831105704433 microsecond delay:
Amazing work, thanks!
I asked on the Audacity forum, and the syntax to stack two biquads is:
The exact prompt you put into Audacity for the two-biquad reverse RIAA with 1kHz at 0db is:
I asked on the Audacity forum, and the syntax to stack two biquads is:
Code:
(setf *track* (biquad-m track ...)) (biquad-m track ...)
The exact prompt you put into Audacity for the two-biquad reverse RIAA with 1kHz at 0db is:
Code:
(setf *track* (biquad-m track 7.96825677e+00 -5.2724672934e+00 -1.4469430768e+00 1.0000000e+00 3.655731e-01 1.499662e-02))
(biquad-m *track* 1.10057904e+00 -6.653010318e-01 -4.302668967e-01 1.000000000e+00 -5.7552742e-01 -3.7960478e-01)
This has me wondering if you can stack three or four biquads and have the output be, say, inverse RIAA with 250 Hz turnover and 8.5 dB rolloff at 10 kHz with only the necessary gain changes.
This seems like it could be an extremely useful Audacity Nyquist plugin, and the coding wouldn't be that heavy of a lift. You could input sampling frequency, what type of preamp you're using, desired rolloff and turnover, and the output would be identical to or better than an analog archival preamp with 1% components. Gary Galo is working tirelessly to work something up for iZotope and Ozone, but it seems like a much-easier solution is possible in Audacity with a very simple program. A few "if" functions and nested biquads with a toggle switch of sorts would do it.
I will have to ask on the Audacity forum.
This seems like it could be an extremely useful Audacity Nyquist plugin, and the coding wouldn't be that heavy of a lift. You could input sampling frequency, what type of preamp you're using, desired rolloff and turnover, and the output would be identical to or better than an analog archival preamp with 1% components. Gary Galo is working tirelessly to work something up for iZotope and Ozone, but it seems like a much-easier solution is possible in Audacity with a very simple program. A few "if" functions and nested biquads with a toggle switch of sorts would do it.
I will have to ask on the Audacity forum.
Thanks. I wish that they had mentioned the method that they used without having to purchase the issue.Brute force numerical optimization, see https://linearaudio.net/article-detail/2240
I do have one concern about the "inverted" RIAA approximation (which is actually the "recording" curve). Its magnitude response continues to rise above 20 kHz. In the digital approximation it might be a good idea to roll that off. Some Neumann cutters actually did that, I think.
- Home
- Source & Line
- Analog Line Level
- Digital IIR Inverse RIAA filter 1kHz @ 0 dB Audacity Nyquist