简体   繁体   English

如何将音频文件播放到任何已连接的USB音频卡?

[英]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.

相关问题 如何列出在USB大容量存储模式下通过电话连接到Linux的SD卡的内容? - How can I list the contents of an SD card connected to Linux via a phone in USB Mass Storage Mode? 我可以读取与 USB 卡读写器连接的 SD 卡序列号作为挂载的 sda 吗? - Can I read SD card serial number connected with USB card reader/writer as mounted sda? 我需要找到如何区分USB已连接和读卡器也已连接到Linux中的目标 - I need to find how to differentiate between usb is connected and card reader is also connected to target in linux 如何在Raspberry Pi上使用c ++ / libao / alsa通过USB声卡播放音频? - How to play audio via a USB sound card using c++/libao/alsa on Raspberry Pi? 在Raspberry PI中,我如何才能达到对SD卡的最小写入周期并使RPI随时拔出? - In Raspberry PI how can I achieve minimum write cycles to SD card and make RPI unplugged at any moment? 如何确定连接的USB设备是否为USB闪存盘? - How do I determine if a connected USB device is a USB flash drive? 如何以编程方式确定设备是否已连接到音频插孔? - How can I programmatically determine if a device is connected to an audio jack? 如何在Linux上使用带有ffmpeg的C ++从USB音频设备录制音频? - How can I record an audio from USB audio device using C++ with ffmpeg on Linux? 如何在Linux上使用Qt或任何其他cpp框架播放wma音频文件? - How to play a wma audio file using Qt or any other cpp framework on linux? 我如何跟踪将数据从任何外部USB传输到PC(Linux)的过程? - How do i track the process of transferringt data from any external usb to PC (linux) ?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM