I don't do a great deal with sound output on my Pi, really just checking that the new Scratch makes the right noises. I don't expect fabulous quality without an external sound widget but it seems that some time recently something has happened to make the sounds I hear go from OK to Yuck.
I double checked by trying out SonicPi and the noises are no better, so I feel reasonably confident it's not my code that has gone wrong. The basic issue is that when there is supposed to be silence 'playing' it's actually really annoying white noise. Explicitly turning off the sound (which at least from the Squeak point of view means stopping feeding anything at all to ALSA rather than playing null samples) works to silence things completely. SonicPi seems to leave its sound process running and the white noise just goes on until I quit it.
Anybody else noticed a recent-ish change in the quality of silence? I'm more than willing to believe that the ALSA libraries have changed for the worse; almost my only experience in dealing with them has been with the completely broken handling of interrupt handlers that was causing client applications to lock up the entire OS.
-
- Posts: 1426
- Joined: Mon Oct 29, 2012 8:12 pm
- Location: Vancouver Island
ALSA sound quality issues
Making Smalltalk on ARM since 1986; making your Scratch better since 2012
Re: ALSA sound quality issues
I tested my audio output and you are right, the sound quality sucks. I was using a bluetooth headset and it worked alright, now the distortion is huge.
Running hello_audio.bin works ok over HDMI, but aplay (with -r 44100 or 48000), omxplayer and mpg123 all give me very distorted sound. Anyone has any idea?
Edit: This is clearly alsa doing something wrong, I used t o have it working. I'll see if I can find the problem
.asoundrc
Edit 2: Playing over HDMI is the problem, playing over the sound jack works OK so I'll use that for now
Running hello_audio.bin works ok over HDMI, but aplay (with -r 44100 or 48000), omxplayer and mpg123 all give me very distorted sound. Anyone has any idea?
Edit: This is clearly alsa doing something wrong, I used t o have it working. I'll see if I can find the problem
.asoundrc
Code: Select all
pcm.!default {
type hw
card 0
}
ctl.!default {
type hw
card 0
}
-
- Posts: 1426
- Joined: Mon Oct 29, 2012 8:12 pm
- Location: Vancouver Island
Re: ALSA sound quality issues
I'm using (decent) headphones from the jack. Ssssssssshhhhhhh.... hissy hissy.ddivid wrote:Edit 2: Playing over HDMI is the problem, playing over the sound jack works OK so I'll use that for now
Making Smalltalk on ARM since 1986; making your Scratch better since 2012
Re: ALSA sound quality issues
The analog output doesn't have that much power, you most likely need an amp. Over HDMI I had unbearable distortion, if there's distortion over my analog output, it's not that much and is enough for my intended purpose
Re: ALSA sound quality issues
I have this issue on my Rpi2 with Retropie & Emulation station. Whilst an emulator is running the sound is fine, but as soon as you quit the emulator or you are at the linux console there is very noticeable white noise from the 3.5mnm jack when no signal is playing. I would love to know what software setting to tweak to change this, or if this is actually a hardware issue.
Re: ALSA sound quality issues
You mean the 'noise' when there is no sound, or no music? It's like a normal radio when there is no station?
Maybe there is a program that will kill the noise when there is no music/sound played. I have the same 'problem'.
You can't expect too much from the Pi1 or 2. I have that problem on RPI 1 but even on the RPI2 I have the same.
The best solution is to get an external soundcard.
Maybe there is a program that will kill the noise when there is no music/sound played. I have the same 'problem'.
You can't expect too much from the Pi1 or 2. I have that problem on RPI 1 but even on the RPI2 I have the same.
The best solution is to get an external soundcard.
Re: ALSA sound quality issues
Yes it's like a radio not tuned into a station when no music is playing. That static is white noise. I found the problem doesn't exist for HDMI output only 3.5mm jack. Some programs seem to be able to mute it / cut the sound output so I have a feeling it is software.
Re: ALSA sound quality issues
<Me Too>
Yesterday I discovered that the software I will be using in a talk at the Birthday Weekend now produced a very annoying "HISSSS" when it should be silent.
Is anyone at the foundation looking at this as it is really rather annoying !
PeterO
Yesterday I discovered that the software I will be using in a talk at the Birthday Weekend now produced a very annoying "HISSSS" when it should be silent.
Is anyone at the foundation looking at this as it is really rather annoying !
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
Re: ALSA sound quality issues
An easy way to produce the symptoms seems to be to install and run fluidsynth.
Re: ALSA sound quality issues
I'm going to purchase a HDMI adaptor that breaks out the analog signal given the HDMI seems to be working without issue on the TV. It would be nice if one of the Pi developers could address the issue with the output to the 3.5mm jack.
Re: ALSA sound quality issues
This is NOT an ALSA issue. I have an application that bypasses ALSA and uses the openMAX IL client interface, and the same problem is present. I think this is a RPI firmware issue with the PWM output driver used for the audio output.
I've put in a "issue" on the firmware github.
PeterO
I've put in a "issue" on the firmware github.
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
Re: ALSA sound quality issues
Thanks @PeterO you are a legend.
Re: ALSA sound quality issues
I can assure you I'm quite real (and still aliveClaytron wrote:Thanks @PeterO you are a legend.

Thanks anyway

Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
Re: ALSA sound quality issues
The firmware guys asked me to try adding "disable_audio_dither=1" to config.txt This does seem to have stopped the "HISS" but it does have a downside in that "In effect you get slightly more distortion without dither than with."
So give it a try and report back your findings...
I hope a better fix will be along later.
PeterO
So give it a try and report back your findings...
I hope a better fix will be along later.
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
Re: ALSA sound quality issues
Works for me.PeterO wrote:So give it a try and report back your findings...
Of course, another 'fix' is to use a USB sound card. That also 'fixes' some other problems with snd_bcm2835 and PulseAudio, for example.
Re: ALSA sound quality issues
Ok so adding disable_audio_dither=1 to your config.txt will prevent the white noise (hiss) from being played from the 3.5mm jack when there is no sound output on a program / game. This fixes the issue on the Retro-Pie distribution with emulation station. Thank you very much for finding the solution to that.
What I have noticed on the Raspbian distribution is that the white noise is noticeable when sound is playing. Try some of the python games (tetris) and you will hear the noise floor has been raised in the background of the music. This issue doesn't exist when music is played on emulator on the Retro-pie distribution. I notice that sound is managed by retroarch on Retro-pie, so I imagine there is some software config setting that is breaking the sound quality on Raspbian. Do the gurus have any ideas?
I have tried using both Alsa and SDL on Retro-pie, but I couldn't introduce the issue on that distro.
I will keep hacking around to try find out what is going on but I'm not a linux software expert.
What I have noticed on the Raspbian distribution is that the white noise is noticeable when sound is playing. Try some of the python games (tetris) and you will hear the noise floor has been raised in the background of the music. This issue doesn't exist when music is played on emulator on the Retro-pie distribution. I notice that sound is managed by retroarch on Retro-pie, so I imagine there is some software config setting that is breaking the sound quality on Raspbian. Do the gurus have any ideas?
I have tried using both Alsa and SDL on Retro-pie, but I couldn't introduce the issue on that distro.
I will keep hacking around to try find out what is going on but I'm not a linux software expert.
-
- Posts: 1
- Joined: Mon Nov 24, 2014 8:34 pm
Re: ALSA sound quality issues
I can confirm that this happens on a model B+ and a model A+ for .wav files played through the pygame library.
The hiss is only present when playing sound.
The hiss is not present on an earlier model B running similar code and files.
Cheers,
Brendan
The hiss is only present when playing sound.
The hiss is not present on an earlier model B running similar code and files.
Cheers,
Brendan
Re: ALSA sound quality issues
Bump - Are we able to get some more help from the developers on this issue?
Re: ALSA sound quality issues
I think your help has been listed above. There are several possible solutions:
1. Add disable_audio_dither=1 to /boot/config.txt
2. Use an amplifier. The output is not meant to drive headphones directly.
3. Pick up a $7 USB audio adapter.
4. Pick up a $15 HDMI sound extractor.
The RPI was not sold as a high-fidelity audio device. These solutions will help. Try your HDMI extractor and please let us know how that worked for you!
1. Add disable_audio_dither=1 to /boot/config.txt
2. Use an amplifier. The output is not meant to drive headphones directly.
3. Pick up a $7 USB audio adapter.
4. Pick up a $15 HDMI sound extractor.
The RPI was not sold as a high-fidelity audio device. These solutions will help. Try your HDMI extractor and please let us know how that worked for you!
Re: ALSA sound quality issues
No, the issue seems to be software, possibly firmware setting.
A 3.5mm jack line out should easily run a set of headphones without an amplifier, in any case the noise is still present with an amplifier.
3&4 are not solutions to the existing problem but work arounds. I'm looking to have the actual issue resolved so the Pi works as expected out of the box without users having to waste money.
A 3.5mm jack line out should easily run a set of headphones without an amplifier, in any case the noise is still present with an amplifier.
3&4 are not solutions to the existing problem but work arounds. I'm looking to have the actual issue resolved so the Pi works as expected out of the box without users having to waste money.
- mahjongg
- Forum Moderator
- Posts: 14825
- Joined: Sun Mar 11, 2012 12:19 am
- Location: South Holland, The Netherlands
Re: ALSA sound quality issues
you are wrong there! The 3.5mm jack output is NOT designed, or capable of, driving a headphone, just a >10K Ohm stereo amplifier input!Claytron wrote: A 3.5mm jack line out should easily run a set of headphones without an amplifier,
Re: ALSA sound quality issues
That doesn't change the fact that there is still a white noise issue that differs between distributions, even with a stereo amplifier.
Re: ALSA sound quality issues
I understand that the analog output "is not designed for high quality audio", but the noise level in the Pi 2 is defective - the S/N is probably 30db... worse than a transistor radio tuned to an AM station. The audio of the model 1 was quite acceptable, no noticeable noise for normal headphone listening, the model 2 is un-listenable. A major step backwards in quality. The foundation should have saved some money and just eliminated the analog output as it is unusable in its current state. I have no idea if the root of the problem is software or hardware, from my reading there has not been serious investigation. Adding "disable_audio_dithering=1" in config.txt made no difference. When playing a sound file (with aplay) the noise is awful. It seems to be quiet when there is no audio being played (which tilts the odds toward a software issue - the output is not inherently electrically noisy).
There are plenty of applications for which this output is important, it would be great if there was a real investigation into the cause and possible solution.
There are plenty of applications for which this output is important, it would be great if there was a real investigation into the cause and possible solution.
- Greg Erskine
- Posts: 246
- Joined: Sat Sep 15, 2012 4:20 am
- Location: Australia
Re: ALSA sound quality issues
hi sibiquin,
Are you referring to the hissing or that actual quality of the sound?
For the hissing issue the command is:
disable_audio_dither=1
not
disable_audio_dithering=1
regards
Greg
Are you referring to the hissing or that actual quality of the sound?
For the hissing issue the command is:
disable_audio_dither=1
not
disable_audio_dithering=1
regards
Greg
* Raspberry Pi is a trademark of the Raspberry Pi Foundation
Re: ALSA sound quality issues
I made a typo in the post, the setting in my config.txt is correct.
The problem is both noise and distortion.
I have referenced 2 audio clips below so you can hear exactly what I am hearing. The first is pi_test.wav. It has 3 seconds of digital silence, followed by 6 seconds of piano notes. This file is uncompressed 16-bit LE encoded. It plays clear as a bell on any audio platform, including the Pi 1.
The second file is recorded off the Pi 2 analog audio output with a high quality digital recorder (Alesis HD24). The recording was started 3 seconds before running "aplay pi_test.wav". So it contains 3 seconds with no audio application running, followed by 3 seconds of silent audio, followed by 6 seconds of piano notes.
Examination of the recording reveals:
1. With no audio application running the Pi 2 audio output has a noise floor of about -50db (relative to the peak value of the recording, which is -6db). This is a very noticeable hiss in a quite environment or with headphones. Spectral analysis shows that it is not pure white noise, it is weighted below 1kHz.
2. With an audio application outputting digital silence the noise floor is -24db (relative). This is un-listenable noise even for a low quality audio device. This noise appears more evenly spread on the frequency spectrum with a slight increase below 1kHz (this is probably a summing of the no-audio noise and some additional noise source).
3. The piano sounds are subtly distorted. It is very noticeable as the last note fades away, there is a kind of 'phasing' effect, like something in the audio chain is making sampling errors.
I wrote my own audio application to play back this file in the Pi 2 using the ALSA interface and it sounds exactly the same.
I tried to attach these to this post but WAV is not an allowed extension, so you can find them here:
http://cabintechglobal.com/wav/pi_test.wav
http://cabintechglobal.com/wav/pi_test_recorded.wav
The problem is both noise and distortion.
I have referenced 2 audio clips below so you can hear exactly what I am hearing. The first is pi_test.wav. It has 3 seconds of digital silence, followed by 6 seconds of piano notes. This file is uncompressed 16-bit LE encoded. It plays clear as a bell on any audio platform, including the Pi 1.
The second file is recorded off the Pi 2 analog audio output with a high quality digital recorder (Alesis HD24). The recording was started 3 seconds before running "aplay pi_test.wav". So it contains 3 seconds with no audio application running, followed by 3 seconds of silent audio, followed by 6 seconds of piano notes.
Examination of the recording reveals:
1. With no audio application running the Pi 2 audio output has a noise floor of about -50db (relative to the peak value of the recording, which is -6db). This is a very noticeable hiss in a quite environment or with headphones. Spectral analysis shows that it is not pure white noise, it is weighted below 1kHz.
2. With an audio application outputting digital silence the noise floor is -24db (relative). This is un-listenable noise even for a low quality audio device. This noise appears more evenly spread on the frequency spectrum with a slight increase below 1kHz (this is probably a summing of the no-audio noise and some additional noise source).
3. The piano sounds are subtly distorted. It is very noticeable as the last note fades away, there is a kind of 'phasing' effect, like something in the audio chain is making sampling errors.
I wrote my own audio application to play back this file in the Pi 2 using the ALSA interface and it sounds exactly the same.
I tried to attach these to this post but WAV is not an allowed extension, so you can find them here:
http://cabintechglobal.com/wav/pi_test.wav
http://cabintechglobal.com/wav/pi_test_recorded.wav