This project has moved and is read-only. For the latest updates, please go here.

Multiple dsound devices on single app

Aug 4, 2011 at 9:39 AM

Hi, I've an application which needs to play up to 5 different files at the same time, keeping them synchronized (latency is not a big problem). They could are mono, stereo, 24bit or 16bit all mixed togheter.

So I create a wavestream32 for each file, with a device for each one. Note that I reuse the device so each time a file is opened I do a device.init(stream). And this is the first question. Is this correct? I've read here that this is not a good idea for old WaveOut devices this is also true for DSound?

The problem is that if I run the application in debug mode everything works fine, but in release... after the first 2/3 files the playing fails in a very weird manner... the position will move faster or stops. it seems sometimes that NAUDIO takes out more bytes than needed or at least skips some of them.

It's a very complex situation because I use many threads so.... you know.

I want only know if there's some best practice when dealing with the playing of multiple files at once (whithout using the wavemixer32).

Thank you



Aug 8, 2011 at 4:10 PM

by far the best way to keep things synchronized is to use a mixer stream. If you absolutely must do it another way, then you need a thread that is watching for things getting out of sync. I also recommend creating a new instance of DirectSoundOut for each playback at the moment.



Aug 13, 2011 at 1:48 PM

Hi Mark,

Thank you for your reply. Now my dev has managed to fix those behavior... In september when breezer will pop up with a refresh you'll see more in detail.

Right now I haven't the time to reply but the solution was quite simple, just we don't call stop, we set the position to 0 and we archive the same effect. And it seems to be a rock-solid approach (even reusing dsound devices). You've done a great work!

But we need more testing to be sure.