我正在尝试通过 ALSA LADSPA 插件使用板载声音硬件设置 Raspberry Pi / Raspbian 喘息音频播放器来立体声缩混和压缩音频。
aplay、sox、mpg123、moc ( cd ~/.moc && cp /usr/share/doc/moc/examples/config.example.gz ./ && gunzip config.example.gz && mv config.example config
) 使用此自定义“设备”:
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
我已经从源代码构建了当前的 mpd 版本(http://www.musicpd.org/download/mpd/0.19/mpd-0.19.8.tar.xz)遵循本教程:
http://www.infofreako.info/2014/04/building-mpd-on-raspberry-pi-with-opus-support/(需要额外的依赖项libboost-dev
和libicu-dev
)
pi@raspberrypi ~ $ mpc version
mpd version: 0.19.0
pi@raspberrypi ~ $ mpd --version
Music Player Daemon 0.19.8
但仍然收到错误:
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
default
使用该设备时它确实工作正常(ladcomp
也不起作用)。
所以我的 ALSA 配置中要么有其他玩家猜测的错误/缺失,要么 mpd 做错了。
没有 /etc/asound.conf,我使用多个源创建了以下 ~/.asoundrc
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+
如果您需要更多信息,请告诉我。
编辑:
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 ~ $
有没有办法让 ALSA 从此处的配置创建虚拟设备,mpd 可以在其中找到它(如果它确实在那里搜索)?
编辑:
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 ~ $
编辑:
pi@raspberrypi ~ $ alsamixer -c 0
作品。
答案1
mpd
的alsa输出没有找到设备,因为它确实没有定义! (守护程序)以不了解“常规”用户的mpd
用户身份运行mpd
pi
/home/pi/.asoundrc
这可以通过以用户身份运行播放器来测试mpd
:
pi@raspberrypi ~ $ sudo -u mpd speaker-test -t wav -c 2 -D mcl
我在其他地方发现实际上有一个 alsa 配置文件
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
}
]
...
我已经添加了pi
本地配置。
然后它就起作用了:
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
还带有 mpd
pi@raspberrypi ~ mpc play