Whenever I try to call .init() on a waveOut that isn't using the default audio device I receive a WaveBadFormat exception. If I change the default device I can open the waveout with no dramas. The wave provider in every case is the same mixer which uses the ieee 44.1k 2 channel wave format.
The below code is called when the application starts.
MixingWaveProvider32 mixer = new MixingWaveProvider32();
WaveOut wavOut = new WaveOut();
wavOut.DesiredLatency=100;
wavOut.Init(mixer);
But if the user selects a different playback device then the following code is called
wavOut.Stop();
wavOut.Dispose();
wavOut = new WaveOut();
wavOut.DeviceNumber = ((WaveCapabilities)comboBox2.SelectedItem).Index;
wavOut.Init(mixer);
And the wavOut.Init(mixer) throw a bad format exception.
Inspecting the non-public members of the devices there doesn't seem to be any difference in their supportedWaveFormats however I also don't believe any of the SupportedWaveFormat enumerable options matches the 32bit ieee wave format that the MixingWaveProvider32 uses.
If anyone has any ideas as to why this is not an issue for the default device (whatever it may be) but id for the other waveOut device options I would very much appreciate it!
Yes, sometimes WaveOut
device drivers only accept certain formats. NAudio does include helper classes like WaveFloatTo16Provider
which you can use in your case to wrap MixingWaveProvider32
before passing it to the WaveOut.Init
method