[英]How I can play any audiofile to any connected usb audio card?
I have PC with linux and connected there 3 usb audio interfaces. 我的电脑装有linux,并连接了3个USB音频接口。 Each audio interface has one stereo output.
每个音频接口都有一个立体声输出。 I have 6 speakers connected by 2 to each stereo output.
我有6个扬声器,每个2输出连接到2个立体声输出。
My goal is have ability to play any sound on any card on any channel. 我的目标是能够在任何频道的任何卡上播放任何声音。 For example I need to play sound of beating glass on first audiocard on left channel and play some sound of nature on second audiocard on right channel.
例如,我需要在左声道的第一个声卡上播放打玻璃的声音,并在右声道的第二个声卡上播放自然的声音。
I have looked into mpg123 but didn't found in man nothing what I want. 我调查了mpg123,但没有在人中发现我想要的东西。
My prefer to have a player with next params: 我更喜欢有一个具有下一个参数的播放器:
./example_player --audio_device=1 --channel=left glass.mp3
If no any player with my requires please advice any python library for easy make my "example_player". 如果没有符合我要求的玩家,请建议使用任何python库,以便轻松设置我的“ example_player”。
Thank you! 谢谢!
I have found the answer. 我找到了答案。 My prefer is mplayer.
我更喜欢mplayer。 It has enought functionality for my goal.
它具有足够的功能来满足我的目标。
This command: 该命令:
$ mplayer -af channels=2:2:0:0:1:0 song1.mp3
will play sound on left speaker. 将在左扬声器上播放声音。 2 (the count of output channels) : 2 (the count of moving signal) : 0:0 (left channel route to left channel) 1:0 (right channel route to left channel)
2(输出通道数):2(移动信号数):0:0(左通道至左通道)1:0(右通道至左通道)
To route sound to any audiocard you should use this command: 要将声音路由到任何声卡,应使用以下命令:
$ mplayer -ao alsa:device=hw=0.0 song2.mp3
To see all available alsa devices use this command: 要查看所有可用的alsa设备,请使用以下命令:
$ aplay -l
Here you'll see all available alsa devices. 在这里,您将看到所有可用的alsa设备。 The first digit in 'hw' param is the card number and second digit is the device number.
“硬件”参数中的第一位数字是卡号,第二位数字是设备号。
Of course you can combine these both commands: 当然,您可以结合使用这两个命令:
$ mplayer -af channels=2:2:0:0:1:0 -ao alsa:device=hw=0.0 song3.mp3
Also I found more useful solution using PulseAudio! 我也发现了使用PulseAudio的更有用的解决方案!
Use thic command to list all available audiodevices with PulseAudio: 使用thic命令列出所有带有PulseAudio的可用音频设备:
$ pactl list cards short
For example you need to output the sound to 0 card (all cards numeric begins with 0): 例如,您需要将声音输出到0卡(所有卡数字以0开头):
$ mplayer -ao --pulse::0 file.mp3
And that's works as well. 这也是可行的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.