I have initialized the device using:
static IWavePlayer waveOut;
static WaveFormat waveFormat;
static BufferedWaveProvider waveProvider;
private static int AudioDeviceInit()
{
waveOut = new DirectSoundOut();
waveFormat = new WaveFormat(44100, 2);
waveProvider = new BufferedWaveProvider(waveFormat);
waveOut.Init(waveProvider);
waveOut.Play();
return 0;
}
I am adding pcm stream to it using:
waveProvider.AddSamples(samples, 0, size);
The above is working fine as long as the stream data is of the same configuration.
I have another function that receives sample rate and number of channels and I want to reconfigure the waveprovider to use the newly provided configuration. Here is the code that I am using:
private static void AudioConfigCallback(int rate, int channel)
{
waveFormat = new WaveFormat(rate, channel);
waveProvider = new BufferedWaveProvider(waveFormat);
waveOut.Init(waveProvider);
return;
}
This is not working and I believe that this is not the correct way of doing it as well. Any idea how I can reconfigure the device to use new sample_rate and num_channels
Thanks.