这是在C#编程播放多个音频文件的同时的好工具 [英] What is a good tool for programmatically playing multiple audio files at the same time in C#

查看:1392
本文介绍了这是在C#编程播放多个音频文件的同时的好工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要的东西,让我的程序在同一时间播放多个音频文件(.WAV和/或.MP3)。这将是的理想的,如果我可以简单地传递一个文件路径一些方法,它会播放该文件没有我不必担心任何的细节。

I need something that will allow my program to play several audio files (.wav and/or .mp3) at the same time. It would be ideal if I could simply pass a file path to some method, and it will play that file without me having to worry about any of the details.

附加要求:

1)我需要能够以编程方式启动和随时停止任何音频文件的播放。

1) I need to be able to programmatically start and stop the playing of any audio file at any time.

2)我需要知道什么时候每个音频文件已经通过一些财产播放完毕(通过响应事件或知道声音文件的持续时间(样本,秒等))

2) I need to know when each audio file has finished playing (by either responding to an event or by knowing the duration of the sound file (samples, seconds, etc.) through some property)

3)该工具必须能够播放.wav(和preferably .MP3)任何长度/时间的文件。

3) This tool must be able to play .wav (and preferably .mp3) files of any length/duration.

4)该工具必须能够同时播放多个音频文件(preferably至少5个或在同一时间6的音频文件)。

4) This tool must be able to play multiple audio files at the same time (preferably at least 5 or 6 audio files at the same time).

我已经尝试使用SlimDX和SharpDX,但我找不到的编程方式确定该文件何时停止播放,或找到文件的持续时间(长度)的任何方式。

I have already tried using SlimDX and SharpDX, but I could not find any way of programmatically determining when the file has stopped playing, or of finding the duration (length) of the file.

编辑:

我相信我找到了我一直在寻找! GStreamer的,似乎这样做,我是问的一切。 http://www.gstreamer.com/

I believe I found what I was looking for! GStreamer seems to do everything that I was asking for. http://www.gstreamer.com/

推荐答案

通用这个问题的答案(好了大部分的如何在框架扮演多重采样一次/语言第X 的问题)是软件搭配的文件放在一起。

The generic answer to this question (good for most of the how do I play multiple samples at once in frameworks/language X questions) is to software mix the files together.

这有给你当个人音频流启动和停止的和同步的完全控制权的利益 - 这是使用更高级别的媒体播放器组件时通常是非常困难的。

This has the benefit of giving you complete control of when the individual audio streams start and stop and of synchronisation - something that is typically very difficult when using higher level media player components.

要执行此操作步骤如下:

To steps for doing this are:


  1. 加载(和格式转换/解code)所有音频输出到内存缓冲区

  2. 对于每个音频文件中的时间在给定时刻播放时,通过将它们混合在一起,从每一个文件的对应的样本。

  3. [并非总是需要]调节所得样品的增益 - 通常这是除以混合的样本数量

  4. 结果存储到另一个内存缓冲区

您现在已经减少了你的问题,以一个单一的音频流输出。最有可能你使用自己选择的音频输出的API,它定期索取样品的缓冲输出的框架。

You have now reduced your problem to a single audio stream to output. Most likely you use your framework of choice's audio output APIs, which periodically request a buffer of samples to output.

如果您的音频流很大,这个问题变得更加复杂一点,你需要同时处理您的输入流一点。

If your audio streams are large, the problem becomes a bit more complex as you will need to process your input streams a bit at a time.

这篇关于这是在C#编程播放多个音频文件的同时的好工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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