Loud popping sound though analog audio port

For topics which do not fit in other specific forums.
retrodroid
Posts: 138
Joined: Tue Feb 02, 2021 5:55 pm
Has thanked: 96 times
Been thanked: 19 times

Loud popping sound though analog audio port

Unread post by retrodroid »

I have my MiSTer connected to my arcade cabinet via the VGA and analog audio ports. The audio goes into a amplified 2.1 speaker setup mounted in the cab.

Any time I switch cores there is a very loud pop, pop, pop, pop sound like the audio amp is being disconnected and re-connected a few times. The loudness isn't impacted by the system volume settings.

Is this "normal"? Anything I can do or look for to resolve (short of turning my speakers way down)?
User avatar
aberu
Core Developer
Posts: 1192
Joined: Tue Jun 09, 2020 8:34 pm
Location: Longmont, CO
Has thanked: 247 times
Been thanked: 411 times
Contact:

Re: Loud popping sound though analog audio port

Unread post by aberu »

Maybe switch to mini-TOSLINK and see if the audio problem persists. If you are using an analog I/O board, that same 3.5mm jack is simultaneously a mini-TOSLINK optical jack. So you could test it by getting a mini-TOSLINK to TOSLINK cable and getting a DAC from Amazon or something (or test on a TV/sound system with optical in, just to see the difference). I personally have used a cheap-o DAC from Amazon to convert TOSLINK optical audio to 3.5mm to get slightly better audio quality (the 3.5mm jack on the analog I/O board had some undesirable noise whenever the cores would load that I could hear with headphones on).
birdybro~
User avatar
LamerDeluxe
Top Contributor
Posts: 1239
Joined: Sun May 24, 2020 10:25 pm
Has thanked: 887 times
Been thanked: 284 times

Re: Loud popping sound though analog audio port

Unread post by LamerDeluxe »

I wonder if decoupling capacitors could help with this. TOSLINK does provide fantastic audio quality.
retrodroid
Posts: 138
Joined: Tue Feb 02, 2021 5:55 pm
Has thanked: 96 times
Been thanked: 19 times

Re: Loud popping sound though analog audio port

Unread post by retrodroid »

aberu wrote: Mon Feb 15, 2021 3:37 am Maybe switch to mini-TOSLINK and see if the audio problem persists. If you are using an analog I/O board, that same 3.5mm jack is simultaneously a mini-TOSLINK optical jack. So you could test it by getting a mini-TOSLINK to TOSLINK cable and getting a DAC from Amazon or something (or test on a TV/sound system with optical in, just to see the difference). I personally have used a cheap-o DAC from Amazon to convert TOSLINK optical audio to 3.5mm to get slightly better audio quality (the 3.5mm jack on the analog I/O board had some undesirable noise whenever the cores would load that I could hear with headphones on).
So you're saying use the TOSlink connector into a $20 DAC and then output analog audio? Can you confirm that this removes the popping sounds completely when loading cores?

Thx.
hiddenbyleaves
Posts: 121
Joined: Mon Nov 02, 2020 11:25 am
Has thanked: 48 times
Been thanked: 19 times

Re: Loud popping sound though analog audio port

Unread post by hiddenbyleaves »

I have the dac setup mentioned above and the popping is only audible if I put my ear right up to the speakers.
User avatar
aberu
Core Developer
Posts: 1192
Joined: Tue Jun 09, 2020 8:34 pm
Location: Longmont, CO
Has thanked: 247 times
Been thanked: 411 times
Contact:

Re: Loud popping sound though analog audio port

Unread post by aberu »

retrodroid wrote: Mon Feb 15, 2021 3:38 pm
aberu wrote: Mon Feb 15, 2021 3:37 am Maybe switch to mini-TOSLINK and see if the audio problem persists. If you are using an analog I/O board, that same 3.5mm jack is simultaneously a mini-TOSLINK optical jack. So you could test it by getting a mini-TOSLINK to TOSLINK cable and getting a DAC from Amazon or something (or test on a TV/sound system with optical in, just to see the difference). I personally have used a cheap-o DAC from Amazon to convert TOSLINK optical audio to 3.5mm to get slightly better audio quality (the 3.5mm jack on the analog I/O board had some undesirable noise whenever the cores would load that I could hear with headphones on).
So you're saying use the TOSlink connector into a $20 DAC and then output analog audio? Can you confirm that this removes the popping sounds completely when loading cores?

Thx.
I am certainly not confirming that, sorry for any misunderstanding.

I am kinda giving a shot in the dark as to one thing you could try. Regardless the optical output is objectively a cleaner audio signal than the 3.5mm analog audio on the analog I/O board, because there is a ton of noise involved with all that power being directly sent around in that board from the DE10-Nano, and optical doesn't transfer any EMI at all. It's a win win if you are pursuing objectively better sound, but given you use the arcade cab speakers, that part might not be worth it.
birdybro~
User avatar
Threepwood
Posts: 133
Joined: Mon May 25, 2020 9:14 am
Has thanked: 4 times
Been thanked: 23 times

Re: Loud popping sound though analog audio port

Unread post by Threepwood »

Well, to back you up on this, aberu, I, too, have the popping sounds on the analog 3.5mm jack. Via TOSlink there are not pops for me; just clean audio.

It is worth a shot, retrodroid. Just be aware that like on analog audio, the volume is still all over the place with the different cores. Luckily there is a fix for that: https://github.com/misteraddons/normalize_audio_scripts
robinsonb5
Posts: 130
Joined: Fri Jun 19, 2020 8:54 pm
Has thanked: 13 times
Been thanked: 58 times

Re: Loud popping sound though analog audio port

Unread post by robinsonb5 »

The popping sound is normal - it happens on pretty much all FPGA systems with analogue audio out.

The reason is that when a core's running, the audio "zero" point is half way between minimum and maximum, so that it can swing both up and down to produce the audio waveform. The core is constantly outputting alternating high and low pulses which are averaged out by a simple filter on the IO board. The ratio of high-to-low pulses determines the output voltage, but when there's no sound the ratio will be 1:1 and the output level will be 50% of maximum.

As soon as you reconfigure the FPGA by changing core that process stops, and the output voltage swings immediately to minimum (or maybe it's maximum!) for the duration of the configuration process, after which the newly-loaded core brings it back to the half-way point. Both transients cause an audible pop.
robinsonb5
Posts: 130
Joined: Fri Jun 19, 2020 8:54 pm
Has thanked: 13 times
Been thanked: 58 times

Re: Loud popping sound though analog audio port

Unread post by robinsonb5 »

So I had a little while to spare today, and experimented a bit. This could be fixed, or at least massively reduced, but it would require a change both to the main firmware and to each core.

At startup each core would have to slowly ramp its sound output from the maximum level to idle. That's enough to reduce massively the pop as a core starts.

To fix the pop as a core changes, the firmware would have to notify the core a second or so before the core change, and the core would have to ramp its audio output back up to maximum before the core change takes place.
ash2fpga
Posts: 237
Joined: Tue May 26, 2020 6:20 pm
Has thanked: 62 times
Been thanked: 28 times

Re: Loud popping sound though analog audio port

Unread post by ash2fpga »

robinsonb5 wrote: Tue Feb 16, 2021 1:15 pm To fix the pop as a core changes, the firmware would have to notify the core a second or so before the core change, and the core would have to ramp its audio output back up to maximum before the core change takes place.
Just thinking out loud, a core "shutdown" function could be useful, perhaps for other things, too (autosave write-back?).
retrodroid
Posts: 138
Joined: Tue Feb 02, 2021 5:55 pm
Has thanked: 96 times
Been thanked: 19 times

Re: Loud popping sound though analog audio port

Unread post by retrodroid »

Thanks for the confirmation and background information. Yeah, that is pretty much what I was guessing was happening and it makes perfect sense.

I also agree a graceful ramp-up/ramp-down cycle would likely prevent this issue and also offer more hooks for cores to finalize before they shutdown, etc.

I've ordered the TOSlink kit to try, better sound quality is always desired anyway, will report back once I get it configured.
robinsonb5
Posts: 130
Joined: Fri Jun 19, 2020 8:54 pm
Has thanked: 13 times
Been thanked: 58 times

Re: Loud popping sound though analog audio port

Unread post by robinsonb5 »

retrodroid wrote: Tue Feb 16, 2021 4:51 pm I also agree a graceful ramp-up/ramp-down cycle would likely prevent this issue and also offer more hooks for cores to finalize before they shutdown, etc.
As a proof of concept, here's what I see if I record my DE10-lite when uploading a core over JTAG:
Firstly an unpleasant pop as FPGA configuration starts...
Transient1.jpg
Transient1.jpg (15.2 KiB) Viewed 7810 times
...and secondly, a much more civilised transient as the FPGA leaves configuration mode and my DAC ramps from maximum to idle. This isn't *quite* silent, but it's not far off.
Transient2.jpg
Transient2.jpg (14.64 KiB) Viewed 7810 times
(I can reduce it further, at the expense of making the ramp take longer, and wasting a few more logic elements on a larger counter, but I think this is the sweet spot in terms of diminishing returns.)

I haven't verified yet that the first transient can be eliminated / reduced in the same way, but I can't see any reason why it shouldn't work.
retrodroid
Posts: 138
Joined: Tue Feb 02, 2021 5:55 pm
Has thanked: 96 times
Been thanked: 19 times

Re: Loud popping sound though analog audio port

Unread post by retrodroid »

Okay, got my TOSlink stuff connected. This is a huge improvement for sure. I had added a 128MB SDRAM board yesterday and I really noticed the background noises increase even more after that via the analog audio port, and not just when switching to a new core.

With the TOSlink pretty much all of that goes away. I do still hear the "pop" "pop" when launching a core, but it is far more subtle vs the analog port. Of course, any improvement in this regard would certainly be nice-to-have. :)

Does anyone happen to know if the hdmi_audio_96k=1 setting also works for the TOSlink audio?
User avatar
Threepwood
Posts: 133
Joined: Mon May 25, 2020 9:14 am
Has thanked: 4 times
Been thanked: 23 times

Re: Loud popping sound though analog audio port

Unread post by Threepwood »

retrodroid wrote: Wed Feb 17, 2021 11:38 pmDoes anyone happen to know if the hdmi_audio_96k=1 setting also works for the TOSlink audio?
The option mentions HDMI audio, which sounds like it does not apply here.

Unless you are recording the sound for audio production I would not bother with that option, though. It produces no hearable difference and can possibly cause issues with equipment that cannot handle 96kHz sample rates (TV, speakers, amps etc.).

The difference between 1 and 0 here is "set to 1 for 96khz/16bit HDMI audio (48khz/16bit otherwise)". 48kHz is already above the frequency range we can hear. 48kHz sample rate has 0 to 24.000Hz frequency range while infants can hear only slightly above 20.000Hz and it degrades from then on. The average adult hears 15-17kHz as upper limit. It may make more sense to have a 48kHz/24bit option instead, to have more dynamic headroom.

The exception here being audio production. If you want to sample the audio and play it back slower, stretching etc. then you need higher sample rates to keep a good frequency range.
ash2fpga
Posts: 237
Joined: Tue May 26, 2020 6:20 pm
Has thanked: 62 times
Been thanked: 28 times

Re: Loud popping sound though analog audio port

Unread post by ash2fpga »

For curiosity sake, I searched for any sort of audio spec document for toslink. I did not find one, but I did find a rather humorous article instead: https://ayrn.io/toslink-optical-connect ... khz-audio/
User avatar
Threepwood
Posts: 133
Joined: Mon May 25, 2020 9:14 am
Has thanked: 4 times
Been thanked: 23 times

Re: Loud popping sound though analog audio port

Unread post by Threepwood »

ash2fpga wrote: Thu Feb 18, 2021 4:41 pm For curiosity sake, I searched for any sort of audio spec document for toslink. I did not find one, but I did find a rather humorous article instead: https://ayrn.io/toslink-optical-connect ... khz-audio/
That was lovely tongue in cheek. Reminds me of cables by Audioquest, like their Toslink cable that goes for ~900$ for just under 10 feet length
User avatar
Threepwood
Posts: 133
Joined: Mon May 25, 2020 9:14 am
Has thanked: 4 times
Been thanked: 23 times

Re: Loud popping sound though analog audio port

Unread post by Threepwood »

retrodroid wrote: Wed Feb 17, 2021 11:38 pm With the TOSlink pretty much all of that goes away. I do still hear the "pop" "pop" when launching a core, but it is far more subtle vs the analog port.
You are right, now I noticed, too, that some cores do pop on Toslink. On Master System I never have pops, but on NES it happens when loading a game.

But to answer your question, retrodroid: I tested it and hdmi_audio_96k=1 changes the sample rate to 96kHz on Toslink as well. To test this I set the MiSTer to hdmi_audio_96k=1 and kept my sound interface at 48k Sample Rate. I then had no more audio from Toslink. Once I set the sound interface to 96k, too, I had sound again.
retrodroid
Posts: 138
Joined: Tue Feb 02, 2021 5:55 pm
Has thanked: 96 times
Been thanked: 19 times

Re: Loud popping sound though analog audio port

Unread post by retrodroid »

Thanks! It would be nice if the mister.ini comment for the setting could be updated to reflect its full impact.
robinsonb5
Posts: 130
Joined: Fri Jun 19, 2020 8:54 pm
Has thanked: 13 times
Been thanked: 58 times

Re: Loud popping sound though analog audio port

Unread post by robinsonb5 »

ash2fpga wrote: Thu Feb 18, 2021 4:41 pm For curiosity sake, I searched for any sort of audio spec document for toslink. I did not find one, but I did find a rather humorous article instead:
Ooooh - Himalayan rock salt cables - gotta have some of those! :D
tbx
Posts: 1
Joined: Sat May 08, 2021 12:23 pm
Been thanked: 1 time

Re: Loud popping sound though analog audio port

Unread post by tbx »

Sorry to bump an old post, but I wanted to say that getting a DAC (FiiO D3 https://www.amazon.com/dp/B07L61JPQW) seems to have fixed my popping problems. Thank you guys for the troubleshooting!
User avatar
aberu
Core Developer
Posts: 1192
Joined: Tue Jun 09, 2020 8:34 pm
Location: Longmont, CO
Has thanked: 247 times
Been thanked: 411 times
Contact:

Re: Loud popping sound though analog audio port

Unread post by aberu »

FiiO makes good stuff. I originally should have gotten that one instead of the cheapo amazon throwaway brand DAC I got. Mine already died. Probably a fluke but probably not.
birdybro~
Post Reply