timrowledge
Posts: 1426
Joined: Mon Oct 29, 2012 8:12 pm
Location: Vancouver Island

ALSA sound quality issues

Thu Oct 30, 2014 9:23 pm

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.
Making Smalltalk on ARM since 1986; making your Scratch better since 2012

deivid
Posts: 52
Joined: Thu Oct 23, 2014 7:08 am

Re: ALSA sound quality issues

Thu Oct 30, 2014 11:02 pm

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

Code: Select all

pcm.!default {
        type hw
        card 0
}
ctl.!default {
        type hw
        card 0
}

Edit 2: Playing over HDMI is the problem, playing over the sound jack works OK so I'll use that for now

timrowledge
Posts: 1426
Joined: Mon Oct 29, 2012 8:12 pm
Location: Vancouver Island

Re: ALSA sound quality issues

Thu Oct 30, 2014 11:27 pm

ddivid wrote:Edit 2: Playing over HDMI is the problem, playing over the sound jack works OK so I'll use that for now
I'm using (decent) headphones from the jack. Ssssssssshhhhhhh.... hissy hissy.
Making Smalltalk on ARM since 1986; making your Scratch better since 2012

deivid
Posts: 52
Joined: Thu Oct 23, 2014 7:08 am

Re: ALSA sound quality issues

Fri Oct 31, 2014 2:33 am

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

Claytron
Posts: 10
Joined: Fri Feb 20, 2015 1:49 am

Re: ALSA sound quality issues

Tue Feb 24, 2015 11:47 am

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.

djdacore
Posts: 90
Joined: Tue Dec 09, 2014 7:47 pm

Re: ALSA sound quality issues

Wed Feb 25, 2015 8:41 am

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.

Claytron
Posts: 10
Joined: Fri Feb 20, 2015 1:49 am

Re: ALSA sound quality issues

Thu Feb 26, 2015 2:03 am

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.

User avatar
PeterO
Posts: 6095
Joined: Sun Jul 22, 2012 4:14 pm

Re: ALSA sound quality issues

Thu Feb 26, 2015 8:21 am

<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
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

User avatar
Douglas6
Posts: 5170
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, USA

Re: ALSA sound quality issues

Thu Feb 26, 2015 3:28 pm

An easy way to produce the symptoms seems to be to install and run fluidsynth.

Claytron
Posts: 10
Joined: Fri Feb 20, 2015 1:49 am

Re: ALSA sound quality issues

Fri Feb 27, 2015 12:57 am

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.

User avatar
PeterO
Posts: 6095
Joined: Sun Jul 22, 2012 4:14 pm

Re: ALSA sound quality issues

Fri Feb 27, 2015 7:10 am

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
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

Claytron
Posts: 10
Joined: Fri Feb 20, 2015 1:49 am

Re: ALSA sound quality issues

Fri Feb 27, 2015 7:28 am

Thanks @PeterO you are a legend.

User avatar
PeterO
Posts: 6095
Joined: Sun Jul 22, 2012 4:14 pm

Re: ALSA sound quality issues

Fri Feb 27, 2015 7:53 am

Claytron wrote:Thanks @PeterO you are a legend.
I can assure you I'm quite real (and still alive :-) )
Thanks anyway :lol:
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

User avatar
PeterO
Posts: 6095
Joined: Sun Jul 22, 2012 4:14 pm

Re: ALSA sound quality issues

Fri Feb 27, 2015 2:46 pm

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
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

User avatar
Douglas6
Posts: 5170
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, USA

Re: ALSA sound quality issues

Fri Feb 27, 2015 6:00 pm

PeterO wrote:So give it a try and report back your findings...
Works for me.

Of course, another 'fix' is to use a USB sound card. That also 'fixes' some other problems with snd_bcm2835 and PulseAudio, for example.

Claytron
Posts: 10
Joined: Fri Feb 20, 2015 1:49 am

Re: ALSA sound quality issues

Mon Mar 09, 2015 1:42 am

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.

brendanarnold
Posts: 1
Joined: Mon Nov 24, 2014 8:34 pm

Re: ALSA sound quality issues

Sat Apr 11, 2015 9:32 am

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

Claytron
Posts: 10
Joined: Fri Feb 20, 2015 1:49 am

Re: ALSA sound quality issues

Thu May 14, 2015 2:33 am

Bump - Are we able to get some more help from the developers on this issue?

User avatar
bobstro
Posts: 193
Joined: Wed Feb 05, 2014 6:48 am
Location: Central Massachusetts, US

Re: ALSA sound quality issues

Mon May 18, 2015 2:29 pm

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!

Claytron
Posts: 10
Joined: Fri Feb 20, 2015 1:49 am

Re: ALSA sound quality issues

Tue May 19, 2015 12:08 am

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.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 14825
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: ALSA sound quality issues

Tue May 19, 2015 12:39 am

Claytron wrote: A 3.5mm jack line out should easily run a set of headphones without an amplifier,
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
Posts: 10
Joined: Fri Feb 20, 2015 1:49 am

Re: ALSA sound quality issues

Tue May 19, 2015 12:54 am

That doesn't change the fact that there is still a white noise issue that differs between distributions, even with a stereo amplifier.

sibiquin
Posts: 21
Joined: Thu Nov 01, 2012 4:45 pm

Re: ALSA sound quality issues

Sat Jun 27, 2015 1:51 am

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.

User avatar
Greg Erskine
Posts: 246
Joined: Sat Sep 15, 2012 4:20 am
Location: Australia

Re: ALSA sound quality issues

Sat Jun 27, 2015 7:22 am

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
* Raspberry Pi is a trademark of the Raspberry Pi Foundation

sibiquin
Posts: 21
Joined: Thu Nov 01, 2012 4:45 pm

Re: ALSA sound quality issues

Sat Jun 27, 2015 9:29 pm

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

Return to “Graphics, sound and multimedia”