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

Create wave file from WaveMixerStream32

Jan 16, 2010 at 1:22 PM


I'm trying to write a WaveMixerStream32 to a file using  "WaveFileWriter.CreateWaveFile", but there is a conversion problem from IeeeFloat to PCM. But let me first explain some steps I did:

As I have set WaveMixerStream32.AutoStop to "false",  this stream would never stop returning data, so  I created a wrapper class "MixerEndPosStream32 : WaveStream"  taking a WaveMixerStream32 in the ctor  and having the "Length" Property overridden, which will return a value manually set. 

Then I had to modify the CreateWaveFile-Method a bit (should only read/write until "Length" bytes are read):


using (WaveFileWriter writer = new WaveFileWriter(filename, stream.WaveFormat))
                byte[] buffer = new byte[stream.GetReadSize(4000)];
                long bytesReadTotal = 0;
                while (true)
                    int bytesRequired = (int) Math.Min(stream.Length - bytesReadTotal, buffer.Length);
                    if (bytesRequired <= 0)

                    int bytesRead = stream.Read(buffer, 0, bytesRequired);
                    if (bytesRead == 0)
                    writer.WriteData(buffer, 0, bytesRead);
                    bytesReadTotal += bytesRead;



But now the problem :   As the format of the input stream is IeeeFloat ,  it has to be converted into PCM. So I tried using



But this results in an MmException:  "NoDriver calling acmFormatSuggest"  when calling  "AcmStream.SuggestPcmFormat"  (I'm using DirectSound).

Inside this function it suggests  {16 bit PCM: 44kHz 2 channels} and then throws the MmExcpetion at

MmException.Try(AcmInterop.acmFormatSuggest(IntPtr.Zero, compressedFormat, suggestedFormat, Marshal.SizeOf(suggestedFormat), AcmFormatSuggestFlags.FormatTag), "acmFormatSuggest");

An idea ?  





Mar 25, 2010 at 5:39 PM

have you tried the Wave32To16ConversionStream?