在C#中同时播放简短的.wav文件 [英] Playing short .wav files at the same time in C#

查看:106
本文介绍了在C#中同时播放简短的.wav文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#中制作了一个小型DAW应用程序并且遇到了一个大问题,到目前为止还没有找到解决方案。我需要编写一个虚拟键盘/钢琴程序来播放单击.wav文件,但是当我制作按键事件时,问题是同时播放多个文件。

例如:



Q是C音

W是D音



我想同时播放它们,所以我同时按Q和W但只有一个播放(第一个)我使用了SoundPlayer,

试图用DirectSound来做,但是无法做到。



所以,我会很高兴如果有人有足够的时间为声音播放功能编写代码snipppet,我将分配给keypress处理程序(或只有2或3个键的演示项目的示例源代码)。

SoundPlayer解决方案将更好(如果可能的话),但事实上,任何一种不是很复杂的解决方案(事实上都没关系,只需要工作并告诉我们.dlls我们欢迎(DirectX,DirectSound,NAudio)。



提前致谢。

I'm making a small DAW app in C# and have a big problem and haven't found a solution so far.I need to write a program for virtual keyboard/piano which plays single-shot .wav files, but the issue is playing multiple files at the same when I make keypress events.
For example:

Q is C tone
W is D tone

I want to play them at the same time,so I press Q and W at the same time but only one plays (the first pressed).I used SoundPlayer,
tried to do it using DirectSound, but couldn't make it.

So, I would be pleased if someone has enough time to write a code snipppet for the soundplay function, which I will assign to keypress handler(or example source code of demo project with only 2 or 3 keys ).
SoundPlayer Solution would be preferable (if possible), but in fact, any kind of solution that isn't very complex (in factm doesn't matter ,just needs to work and tell the .dlls used) is welcome (DirectX,DirectSound,NAudio).

Thanks in advance.

推荐答案

你应该使用 Polyphonic C# [ ^ ]。

(开玩笑)





看看这个 Stack Overflow 问题:同时播放两个声音 [ ^ ]。
You should use Polyphonic C#[^].
(kidding)


Have a look at this Stack Overflow question: "Play two sounds simultaneusly"[^].


这篇关于在C#中同时播放简短的.wav文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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