开发者

c# How do I play multiple .wav files, and set the volume of each

I am currently playing around in c#, and I would like to have some music play in the background and to have other little sounds happen when a user hits a button or when other little actions take place. (specifically, I am making a small game, using mogre3d, and I am just to the point in which I need to add a little sound).

1) Is there a way already built in to c# to play multiple wav files at the same time? I have tried using System.Media.SoundPlayer, but that can only play one wav file at a 开发者_开发问答time (and I can not set the volume in which it is played).

2) What is the best/easiest way to play multiple sounds at a time and to be able to set each of the sounds volume?

I am dreadfully new to C#, and I am sure their must be a simple solution that I am just not seeing. It does not need to be wav, it can easily be mp3/et al. but the simpler the solution the better.

Thanks kindly for your time!


Fast

Change overall volume with that method: http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/42b46e40-4d4a-48f8-8681-9b0167cfe781 and you can play .wav files simultaneously with separate SoundPlayer instances.

Better and seperate Volumes

I would use Bass.Net. Good documentation and simple.


You can play multiple .wav files simultaneously with the System.Media.SoundPlayer class: for this, just create an instance of soundPlayer for each .wav file you wish to play. But you cannot set the volume independently this way.

If you want more functionalities with audio files, I recommend you check the NAudio library.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜