How to mute AK4396 dac in raspberry pi based streamer

Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
Hi all,

Last year I build a DIY audio streamer based on raspberry pi and LMS (logitech media server)/squeezeplayer.

The streamer works fine and sounds really good. However there is one big problem that I never managed to solve: a loud digital click/pop when changing from for instance playing a flac file to playing spotify content.

The pops are really loud since I use a power amplifier and digital volume control on the streamer itself. There are no digital pops/clicks when changing from local (flac file) audio track since auto(software) mute in alsa works fine then.

The real issue here in my opinion is that there is no mute signal available to mute the AK4396 DAC to mute the dac when there is no "signal".

I am using the Allo Kali I2S reclocker to feed my DAC, it has no mute signal but it does have some leds like "buffer empty" , maybe I can use this somehow to mute the dac?

Any ideas/comments are very welcome as this issue withholds me to use the streamer in my stereo setup as I do not want to blow my expemnsive ceramic tweeters.

Ronald
 

Attachments

  • DSC03483.jpg
    DSC03483.jpg
    264.2 KB · Views: 184
  • kali-top.png
    kali-top.png
    199.1 KB · Views: 199
IMO more info about the issue is needed.

* What happens (internally) when you switch between flac/spotify?

* Are both sources (local files vs. spotify) served by the same LMS server-> renderer chain or do you switch the playback applications somehow?

* Does samplerate change occur during the pop? How does the I2S reclocker behave during samplerate change, what does it do with its pre-filled buffer at samplerate change?

Your DAC has the well-behaving mute pin, it could be operated from RPi.

A script can operate alsa mute control item if called at proper moment.

But all of it must be controlled by the playback application - does it offer proper options? Can LMS be configured to send zero samples during switching "plugins"?
 
IMO more info about the issue is needed.

* What happens (internally) when you switch between flac/spotify?

* Are both sources (local files vs. spotify) served by the same LMS server-> renderer chain or do you switch the playback applications somehow?

* Does samplerate change occur during the pop? How does the I2S reclocker behave during samplerate change, what does it do with its pre-filled buffer at samplerate change?

Your DAC has the well-behaving mute pin, it could be operated from RPi.

A script can operate alsa mute control item if called at proper moment.

But all of it must be controlled by the playback application - does it offer proper options? Can LMS be configured to send zero samples during switching "plugins"?

Thanks for your reply :) All good questions! Unfortunatly I don't know all the answers...

* What happens (internally) when you switch between flac/spotify?

I do not know.

* Are both sources (local files vs. spotify) served by the same LMS server-> renderer chain or do you switch the playback applications somehow?

Yes! I use another pc as LMS server by the way, not picoreplayer.

* Does samplerate change occur during the pop?

Probably!!

* How does the I2S reclocker behave during samplerate change, what does it do with its pre-filled buffer at samplerate change?

No idea...

Thanks for the idea of using a script to let the pi control the DAC mute pin. I'm going to look into it! :)
 
Last edited:
Thanks for your reply :) All good questions! Unfortunatly I don't know all the answers...

Well, you are using open-source software and open-source OS, not a black-box closed-source player running on windows. Learn how to find out.

* Are both sources (local files vs. spotify) served by the same LMS server-> renderer chain or do you switch the playback applications somehow?


Yes!

OK, that is an important information. So you know you need to deal with LMS to resolve the issue. LMS is open source, huge community around, good.

* Does samplerate change occur during the pop?

Probably!!

No need to guess in linux. You need to know exactly. Check contents of file /proc/asound/YOUR_SOUNDCARD_NAME/pcm0p/sub0/hw_params on the renderer while anything is playing. The file will give you current samplerate and sample format being passed to the soundcard, among other information. Check page Alsa Opensrc Org - Independent ALSA and linux audio support site for background info.

* How does the I2S reclocker behave during samplerate change, what does it do with its pre-filled buffer at samplerate change?

No idea...

If you find out the pop occurs during samplerate change, you should suspect the reclocker. It is a commercial product you paid your money for, ask its manufacturer. This is an important information. A detailed description of what happens at samplerate change should be part of the product specifications.


Thanks for the idea of using the a script to let the pi control the DAC mute pin. I'm going to look into it! :)

The script will be simple. The key part is arranging for the script to be run at proper time. Only the playback app switching the sources can do it.


But you did not answer the key question:

Can LMS be configured to send zero samples/mute during switching "plugins"?

Search google, ask at LMS forums, etc. You did a lot of DIY work on your streamer, you certainly can do technology.

All the key components of your chain are open-source and therefore their internals are available to you. It is certainly doable, with a bit of effort. You can do it.
 
Well, you are using open-source software and open-source OS, not a black-box closed-source player running on windows. Learn how to find out.
Good plan, starting right now! :)

OK, that is an important information. So you know you need to deal with LMS to resolve the issue. LMS is open source, huge community around, good.
True, I started asking around there as well ;-)

No need to guess in linux. You need to know exactly. Check contents of file /proc/asound/YOUR_SOUNDCARD_NAME/pcm0p/sub0/hw_params on the renderer while anything is playing. The file will give you current samplerate and sample format being passed to the soundcard, among other information. Check page Alsa Opensrc Org - Independent ALSA and linux audio support site for background info.
You are right, I will do some more investigation about this issue this weekend!

If you find out the pop occurs during samplerate change, you should suspect the reclocker. It is a commercial product you paid your money for, ask its manufacturer. This is an important information. A detailed description of what happens at samplerate change should be part of the product specifications.
Actually that's what I did right away, never got an answer...

The script will be simple. The key part is arranging for the script to be run at proper time. Only the playback app switching the sources can do it.
So back to LMS again, will investigate the options, thanks for pointing this out!

But you did not answer the key question:

Search google, ask at LMS forums, etc. You did a lot of DIY work on your streamer, you certainly can do technology.

All the key components of your chain are open-source and therefore their internals are available to you. It is certainly doable, with a bit of effort. You can do it.

Thanks for the PEP talk, it helps :)
 
If the board clicks during sample rate changes, normal a simple solution is to have the LMS server resample everything to a set sample rate. However quite a few Dac board use gpio connections to mute the Dac, this is controlled at the driver level. What kernel driver is being used. Perhaps you can just use a different driver that has gpio/mute builtin and connect the gpio to your mute pin.
 
Hello

Not sure if you are using the differential outputs or wired as single ended..

My amplifier is running wide open with no attenuation on the input and is using the hardware volume on the DAC itself alone to control the volume, so any normally inconspicuous anomalies or imperfections along the signal line before the amp are easily exposed in my case. Initially I had the same or similar issues as yourself, clicks and pops while changing tracks or beginning/ending them. If you are using the DAC in single ended output format, when the DAC goes from active to inactive during changes, there is a slight DC on the DAC output that will get amplified at the amplifier. Most people will experience only a light or imperceptible sound if any because they have a volume control before the amplifier that diminishes the effect of this, while I myself and some others likely like yourself, have our volume controls using the DAC alone. It was suspected and as well I had found some information on the TI website where another had the same issues, and was literally explained that one must use a DAC with balanced out pairs, then back into a single ended, in order to rid the issues of pop and click. I suppose you could use a balanced line IC receiver in your project, however, I chose to go with line-level transformers for my DAC output-to-amp-input resolution. I will say for myself, that this alone is the most important added component for taking my project from a DIY toy, to a professionally performing machine. I experience no more clicks pops whatever, with the added natural filtering capabilities and DC blocking inherent with transformers. They are in my system for good. She is clean and quiet.

Best
S
 
The reclocker holds 0.7s of data. No point in muting the DAC during the switchover when the actual data to be muted-out will reach the DAC much later.

Still we do not know when the pop occurs. What does that hw_params file say, before the switch and after?
Good point!

I did some tests, indeed the loud plops are when sample rate is changing but not always.... I had to switch 10 times before I got one loud crack/pop. I was afraid my speakers tweeters
would be launched and hit me...
 
I did some tests, indeed the loud plops are when sample rate is changing but not always....

Very good. The key question is: Did you encounter a pop WITHOUT samplerate change? The change does not have to always produce the pop, it depends on sample values at that moment - if they have low level around the transition time, the pop (samples discontinuity) would be silent.

IMO the samplerate change should be accompanied with flushing the reclocker buffer while the DAC is muted. I do not know if the reclocker can be flushed with some external pin signal.
 
Last edited:
Very good. The key question is: Did you encounter a pop WITHOUT samplerate change? The change does not have to always produce the pop, it depends on sample values at that moment - if they have low level around the transition time, the pop (samples discontinuity) would be silent.

IMO the samplerate change should be accompanied with flushing the reclocker buffer while the DAC is muted. I do not know if the reclocker can be flushed with some external pin signal.
I did, no POP, but unfortunatly the pop this issue happens only sometimes so it does not mean it will never happen without changing sample rates.
 
Hello

Not sure if you are using the differential outputs or wired as single ended..

My amplifier is running wide open with no attenuation on the input and is using the hardware volume on the DAC itself alone to control the volume, so any normally inconspicuous anomalies or imperfections along the signal line before the amp are easily exposed in my case. Initially I had the same or similar issues as yourself, clicks and pops while changing tracks or beginning/ending them. If you are using the DAC in single ended output format, when the DAC goes from active to inactive during changes, there is a slight DC on the DAC output that will get amplified at the amplifier. Most people will experience only a light or imperceptible sound if any because they have a volume control before the amplifier that diminishes the effect of this, while I myself and some others likely like yourself, have our volume controls using the DAC alone. It was suspected and as well I had found some information on the TI website where another had the same issues, and was literally explained that one must use a DAC with balanced out pairs, then back into a single ended, in order to rid the issues of pop and click. I suppose you could use a balanced line IC receiver in your project, however, I chose to go with line-level transformers for my DAC output-to-amp-input resolution. I will say for myself, that this alone is the most important added component for taking my project from a DIY toy, to a professionally performing machine. I experience no more clicks pops whatever, with the added natural filtering capabilities and DC blocking inherent with transformers. They are in my system for good. She is clean and quiet.

Best
S
I use the differential outputs of the dac chip, then feed them into an opamp to convert to single ended output. So I guess I should not suffer the issue you describe.

The opamp in my case is however dc coupled, there is no capacitor at the output. Never thought about the fact that it might be DC pop I am hearing. But then again, the power amp connected to the streamer DOES have an input cap. What I certainly am going to try is to insert dc blocking caps at the output to see if it reduces the pop significantly or not. Thanks a lot for your reply!
 
Last edited:
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.