ALSA Api:如何同时播放两个wave文件? [英] ALSA Api: How to play two wave files simultaneously?

查看:313
本文介绍了ALSA Api:如何同时播放两个wave文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

播放两个重叠的独立wavefile所需的API配置/调用是什么? 我试图这样做,却出现资源繁忙错误.一些解决问题的指针将非常有帮助.

What is the required API configuration/call for playing two independent wavefiles overlapped ? I tried to do so , I am getting resource busy error. Some pointers to solve the problem will be very helpful.

以下是第二个波形文件的snd_pcm_prepare()中的错误消息

Following is the error message from snd_pcm_prepare() of the second wavefile

"Device or resource busy"

推荐答案

ALSA不提供混合器.如果需要同时播放多个音频流,则需要自己将它们混合在一起.

ALSA does not provide a mixer. If you need to play multiple audio streams at the same time, you need to mix them together on your own.

最简单的方法是将WAV文件解码为float个样本,添加它们,然后在将它们转换回整数样本时对其进行裁剪.

The easiest way this can be accomplished is by decoding the WAV files to float samples, add them, and clip them when converting them back to integer samples.

或者,您可以尝试多次打开默认音频设备(而不是"em> not "诸如"hw:0"之类的硬件设备),一次为您希望的每个流打开一次播放,并希望dmix ALSA插件已加载,并将提供混合功能.

Alternatively, you can try to open the default audio device (and not a hardware device like "hw:0") multiple times, once for each stream you wish to play, and hope that the dmix ALSA plugin is loaded and will provide the mixing functionality.

这篇关于ALSA Api:如何同时播放两个wave文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆