• Advertisement

Archived

This topic is now archived and is closed to further replies.

C# Sound playing sound

This topic is 5031 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, Does anybody know how to play Sound in C#? I know how to play a sound ASYNC but what I want to do is play background music and make it loop forever. How do I do that? Also, is there anyway for the background music to loop and then play a sound of like a button been clicked so you here them both? I am using GDI+. Thanks, Rob

Share this post


Link to post
Share on other sites
Advertisement
Ok, I finally mangedto loop background sound win winmm.dll but now an even bigger problem. It only plays one sound at a time. How do I make it play more then ONE sound at the same time? Like Background music looping and abutton been clicked?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Try http://nbass.sourceforge.net/ (C# Sound library)
Tutorial: http://www.codeproject.com/cs/media/nbass.asp

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Might be easier to use something like SDL.NET (http://cs-sdl.sourceforge.net/). It supports alot of audio formats.

Share this post


Link to post
Share on other sites
Cannot this be done win winmm.dll? I don''t really want to use 3rd party dlls but just the built in system dlls. Anyway of doing that?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Try using managed DirectSound.

Share this post


Link to post
Share on other sites
DirectX9 is not the most compatable of producta for small games like mine.

Share this post


Link to post
Share on other sites
quote:
Original post by rob64464
DirectX9 is not the most compatable of producta for small games like mine.

I have no idea what you mean by that. What''s compatible in this context ? At least it''s an API that abstracts your hardware and allows you to play a sound no matter what kind of soundcard you have.

Also the original poster uses C#, if he targets Windows, why not use DirectX then ?

Share this post


Link to post
Share on other sites
Well nearly everybody has DX7 but DX9 is to new and then you get people who never download the latest version and when they download the game it won''t work right so they will uninstall it.

Share this post


Link to post
Share on other sites
I understand your frustration. You just want to play a few sounds and have windows mix them for you. Unfortunately there's not a very clear roadmap for your needs, especially if you do not want to want to make the user download something.

The fact of the matter is that the "official" (if such a thing exists) multimedia sound API for C# is DX9. Since you have chosen a managed language there is a decent chance that your end-user is going to have to download the .Net runtime so maybe having them download DX9 is not too unreasonable to ask. With that being said...

Given what you have said so far and assuming that you don't want to use a 3rd party lib I suspect that that best path for you will be to come up with a simple sound API that can be called from C# and write an unmanaged dll that implements it. Then you can code it to DX7 or whatever minimum level of DX you want to assume that your end user has.

If you want to stick with winmm.dll I think you're going to have to do you own sound mixing in software which can be quite a pain. But again if it's hidden behind an API you can try out several different strategies and see which works best for you.

Edit: Fixed typos

[edited by - mauman on May 10, 2004 11:31:37 AM]

Share this post


Link to post
Share on other sites
luckly for me my sound can be converted to a midi file so then I can play it as a midi but that is causing me a lot of problems because I can not find a wav to midi converter which can convert a sound of this spec:

BitRate: 89kbps
Audio Sample Size: 4 bit
Channels: 1 mono
Audio Sample rate: 22khz
Audio Format: ADPCM

toa midi file any ideas?

Thanks,
Rob,

Share this post


Link to post
Share on other sites
uhm...you are aware of that midi-files are pretty much just digital note-sheets?

-Luctus

Statisticly seen, most things happens to other people.
[Mail]


[edited by - Luctus on May 10, 2004 10:56:35 PM]

Share this post


Link to post
Share on other sites

  • Advertisement