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

How to play multiple wave files simultaniously using ASIO

May 25, 2012 at 8:18 AM

 Hi,

   I am using the NAudio way for playing the single wave file, I am trying to extend the same way to play two wave files to different channels simultanioulsy . Currently I am using  driver.createbuffer function to create the buffers. Second call of this funtion for creaing the second buffer is failing.

Please let me know if it is possible to play multiple wave files using ASIO.

 

Thanks in advance

 

 

May 25, 2012 at 10:02 AM

you can't have multiple instances of AsioOut. Instead you would use the multiplexing wave provider I describe here:

http://mark-dot-net.blogspot.co.uk/2012/01/handling-multi-channel-audio-in-naudio.html

May 25, 2012 at 1:17 PM
Edited May 25, 2012 at 1:18 PM

Hi,

  If you have the class for multiplexing wave provider please share the same. Using this can I play to specific files to specific channels. 

 

 

 

Thanks in advance

May 25, 2012 at 1:29 PM

they are in the latest NAudio source code.

May 25, 2012 at 2:19 PM
Edited May 25, 2012 at 3:18 PM


var waveProvider = new MultiplexingWaveProvider(new IWaveProvider[] { soundMangerObj.reader, soundMangerObj.reader1 }, 4);

waveProvider.ConnectInputToOutput(2,3);
waveProvider.ConnectInputToOutput(3,1); 
waveProvider.ConnectInputToOutput(1,2); 
waveProvider.ConnectInputToOutput(1,3);

 AsioOut dfd = new AsioOut();
 string ffd = dfd.DriverName;
dfd.Init(waveProvider);
dfd.Play();

 

My PC is connected with the device which has 10 IN and 10 OUT channels. I am getting exception when it try to call conncetinputtooutput, Please help

 My requirement is suppose my speakers are connected to Speaker-1 to Output Channel-5 and Speaker -2 to Output Channel-8 how should i configure the channels to play the files only to this specific channels , all the other channels should not hear anything.

Thanks in advance

May 25, 2012 at 4:06 PM

these numbers should be zero based which is probably causing your exception

The multiplexing wave provider doesn't currently have the ability to disconnect an input. You could add that, or make a silence playing waveprovider (very easy to do - just implement IWaveProvider and zero out the buffer), which you connect to the inputs you want silent.

My soundcard only has two outputs so I've never been able to test ASIO with higher channel counts. hope it works for you.

May 26, 2012 at 5:53 AM
Edited May 26, 2012 at 9:13 AM

Hi ,

  I tried this but I am not getting this please provide me with some samples which will be really helpful.

 I need to play a two mono file to two input channels say ch-1 and ch-7. Is there any sample that you can provide me or the read() function which will solve my purpose

Thanks in advance