Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Distorted sound on Raspberry Pi #299

Closed
woutervanwijk opened this Issue · 20 comments

8 participants

@woutervanwijk

Mopidy uses 95%+ CPU on my Raspberry Pi. Probably because of that, the music sounds distorted. Maybe it's my installation, but I followed the instructions and updated everything.

@adamcik
Owner

Any one have any suggestions on how to confirm this?

@jodal
Owner

I can give my RasPi a spin with an external USB sound card. I got both at home, but the USB sound card is usually used for other purposes. This is not on the top of my priority list, though.

@woutervanwijk

It would be best to try to make it work without an extra sound card imho, considering #296. With 0.8 I had it working, but I don't know why it doesn't anymore. The CPU usage isn't that important actually, the distorted sound is .

@mineur

I just did a fresh install of debian 7 on my raspberry pi and installed mopidy. Played a song from spotify through the analog sound jack and saw a CPU usage of more or less 30%.
I'm waiting for a usb sound dongle to arrive, once that's in I'll give it a go as well.

@woutervanwijk

@mineur:
And the sound quality?
I did the same, twice, and I had distorted sound and the high CPU usage.
How did you install it? Did you upgrade the kernel? Did you upgrade all packages? Followed the wiki I presume?

@mineur

@woutervanwijk
Sound quality is poor but I don't get the impression it's because of HW unable to process properly. Just the well known problem of poor sound quality of the on board sound jack. I did get much better results in terms of sound using an cheap USB sound card from sweex, but didn't test this card with mopidy yet. I tested the usb adapter using MPD and Shairport with which it gave acceptable sound quality (quality to be expected from a 10 euro USB sound dongle). I'll give the sweex dongle a go with mopidy as well later this week, just there are so many things I want to try with my RPI... I'm prioritizing stuff :)

@woutervanwijk

I build a new image, not from the official downloads of the pi, but from plain Debian. No problem. CPU usage is ~30-40%, sound is good (as good as it gets with the Pi at least)... Must be something with the official Armel distribution. I'll try an usb-soundcard too.

@herrernst

After some troubleshooing I found out that the 100% CPU usage occurs on the official Raspberry Pi image (hardfloat) only when the alsasink output is used (and only when using Spotify, local MP3 files worked). After installing Pulseaudio and switching to pulsesink it works with the expected 25-30% CPU usage.

The problem must be in the gstreamer alsasink path, because playback works with the libspotify jukebox example (in C) and also with the jukebox example from pyspotify (jukebox.py), IF I disable gstreamer (!) in spotify/audiosink/, direct output via alsa works.

I'm using the built-in analog jack.

@jodal
Owner

Thanks, this is valuable debugging info!

@jodal jodal reopened this
@woutervanwijk

I can concur with the observations of herrernst, pulse did not show the cpu-usage (but at the time I did not get sound when using pulse, so I did not know if it was doing anything).

@robhuls

I had the same problem and a solution that works for me. I had lousy sound and 100% cpu use for output on the internal sound chip as well as on an external USB DAC (Cambridge Audio, seems to use some CMEDIA chip). I threw away /etc/asound.conf and the issue went away. I had modified that file to direct output to the USB DAC in stead of the internal audio:

pcm.mmap0 {
    type mmap_emul;
    slave {
      pcm "hw:Set";
    }
}

pcm.!default {
  type plug;
  slave {
    pcm mmap0;
  }
}

I changed my /etc/modprobe.d/alsa-base.conf to ensure that the USB DAC is the first output device to have so it is not the default output device after booting:

options snd-usb-audio index=0

(I took this from http://thisoldgeek.blogspot.nl/2012_10_01_archive.html )

Sound quality over the high end audio system is still not brilliant it seems. One thing I still have to fix is output frequency, which should be 44.1 kHz bit isn't.

@kingosticks
Collaborator

I'm now getting great playback (no popping, stuttering, crackling etc) using the onboard sound and alsa with 30-40% CPU usage.

The latest 2013-02-09 Raspbian image had popping at the start and end of songs with stuttering throughout playback. Upgrading to the latest firmware has fixed the popping and the following config in ~/.asoundrc has fixed the stuttering/quality issues (taken from http://www.raspberrypi.org/phpBB3/viewtopic.php?f=66&t=7107. Note the author goes on to provide another config using mmap but that one didn't work for me):

pcm.!default {
        type hw
        card 0
}

ctl.!default {
        type hw
        card 0
}
uname -a
Linux raspberrypi 3.6.11+ #408 PREEMPT Wed Apr 10 20:33:39 BST 2013 armv6l GNU/Linux

I am now seeing the following messages in the mopidy console. They are printed on every track change but don't seem to be causing any actual problems. I've no idea what a jack server is or why it would be trying to run. I'm using mopidy 0.13.0 from apt.

Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started

UPDATE:
It seems that autoaudiosink is trying (but failing) to use jacksink, so adding OUTPUT = u'alsasink' to my settings.py is the solution (but presumably with a slightly different syntax if using the new .conf settings style).

@kingosticks
Collaborator

When I just tested playback via HDMI the quality was also fine, but I did notice the first quarter/half second of each song is skipped. So if the particular song starts right away it might sound slightly weird (e.g. the first whistle in Noah And The Whale - 5 Years Time), but if there's a pause, you don't notice. This definitely doesn't occur when using the analogue output.

@herrernst

With the latest firmware image, I can confirm the the popping when changing songs (a minor problem I also had, but not reported yet), is gone.

@herrernst

Another small note: since a few days, playback via pulseaudio is also crackling on my pi, don't know why. So I have tried ALSA again using a custom asound.conf, and now it also works through alsa.

@adamcik
Owner

Using a newly updated firmware + kernel (rpi-update + apt-get full-upgrade) and the following asound.conf I have sound that works with no issues on both analog and HDMI when using audio/output=alsasink. In other words, please test this out, then we'll update the docs and consider this fixed once again.

> cat /etc/asound.conf
pcm.!default {
        type hw
        card 0
}

ctl.!default {
        type hw
        card 0
}
> sudo /opt/vc/bin/vcgencmd version             
Apr 25 2013 01:07:36 
Copyright (c) 2012 Broadcom
version 386589 (release)
> uname -a                         
Linux raspberrypi 3.6.11+ #427 PREEMPT Fri Apr 26 20:53:06 BST 2013 armv6l GNU/Linux
@kingosticks
Collaborator

Yes, this has been working just fine for me.

@herrernst

Also works for me, not having the latest firmware.

/opt/vc/bin/vcgencmd version
Apr  2 2013 23:03:25 
Copyright (c) 2012 Broadcom
version 381148 (release)

Thanks for your efforts!

@woutervanwijk

Ill try it and close this if it works, thanks

@DennisErnens

Confirming that the above fix is working! Thanks adamcik.

uname -a
Linux raspberrypi 3.6.11+ # 434 PREEMPT Wed May 1 21:13:52 BST 2013 armv6l GNU/Linux

@adamcik adamcik closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.