Click here to Skip to main content
15,885,875 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
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.
Posted

1 solution

You should use Polyphonic C#[^].
(kidding)


Have a look at this Stack Overflow question: "Play two sounds simultaneusly"[^].
 
Share this answer
 
Comments
[no name] 22-May-14 12:55pm    
I think OP's problem is more how to recognize multiply key press.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900