本文档主要包括两个部分:
1:如何将一首超过两声道的多声道音乐放到多个双声道声卡上播放,来模拟原音乐文件的多声道输出。
2:如何将多个双声道音乐文件同时放到一个8声道的声卡的不同channel上播放。
涉及的文件:etc/asound.conf
1:如何将一首超过两声道的多声道音乐放到多个双声道声卡上播放,来模拟原音乐文件的多声道输出。
1):Sabresd板子
按设计来讲,sabresd板子最多只能播双声道的音乐,但是如果一个音乐文件是四声道,该如何用sabresd板子来播放呢?
可以让前两个声道通过WM8962来播放,后两个声道通过HDMI来播放:
33 pcm.multi {
34 type multi
35
36 slaves.a.pcm "hw:0,0"
37 slaves.a.channels 2
38 slaves.b.pcm "hw:1,0"
39 slaves.b.channels 2
40
41 bindings.0.slave a
42 bindings.0.channel 0
43 bindings.1.slave a
44 bindings.1.channel 1
45 bindings.2.slave b
46 bindings.2.channel 0
47 bindings.3.slave b
48 bindings.3.channel 1
49 }
273 pcm.asymed{
274 type asym
275 playback.pcm "multi"
276 capture.pcm "dsnoop_44100"
277 }
278
279 ctl.multi{
280 type hw;
281 card 0;
282 }
289 pcm.!default{
290 type plug
291 route_policy "average"
292 slave.pcm "asymed"
293 }
可以通过以下命令来测试:
speaker-test -c 4 -t sine
speaker-test -c 4 -t sine -D multi
2):ARD板子
ARD板子,6声道的audio文件,用ESAI来播放前四个channel,后两个channel用HDMI来播放:
33 pcm.multi {
34 type multi
35
36 slaves.a.pcm "hw:0,0"
37 slaves.a.channels 4
38 slaves.b.pcm "hw:2,0"
39 slaves.b.channels 2
40
41 bindings.0.slave a
42 bindings.0.channel 0
43 bindings.1.slave a
44 bindings.1.channel 1
45 bindings.2.slave a
46 bindings.2.channel 2
47 bindings.3.slave a
48 bindings.3.channel 3
49 bindings.4.slave b
50 bindings.4.channel 0
51 bindings.5.slave b
52 bindings.5.channel 1
53 }
273 pcm.asymed{
274 type asym
275 playback.pcm "multi"
276 capture.pcm "dsnoop_44100"
277 }
278
279 ctl.multi{
280 type hw;
281 card 0;
282 }
289 pcm.!default{
290 type plug
291 route_policy "average"
292 slave.pcm "asymed"
293 }
可以用下面命令来测试:
播源文件是6声道的音乐:
aplay 48kHz16bit-six-channel.wav
aplay -D multi 48kHz16bit-six-channel.wav
speaker-test -c 6 -t sine
speaker-test -c 6 -t sine -D multi
播源文件是双声道的音乐,ESAI的四个channel和HDMI的两个声道都是该音乐:
aplay heart.wav
2:如何将多个双声道音乐文件同时放到一个8声道的声卡的不同channel上播放。
我们ARD的板子,ESAI是8声道的,大部分音乐都是双声道的,ESAI的6个channel会被浪费掉。如何将其余的6个声道也应用起来?
alsa lib有dshare这个plugin,可以将4个双声道的音乐文件当成一个8声道的音乐来处理。 28 pcm_slave.nforce {
29 pcm "hw:0,0”
30 channels 8
31 rate 48000 # fixed, because all dshare devices must use the same samplerate.
32 buffer_size 4096 # make these sizes smaller for lower latency
33 period_size 1024
34 periods 4
35 period_time 0
36 }
37
39 pcm.ch12 {
40 type dshare
41 ipc_key 47110815
42 slave nforce
43 bindings.0 0
44 bindings.1 1
45 }
46
47 pcm.ch34 {
48 type dshare
49 ipc_key 47110815
50 slave nforce
51 bindings.0 2
52 bindings.1 3
53 }
54
55 pcm.ch56 {
56 type dshare
57 ipc_key 47110815
58 slave nforce
59 bindings.0 4
60 bindings.1 5
61 }
62
63 pcm.ch78 {
64 type dshare
65 ipc_key 47110815
66 slave nforce
67 bindings.0 6
68 bindings.1 7
69 }
可以通过下面的命令来测试:
(aplay -Dplug:ch12 XX.wav &)
(aplay -Dplug:ch34 XXX.wav &)
(aplay -Dplug:ch56 XXXX.wav &)
(aplay -Dplug:ch78 XXXXX.wav &)
四首音乐会分配到ESAI的8个channel上。
如果开发板有多个双声道声卡(不超过8个),每个声卡同时播放不同的双声道音源,alsa的aplay播放器可以实现吗?