Playing Audio in .Net / C#

I have used this sample in several projects with good results. It is basically a .Net wrapper for Windows Waveform Audio API using P/Invoke. Other choices:

  • NAudio
  • Sound Player class from .Net framework

I have created a class that can play audio given Stream derivate as an input. So if you are able to pack your sound-generator into the Stream compatible interface, it could be suitable for you.

How I did it - I used unmanaged waveOut* methods from old Windows multimedia API, and handled the playback from there.

Other options - that I am aware of - use waveOut directly, from this: http://windowsmedianet.sourceforge.net/ or write your own DirectShow source filter, but that might be too complicated, since it has to be written in c++.

If you are interested in giving my component a try, I can make it available to you at no charge, since I need it beta tested (I only used it in several of my projects).

EDIT:

Since there are 6 upvotes to the question, I am offering my component free of charge (if you find useful) here: http://dl.dropbox.com/u/10020780/SimpleAudioPlayer.zip

Maybe you can reflect on it :)


I use Audiere to accomplish this and find it works very well.

It's a C++ lib really, but there are a set of bindings available for C#.

For more info, see the question I asked.