I am trying to play multiple sound files at the same time using NAudio MixingSampleProvider's AddMixerInput method. I am using the AudioPlaybackEngine found at this page: https://gist.github.com/markheath/8783999
However, when I tried to play different files, I get an exception while playing some sounds: "All mixer inputs must have the same WaveFormat" It is probably because the sound files I have do not have the same sample rate (I see some files have 7046 as sample rate, instead of 44100).
Is there a way to modify the CachedSound class so that the sample rates are all converted to 44100 when reading the files?
Thanks!
You cant mix audio streams together without converting them to the same sample rate. In NAudio there are three ways of accessing a resampler:
As well as matching sample rates, you also need matching channel counts. NAudio has various ways to turn mono into stereo and vice versa.