ADAU1701 RIAA
Hi all,
I successfully built an RIAA equalizer with sigmastudio to Play vinyl discs.
Is it possible to filter the noise made from scratches on my discs ?
Michael
Audio Signal Processors
SigmaDSP Audio Processors
adau1701
Hello Michael,
That's an interesting application. You could always reduce treble response, but we hope to do better with DSP. There's several possible methods, all of which depend upon the high-frequency content and the short time of the pops and ticks common to vinyl. Perhaps the most ambitious method is one that BSR developed many years ago. I remember reading about it and it works something like this: The incoming audio went through a short delay -- likely an analog bucket brigade at the time. Normally the listened-to sound is taken from the delay output. But when circuitry looking at the input detected a vinyl defect, it would wait until just before the defect reached the delay's end, then momentarily switch to the non-delayed signal to skip over the defect. Very cool!
It won't be a trivial undertaking, but something like this should be quite possible with SigmaStudio. In fact I had thought about making one of these but didn't pursue it. The key to detecting vinyl defects is their transient nature -- they come and go quickly. Most important, their direct mechanical production right at your turntable means there's absolutely no reverberation or echo in their decay characteristic. This separates vinyl defects from virtually any recorded sound, making the needed "click detector" possible to implement. Delays of course are easy in DSP, so there you are! Perhaps someone out there has already done this, but you'll have lots of fun developing it further yourself. And you won't burn your fingers on a soldering iron in the process!
Best regards,
Bob
Hi Bob,
thanks for your fast response.
My problem is how to detect that click, or what kind of filter do i have to use to detect it ?
Michael
Hello Michael,
There's no one filter or block to perform this function. We can, however, wire together several to help identify the clicks among the music according to their unique decay characteristic. In SigmaStudio there's often more than one way to do something -- and the more complex the function, the more ways exist. The method shown below is just one possibility:
I suspect (but don't know) that the vinyl scratches cause primarily vertical stylus motion. This would translate to out-of-phase (L-R) signals at the cartridge. Thus I made the circuit sensitive to such signals (of course you would be the expert on this). The peak-sensing envelope follower works much like a full-wave rectifier & capacitor filter. Its output rises instantly with input peaks, then decays in between. The feedback, multiplier and DC source establishes an exponential "RC" decay characteristic (otherwise, the decay is linear --
see https://ez.analog.com/message/146951?commentID=146951#comment-146951 ).
The "hold" time of 3 mS bridges the gaps between peaks, reducing output ripple. Without hold time the circuit responds to ripple, resulting in premature triggering of the "click" function which actually lets clicks through. At the peak follower's output we have a positive signal which follows the level of the (L-R) input.
Next, we need to sense a sudden downturn of this level, indicating that a loud disturbance came and went with a fast decay (a click or scratch). The following circuit takes the difference between the current sample and one two samples previous, to measure the rate of change. It's purposely wired backwards so the faster its input falls, the more positive its output goes. As a result, the higher the differentiator's output, the more likely there's been a click. So we can use the output of this circuit for our click detector.
No suggestion is truly helpful unless it has at least a chance of working, so I built a demo project to test it. In addition to the click filter, the project contains:
A simulated click sound (since I no longer own a turntable)
A mixer to add music from (gasp!) a MP3 player
A threshold comparator and timing logic that responds to clicks found by the filter
The essential delay and cross-fader driven by the click detector & logic
The project runs on the ADAU1701MINIZ board. I suggest using the built-in click at first. Add some music, and adjust the threshold downward until you see LED D5 blink, showing that the thing is finding the clicks. The clicks will then be rendered nearly inaudible! Next you can switch off the built-in clicker and try some bad vinyl. You'll need to add your RIAA EQ.
At this point you're free to come up with variations or an entirely new circuit. The more you learn about the blocks and what they do, the more likely you'll succeed. Here's a few more tips:
Keep multiple project copies, documenting their unique features and how well they perform.
No one likes to debug spaghetti C code, or scrambled schematics -- see Taming sloppy schematics
Need to scope an internal signal? Connect it to an unused DAC and hang your scope on that pin. Normally a RC reconstruction filter is needed, but you may get away without it for a quick look. And remember that the 1701's DACs invert the signal.
Best regards,
Bob
Hi Bob,
wow, thats a lot of stuff i have to understand.
I will try to implement this on my board, as i don't own the MINIZ board.
I will keep you informed and post my hopefully working project.
It is just for hobby, and anyone who wants can use it for non commercial projects.
Many thanks.
Kind regards,
Michael
Hello Michael,
Sorry I forgot to attach the project. Here it is. It should be fairly easy to adapt it to the Sure DSP or similar boards, just change your ins and outs. Anything needing more explanation, just ask. Hobby projects are fun!
Best regards,
Bob
Hi Bob,
finally I got the hardware and software running with good results.
The clicks of old vinyls are nearly inaudible and the RIAA curve is nearly 100% exact.
Now I would like to make some of the parameters (treshold etc.) externally adjustable via the AUX-ADC's
but I don't know how to do it in studio.
Kind regards
Michael
Vinyl-fixer-RIAA.dspproj.zip
Hello Michael,
Glad to hear you got your hardware going. Now for the fun part, tweaking and improving your project. Your use of hierarchy boards is a fine idea, as well as providing external adjustments via Aux ADCs. The ADAU1701's aux ADCs go from zero to 1.0 decimal, so all we need do is scale this to the needed level. For example, the Threshold presently goes from -80 dB (or 0.0001) to -40 dB (0.01). The arrangement of gain, DC source, and adder shown below will provide approximately that range as you turn your pot connected to the Aux ADC:
There's more sophisticated approaches involving a Lookup Table (LUT) -- for an example of interfacing an Aux ADC and LUT, see https://ez.analog.com/dsp/sigmadsp/f/q-a/66309/logarithmic-pot-by-index-lut
Best regards,
Bob
Vinyl-fixer-RIAA-2.zip
Hello Bob,
finally I got an USBi interface, so testing my design is easy from now on.
I found a project from you about a dynamic loudness enhancer and tried to implement this
into my RIAA project to make old vinyls sound better. Unfortunately is does not work as expected.
Putting the loudness in front of the RIAA block works, but sounds not so good.
Putting the loudness after the RIAA block gives only hiss, like white noise,
but no music at all. And I don't know why.
Best regards,
Michael2746.Vinyl-fixer-RIAA-2.zip
Hello Michael,
The processing order in the project you have attached is the best: The click filter first, where it receives the best click information. Then the RIAA EQ, and finally, the dynamic loudness which operates on a normal (flat) signal. And yes, it hisses and quite loudly at that. Fortunately, another EZ engineer figured out why this happens and found an easy workaround.
The problem lies in the Dynamic Loudness circuit, which I made years ago before the problem was discovered. It turns out that when a Feedback block feeds two or more destinations via a T junction, the compiler doesn't assign memory for the extra connections. Occasionally it works anyway, as it did when I made the Dynamic Loudness. Other times it doesn't -- and the DSP departs to Mars. The result is that awful hiss. The fix is to use a separate Feedback for each needed signal:
Bad: Hisses
Good:
By the way, AD has used a similar "implicit" calculation arrangement in their analog RMS converter chips. Here it performs two mathematical functions which would otherwise require a boatload of ADAU1701 instructions. The higher-end DSPs (ADAU1452 and above) can handle square root and divide much more efficiently.
Making the above change will get rid of your hiss. I did notice one other thing you need to fix, this in the differential outputs. The Buffer Gates shown below are not audio buffers but are used for logic functions. They won't pass audio, only distortion. And you don't need them anyway so take them out!
Best regards,
Bob
Hello Bob,
thank you for the fixes.
I placed the Buffers there because I was thinking of timing issues between the positive and
negative outputs. The negative signal will be a bit delayed because of the inverters ?
Best regards,
Michael
Hello Michael,
Your idea to balance the delays is good thinking, yet it doesn't apply here. The -1701 executes your entire schematic with each tick of the 48 KHz sample rate clock. Thus, blocks such as adders and gains add no latency or delay. It's just another advantage of DSP
Best regards,
Bob
Hello Bob,
that is really an advantage, good to know.
Now that my project is nearly finished, i still have to add an microprocessor and make the documentation
ready, I will publish everything here for the hobbyists.
But there is an small issue with the click filter.
When the audio level is low and one adjusts the treshold low to get rid of the clicks and then
suddenly the volume gets up, the treshold runs into the audio signal and there will be a lot of
distortion. Is there a way to always keep the treshold slightly above the average audio level
plus an adjustable offset ?
Best regards,
Michael
Hello Michael,
The adaptive threshold you desire is straightforward to implement and very likely to help. An old engineering proverb says that to describe a problem is to solve it -- and you've already described exactly what you need to do:
First, measure the average incoming audio level, often called the envelope.
Add an adjustable amount of this signal to your existing threshold.
The existing threshold is now the offset.
It may work well to simply obtain the average audio level by lowpass filtering the output of the existing Peak Envelope detector. This would average the L-R signal. It may work better to average the L+R (mono) signal with its own envelope detector -- in that case, choose among the non-peak Envelope Detectors under Dynamic Processors. The lowpass filter (or the adjustable response of a separate envelope block, if used) needs to be reasonably quick to follow the changing audio level, but slow enough to mostly ignore the clicks as they go by. As you can see -- if the threshold jumps too much with every click, none would be detected!
I'd be happy to help with any questions as you implement your adaptive threshold, yet at this point you're evidently savvy enough to experiment with your idea and make it work with vinyl samples that I no longer have. Two more thoughts:
Now that you have a USBi, you can use SigmaStudio's Real-Time Display (under DSP Functions) to see your click level or threshold as they change. The Real-Time Display has its limitations but can be incredibly useful.
You may want to experiment with a feature that BSR had included in their original box -- a switch that when activated, flips the Click Filter's logic around so that instead of the filtered music, you hear what the filter "thinks" are clicks. It's an excellent help for both you as the designer and for your end users to adjust the threshold.
Best regards,
Bob
Hello Bob, Michael,
I have maybe another solution, why do not use a median filter ?
--> "Is it possible to filter the noise made from scratches on my discs ?" by Michael
It is a FIR a little bit particular because the calculation is not a linear formula but a median calculation. This type of filter is adapted for the pulse noise and the gaussian noise. So, it significantly improves the signal-to-noise ratio. It is possible that this filter is the best choice for your case, despite that this one is rather used in the image processing application, but nothing prevents ?
Your thoughts ?
Hello Cmo,
The median filter is interesting because it's a purely DSP solution, instead of a DSP implementation of an old analog device. I wasn't familiar with it. This Wikipedia article describes it as a walking window from which the median of its included samples is taken. It also describes the computations required to take the median, which can be extensive. My first impression is to be scared of any audio filter that selects among individual samples like this one -- but I'm not a DSP expert so really, the only way for me to know is to try it.
SigmaStudio doesn't offer a median filter, yet it's possible to make a tiny one with only three taps. In this case, the median is uniquely easy to find: The sample that's neither the maximum nor the minimum is the median! The diagram below shows the SigmaDSP logic to perform this three-tap median filter:
The two delays establish the three-tap window. The Max and Min blocks obtain these two samples, and the ABCD Comparators find the one sample equal to neither. I have no idea how to make a larger median filter from SigmaDSP blocks, and suspect that longer ones would involve escalating complexity.
What does it sound like? The attached project implements a set of three stereo FIR filters with a switch for comparing how they sound. The choices are:
The median filter as shown above
The median filter with added delay blocks to maintain the filter's group delay at two samples regardless of which sample in the window happens to be the median.
A three-tap moving average filter
No filter, just the two-sample delay.
Running music through these shows that all pass sound similarly except for the median filter with added "compensating" delays -- this one reminds me of a raspy speaker. I did not evaluate their noise reduction, suspecting that a longer filter is needed for that.
Best regards,
Bob
Median-filter-3.zip
Hello Bob,
Thank you for your feedback, and it is very interresting.
I have also tried from my side, but I think that I am less comfortable than you in Sigma Studio.
Here below is my sort function:
Tri 3 valeurs.zip
Then, I tried with 9 taps, but this one seems "clipping the signal" (maybe, I have mistaken an error):
9 taps:
Sort by 3 [a,b,c], [d,e,f], [g,h,j] (lignes), then sort by 3 [a,d,g], [b,e,h], [c,f,j], (column), and then sort by 3 [g,e,c] (diagonal), the result is in "e" (median), it is an algorithm of "sort at bubble".
The median filter 3 taps seems to be efficient, because I resumed your test signal on the previous schematic, and I tried on it. If you could try on a true signal, and I would like to get your opinion.
What do you think about ?
Thank you in advance.
Median filter 3 and 9 test.dspproj.zip
Sorry, I forgot both others pictures :
Before the filter:
After filter:
Thank you.
Hello Cmo,
You've got some really interesting stuff here:
Your implementation of the 3-tap median filter is genius, much simpler than mine.
The expansion to 3 x 3 = 9 taps via "median of medians" allows us to scale it up.
I simply added a delay output to your 3-tap filter so they can easily be cascaded. This and extensively using aliases (net names) makes the whole thing fit nicely on my laptop screen. The attached circuit compares three stereo choices: 3-tap median, 9-tap median, and 9-tap average.
Listening to the results suggests not much hope as a vinyl fixer. Yet evidently your settings for the noise simulation reminds me of AM / SSB radio static.. For this application your median filter is perfect! It completely eliminates the static with little effect upon the signal. I've never heard anything work this wonderfully. It makes me want to hook this thing up to my shortwave radio, which I'll try some day. If it works "in the wild," it would make quite a practical accessory for amateur radio operators.
Best regards,
Bob
Median-filter-9_comp.zip
Hi there Bob - perhaps I'm imagining it but it seems like your 9 tap filter here re-uses the last sample of a group of three as the first sample of the next group of three - doesn't that make the overall a 7 tap median filter?
Hi David,
Thank you for pointing this out. You're correct, the filter as shown is missing a delay on either side of the interior group. Yet there is a more fundamental problem than this mistake. I've always wondered if the "median of medians" 3x3 filter would always give the same output as a true 9-tap median filter -- but could not prove it one way or the other. Your post gave me an excuse to examine the filter again, which resulted in the thought experiment shown below. It proves that the median of medians filter is not equivalent to a true median filter which takes the median of all nine samples at once.
Assume the 9-step waveform shown repeats indefinitely and feeds a 9-tap median filter. A 'real' median filter will always have the median value of 5 somewhere in its taps, thus its output will always be 5. Yet in the three cases I show above, the last two cases yield an incorrect answer since they ignore the 5. Thus the median-of-medians filter is a faulty design.
I've tested some other nonlinear methods to remove impulse noise such as LULU smoothing. Any method I tried either was ineffective or awful sounding. One could easily add the missing delays to my 3x3 filter project, yet I gave up on the idea a long time ago.
Best regards,
Bob
Thanks Bob. So I'm not ENTIRELY losing my mind. LuLu smoothing looks interesting. I think overall there are plenty of techniques to do that noise removal but it's the noise that the noise-removal generates that is the issue :p Larger windows seems to be a better way to achieve it from what I've been seeing - I haven't given up QUITE yet. :)
Please log in to reply.











