How to play mp3 using AsioDriver and NAudio?

Dec 27, 2011 at 7:31 AM

I want to write a program to play mp3 to multiple channels of sound card. I use M-audio fast track pro sound which has got 4in/4out.

But when i use some function in winmm.dll so i just get only 1 output device, but i thinks it must be return me 4 output device.

I search on the google and found NAudio library, and i hear some body say that if i use AsioDriver i can play multiple mp3 file to multiple output channels.

I had download and run the NAudioDemo, and select  AsioDriver, in that example i just can play the .wave file for Asio

My question is how to play mp3 file with AsioOut.

Could you help me?

Dec 27, 2011 at 2:12 PM


NAudio isn't particularly well set up to do this, but it is possible by creating a 4 channel wavestream that multiplexes two MP3 streams together. You would have to write that class yourself though. It's a possible feature for a future NAudio, but will have to wait until I own a multi-out soundcard myself ;)


Dec 28, 2011 at 3:04 AM

Now i have a new problem.

Some time before i use libZPlayer to play mp3 file, i create an install pagkage and deploy to others computer it run ok.

But now i change libZplay and use NAudio to play mp3 music, i create install pagkage and deploy to others computer, when i run the application i get a Just-In-Time Debugger

with the error: An unhandled win32 exception occured in my application.

then i click Yes button to debug i get assembly  code, so i can not determine error in what class

How to solve this problem?

Dec 28, 2011 at 6:41 AM

Can you try to play this using the NAudio demo application that comes with the latest NAudio? Also if possible, download the latest NAudio source code and run it through Visual Studio in the debugger. We need to know at what point the exception is happening (e.g. opening the ASIO driver, or during playback


Dec 30, 2011 at 10:30 AM

I see the exception An unhandled win32 exception occured in my application,i think i cause from NAudio, because in NAudio have some unmanage code, but now i reconize that it not cause by NAudi, the NAudio run OK, the error cause bacause set an icon my form, the icon is a bad image so it cause the error.

Now i have one more question.

I want to use WaveOut to play mp3, my question is could i determine my output sound card have multi channels. for example if the output have left side, right side, and center.

I want to one mp3 to left side, one different mp3 to right side, one for center.


How to implement that?

Jan 3, 2012 at 1:18 PM

it depends on your soundcard drivers - they may not allow you to open WaveOut with multiple outputs. But if you can open with 3 or four channels, then you would need to make your own derived IWaveProvider that read from your source streams and interleaved the samples correctly to go to each channel in turn.