This project has moved and is read-only. For the latest updates, please go here.

AcmNotPossible calling acmStreamOpen

Nov 19, 2014 at 1:52 PM
Edited Nov 19, 2014 at 2:31 PM
I get this error with any wavefile with a 32 bit samplerate but not with any of my wave files with a 16 bit samplerate
 using (MediaFoundationReader wfr = new MediaFoundationReader(fn))
{
    var newFormat = new WaveFormat(44100, wfr.WaveFormat.BitsPerSample, wfr.WaveFormat.Channels);
    System.Threading.Thread.Sleep(100);
    File.Delete("C:\\Users\\karls_000\\OneDrive\\Documents\\MidWay44khz.wav");
    using (WaveFileWriter wfw = new WaveFileWriter("C:\\Users\\karls_000\\OneDrive\\Documents\\MidWay44khz.wav", newFormat))
    {
        using ( WaveFormatConversionStream conversionStream = new WaveFormatConversionStream(newFormat, wfr)) // this line gives the error
        {
            conversionStream.Position = 0;
            byte[] buffer = new byte[1024];
            while (conversionStream.Position < conversionStream.Length)
            {
                 int bytesRead = conversionStream.Read(buffer, 0, 1024);
                 if (bytesRead > 0)
                 {
                      wfw.Write(buffer, 0, bytesRead);
                 }
                 else
                {
                      break;
                }
            }
       }
   }
}
Nov 28, 2014 at 5:11 PM
Not every conversion is possible. You can only do what the codecs allow. The ACM resampler codec won't allow you to go from 32 bit floating point to 16 bit AND resample in one go. You'd need to do it in two steps. The MediaFoundationResampler is actually more flexible and may be a better choice here.
Marked as answer by zoomvirus on 12/2/2014 at 5:11 AM