This project has moved. For the latest updates, please go here.

Opening some instances of Waveout together

Jul 25, 2011 at 7:38 AM

Hi

I have a problem with opening some waveout instances together.

I defined a class named audioLib and it has an instance of waveout class and Init the waveout  instance in constructor of the audioLib class.

The problem is that when I define an array with 50 indices of audioLib class ( audioLib[] al = new audioLib[50] ) The program faces an exception and it close the program, but if I define about 30 instances of audioLib there's no any problem.

Exception handling says this: AlreadyAllocated calling waveOutOpen

Please help. I really don't know what's the problem.

Thanks in advance

Coordinator
Jul 26, 2011 at 9:46 AM

It may be simply a driver issue not letting you have that many concurrent instances of WaveOut. Have you considered having just one WaveOut and using a mixer to mix in the sounds you want to play?

Mark

Jul 26, 2011 at 12:34 PM

Hi Mark

Before anything I want to say thanks for your great project. It's really the best audio library I've ever seen :)

As you said it's a driver issue. It seems that I can have 32 channel at most with my driver.

I tried to use mixer but I'm new with this library. I tried to use mixer.  I have a 16 bit waveFormat and there's a WaveMixerStream32 class that needs 32 bit waveformat. 

It would be nice if you can help me to setup a mixer for my scenario.

I have something like this:

 

 WaveFormat wf = new WaveFormat(8000, 16, 1);          

 waveProvider = new BufferedWaveProvider(wf);

 waveOut = new WaveOut(); 

 

How can I add my waveProvider to mixer? I found WaveProviderToWaveStream in a stackoverflow.com post of you for adding provider to mixer. But there's some problems with converting my waveformat.

Thanks again

 

Coordinator
Jul 26, 2011 at 12:36 PM

you can use WaveChannel32 for now to make a mixer input. I'm hoping to make this kind of task easier in NAudio 1.5 with a new ISampleProvider interface

Jul 26, 2011 at 1:29 PM

I get the error "The method or operation is not implemented." with this code:

 

            WaveFormat wf = new WaveFormat(8000, 16, 1);
            
            waveProvider = new BufferedWaveProvider(wf);
            waveProvider.DiscardOnBufferOverflow = true;
            
            WaveProviderToWaveStream wpws = new WaveProviderToWaveStream(waveProvider);

            WaveChannel32 waveChan32 = new WaveChannel32(wpws);

            WaveMixerStream32 mixer = new WaveMixerStream32();

            mixer.AddInputStream(waveChan32);

            waveOut = new WaveOut();

            waveOut.Init(mixer);

            waveOut.Play();

What's the problem?

Jul 27, 2011 at 10:30 AM

The problem solved. it was from WaveProviderToWaveStream class. I just commented "throw new NotImplementedException();" line in Position set.

Thanks for the solution. it seems that mixer will solve my problem.