I have a series of 44 kHz 16-bit two-channel uncompressed wave files (read from resources) and want to apply the fade out and fade in effect to create a stream from the sequence of all the WAV files.
The resource reading, and getting the 16-bit wavestream happens correctly. The target format is also shown correct, but I keep getting acmnotpossible
as the exception in the waveformat coversion step below. What am I doing wrong?
String ResToPlay2 = NameSpaceString + ".Resources." + inWave2 + ".wav";
Stream _audioStream2;
int wavdur2 = 0;
Double fadeDurDbl2 = 0;
int fadeDur2 = 0;
if (!resA.GetManifestResourceStream (ResToPlay2).Equals (Stream.Null))
{
_audioStream2 = resA.GetManifestResourceStream (ResToPlay2);
WaveStream wavePCMStream2 = WaveFormatConversionStream.CreatePcmStream (new WaveFileReader (_audioStream2));
WaveFormat targetFmt2 = new WaveFormat (44100, 32, 2);
WaveStream waveStream2 = new WaveFormatConversionStream(targetFmt2,wavePCMStream2);
using (waveStream2)
{
wavdur2 = (int) waveStream2.TotalTime.Milliseconds;
var fader2 = new FadeInOutSampleProvider(new WaveToSampleProvider(waveStream2));
fadeDurDbl2 = (wavdur2*OverlapPCT) / 100;
fadeDur2 = (int) Math.Round(fadeDurDbl2, 0);
fader2.BeginFadeIn (fadeDur2);
var stwp2 = new NAudio.Wave.SampleProviders.SampleToWaveProvider (fader2);
WaveFileWriter.CreateWaveFile (Application.StartupPath + "\\" + "fadedIn_?.wav", stwp2);
}
}