0

I am trying to set up an Raspberry Pi / Raspbian wheezy audio player using the onboard sound hardware via ALSA LADSPA plugins to stereo downmix and compress the audio.

aplay, sox, mpg123, moc (cd ~/.moc && cp /usr/share/doc/moc/examples/config.example.gz ./ && gunzip config.example.gz && mv config.example config) work with this custom "device":

pi@raspberrypi ~ $ aplay -D mcl audiofile.wav
pi@raspberrypi ~ $ sox audiofile.wav -t alsa mcl
pi@raspberrypi ~ $ mpg123 -a mcl audiofile.mp3
pi@raspberrypi ~ $ speaker-test -t wav -c 2
pi@raspberrypi ~ $ speaker-test -t wav -c 2 -D mcl

I have built the current mpd version from source (http://www.musicpd.org/download/mpd/0.19/mpd-0.19.8.tar.xz) following this tutorial: http://www.infofreako.info/2014/04/building-mpd-on-raspberry-pi-with-opus-support/ (needs additional dependencies libboost-dev and libicu-dev)

pi@raspberrypi ~ $ mpc version
mpd version: 0.19.0
pi@raspberrypi ~ $ mpd --version
Music Player Daemon 0.19.8

but still get the error:

ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM mcl
Jan 25 10:23 : alsa_output: Failed to open "My ALSA Device" [alsa]: Failed to open ALSA device "mcl": No such file or directory
Jan 25 10:23 : output: Failed to open audio output
Jan 25 10:23 : client: [1] closed

It does work fine when using the default device (ladcomp does not work either).

So there is either something wrong/missing in my ALSA configuration that the other players are guessing or mpd is doing it wrong.

There is no /etc/asound.conf, I created the following ~/.asoundrc using several sources

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

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


###############


# compressor

pcm.ladcomp_limiter {
    type ladspa
    slave.pcm "plughw:0,0";
#    slave.pcm "default";
#    slave.pcm "makemono";

    path "/usr/lib/ladspa";
    plugins [{
        label fastLookaheadLimiter
        input {
            #InputGain(Db) -20 -> +20 ; Limit (db) -20 -> 0 ; Release time (s) 0.01 -> 2
            controls [ 20 0 0.8  ]
        }
    }]
}

pcm.ladcomp_compressor {
    type ladspa
    slave.pcm "ladcomp_limiter";
    path "/usr/lib/ladspa";
    plugins [{
        label dysonCompress
        input {
            #peak limit, release time, fast ratio, ratio
            controls [0 1 0.5 0.99]
        }
    }]
}

pcm.ladcomp {
    type plug
    slave.pcm "ladcomp_compressor";
}




### test mono downmix

#pcm.card0 {
#  type hw
#  card 0
#  device 0
#}

#ctl.card0 {
#  type hw
#  card 0
#  device 0
#}


#pcm.monocard {
#  slave.pcm card0
#  slave.channels 2
#  type plug
#}

#ctl.monocard {
#  type hw
#  card 0
#  device 0
#}

#pcm.!default monocard

####### didnt work, try this


pcm.mcl {
#pcm.makemono {
    type route
   # slave.pcm "plughw:0,0"
    slave.pcm "ladcomp"

    ttable {

    # Copy both input channels to output channel 0 (Left).
    0.0 1.0
    1.0 1.0
    # copy both input channels to output channel 1 (Right).
    0.1 1.0
    1.1 1.0
    }
}

#pcm.!default monocomplimiter


# EOF

pi@raspberrypi ~ $ grep -v '^$\|^\s*#' /etc/mpd.conf

music_directory         "/var/lib/mpd/music"
playlist_directory              "/var/lib/mpd/"
db_file                 "/var/lib/mpd/tag_cache"
log_file                        "/var/lib/mpd/mpd.log"
pid_file                        "/var/run/mpd/pid"
state_file                      "/var/lib/mpd/state"
sticker_file                   "/var/lib/mpd/sticker.sql"
user                            "mpd"
bind_to_address         "any"
metadata_to_use "artist,album,title,track,name,comment"
input {
        plugin "curl"
}
audio_output {
        type            "alsa"
        name            "My ALSA Device"
        device          "mcl"
}
mixer_type                      "disabled"
filesystem_charset              "UTF-8"
id3v1_encoding                  "UTF-8"


pi@raspberrypi ~ $ uname -r
3.18.3+

Let me know if you need more info.

Edit:

pi@raspberrypi ~ $ cat /proc/asound/cards
 0 [ALSA           ]: bcm2835 - bcm2835 ALSA
                      bcm2835 ALSA
pi@raspberrypi ~ $ cat /proc/asound/devices
  0: [ 0]   : control
  1:        : sequencer
 16: [ 0- 0]: digital audio playback
 17: [ 0- 1]: digital audio playback
 33:        : timer
pi@raspberrypi ~ $

Is there a way for ALSA to create virtual devices from the config in here, where mpd could find it (if it does search there)?

Edit:

pi@raspberrypi ~ $ cat /proc/asound/pcm
00-00: bcm2835 ALSA : bcm2835 ALSA : playback 8
00-01: bcm2835 ALSA : bcm2835 IEC958/HDMI : playback 1
pi@raspberrypi ~ $ ls /proc/asound/dev
ls: cannot access /proc/asound/dev: No such file or directory
pi@raspberrypi ~ $ ls /dev/snd
controlC0  pcmC0D0p  pcmC0D1p  seq  timer
pi@raspberrypi ~ $ ls /proc/sound/
ls: cannot access /proc/sound/: No such file or directory
pi@raspberrypi ~ $ ls /proc/sound
ls: cannot access /proc/sound: No such file or directory
pi@raspberrypi ~ $ amixer
amixer: Mixer attach default error: Invalid argument
pi@raspberrypi ~ $ alsamixer
cannot open mixer: Invalid argument
pi@raspberrypi ~ $

Edit:

pi@raspberrypi ~ $ alsamixer -c 0

works.

3

mpd's alsa output does not find the device, because it really is not defined! mpd (the daemon program) is run as user mpd which does not know about the "regular" user pis /home/pi/.asoundrc

This can be tested by running a player as user mpd:

pi@raspberrypi ~ $ sudo -u mpd speaker-test -t wav -c 2 -D mcl

I have discovered elsewhere that there is in fact an alsa configuration file

pi@raspberrypi ~ $ sudo nano /usr/share/alsa/alsa.conf

#
#  ALSA library configuration file
#

# pre-load the configuration files

@hooks [
        {
                func load
                files [
                        {
                                @func concat
                                strings [
                                        { @func datadir }
                                        "/alsa.conf.d/"
                                ]
                        }
                        "/etc/asound.conf"
                        "~/.asoundrc"
                        "/home/pi/.asoundrc" # added !
                ]
                errors false
        }
]
...

to which I have added pi's local config.

And then it works:

pi@raspberrypi ~ $ sudo -u mpd speaker-test -t wav -c 2 -D mcl

speaker-test 1.0.25

Playback device is mcl
Stream parameters are 48000Hz, S16_LE, 2 channels
WAV file(s)
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 256 to 16384
Period size range from 256 to 16384
Using max buffer size 16384
Periods = 4
was set period_size = 4096
was set buffer_size = 16384
 0 - Front Left
 1 - Front Right
Time per period = 2.944647
 0 - Front Left
^C

Also with mpd

pi@raspberrypi ~ mpc play
  • A globally available device should be put into /etc/asound.conf. A device available for the user mpd should be put into /home/mpd/.asoundrc. – CL. Jan 25 '15 at 12:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.