3

My pi is plugged to my tv and I have installed mopidy.

Everything is ok, the sound is played through my tv, except that the sound quality is terrible. I mean, it is not listenable at all.

When I play movie the sound is ok.

I have the default settings (alsa, ...) and I don't use a X server, only command lines.

Ghanima
  • 15,958
  • 17
  • 65
  • 125
tibo
  • 131
  • 1
  • 4

5 Answers5

2

From the Mopidy website:

The Raspberry Pi’s audio quality can be sub-par through the analog output. This is known and unlikely to be fixed as including any higher-quality hardware would increase the cost of the board. If you experience crackling/hissing or skipping audio, you may want to try a USB sound card. Additionally, you could lower your default ALSA sampling rate to 22KHz, though this will lead to a substantial decrease in sound quality.

Many companies have recognized this issue though, and here is one that works quite well. The official forums have had a running discussion on the topic, and here is a link to one of the setup tutorials.

The instructions are below (Note: they were tested with the sound card linked in my answer):

  1. Make the USB card the primary device. Type this in terminal.

    sudo nano/etc/modprobe.d/alsa-base.conf 
    Made the following entries in the file
    #options snd-usb-audio index=-2
    options snd_bcm2835=-2
    
    exit
    reboot
    
  2. Then, add the following line to the /boot/cmdline.txt

    dwc_otg.speed=1
    
  3. In your home directory create a ~/.libao file in your home directory and enter the following:

    driver=alsa
    dev=default
    
  4. Lastly create a ~/.asoundrc in your home directory and enter the following:

Line here to make it so that I don't have to enter tons of code.

pcm.!default {
              type asym
              playback.pcm "defaultplayback"
              capture.pcm "defaultrec"
                hint{   show on
                   description "default play and rec koko"
                }
      }

      pcm.defaultrec {
              type plug
              slave {
                  pcm "hw:0,0"
                  rate 48000 
                  channels 2
                  format S16_LE
              }
                hint{   show on
                   description "default rec koko"
                }

      }

  pcm.defaultplayback{
          type rate
          slave.pcm mix1
          slave.rate 48000 

          #Intel(R) Core(TM)2 Duo CPU     E7500  @ 2.93GHz:

            #converter "samplerate_best"     # perfect: 16%cpu, maybe overkill
            #converter "samplerate_medium"   # almost perfect: 6%cpu
            #converter "samplerate"          # good: 4%cpu, definitely usable
            #converter "samplerate_linear"   # bad: 2%cpu, way better than default wine resampler
            #converter "samplerate_order"    # very bad: 2%cpu, like the default wine resampler

          converter "samplerate"

            hint{   show on
                   description "default play koko"
            }
  }

    pcm.mix1 {
            type dmix
            ipc_key 1024
            slave {
                pcm "hw:0,0"
                rate 48000
                periods 128
                period_time 0
                period_size 1024 # must be power of 2
                buffer_size 65536

            }
    }
xxmbabanexx
  • 3,278
  • 7
  • 36
  • 56
1

I had the same problem with Pi MusicBox. I reinstalled everything and the problem was gond. I really don't know what fixed it. It just was gone. You could try to look at the files I changed for musicbox: https://github.com/woutervanwijk/Pi-MusicBox/tree/master/filechanges/etc

1

The pulseaudio workaround shouldn't be needed if you follow the instructions in http://docs.mopidy.com/en/latest/installation/raspberrypi/#fixing-audio-quality-issues At the time of writing that answer was correct, but with a newer raspi firmware and the right asound settings as mentioned above you should get working sound without pulseaudio.

Thomas A.
  • 36
  • 1
0

The only work around I have found is to install pulseaudio and to configure mopidy to use pulseaudio. Now everything works perfectly but I still have no idea about the cause of the problem nor how to fix it using alsa... Linux and the sound, a long sad story...

tibo
  • 131
  • 1
  • 4
0

I've had success using the analogue output by updating the firmware with rpi-update to the latest version and putting the following in ~/.asoundrc:

pcm.!default {
        type hw
        card 0
}

ctl.!default {
        type hw
        card 0
}

(Taken from http://www.raspberrypi.org/phpBB3/viewtopic.php?f=66&t=7107)

However, I found that when using HDMI output with this, the first quarter-ish second of each song was skipped. Sometimes it's quite noticeable but it entirely depends on the song.