How to create WaveChannel32 from IeeeFloat stream?

Apr 11, 2011 at 11:31 AM
Edited Apr 11, 2011 at 12:19 PM


Hi,
i have problem with reading wav files in Ieee Float format.


here is the file I'm working with: http://tsmaestro.aspone.cz/aa.wav

WaveStream readerStream = new WaveFileReader("aa.wav");
//when debugging, i got following values:
//readerStream.Format.BitsPerSample: 32
//readerStream.Format.Encoding: IeeeFloat

readerStream = WaveFormatConversionStream.CreatePcmStream(readerStream); //throws NoDriver calling acmFormatSuggest


if I skipped previous line and run:

var format = new WaveFormat(readerStream.WaveFormat.SampleRate, 16, readerStream.WaveFormat.Channels);
readerStream = new WaveFormatConversionStream(format, readerStream);
//I got enother exteption: "AcmNotPossible calling acmStreamOpen"

 

//and this line throws NullReferenceException:
inputStream = new WaveChannel32(readerStream);


I also tried Wave32To16stream without success.


I can play the file in Windows Media Player so a suggest it is valid.
I have read some threads on this forum and more developers have the same problem.


Thanks for any help.

Coordinator
Apr 12, 2011 at 9:57 AM

the whole purpose of this code is to turn a 16 bit WAV file into 32 bit IEEE format (first bit tries to convert to 16 bit PCM, WaveChannel converts to float). Obviously, since your audio is already in that format, most of this code is redundant. The demo would require refactoring a bit to be able to play 3 bit files.

Mark

Apr 12, 2011 at 1:49 PM
Edited Apr 12, 2011 at 1:58 PM

Thanks for your response.

well, I understand the it's redundant code, basically.

I just didn't find a way how to:
1.  convert 32 bit IEEE float stream to 16bit and pass to WavFileWriter.
  OR
2. create WaveChannel32 from WaveStream with 32 IEEE format. (if wav is already in ieee format)

I have worked around the first point so that I just readed from underlying pcm stream, but I'm not sure if this won't cause some kind of inconsistent state.


anyway, you have done great work with this library and support I really appreciate it. I think you should add some info about how to donate to the project's homepage ;) This budget could be spent for some documentation. Consider it!

Coordinator
Apr 13, 2011 at 10:43 AM

There is a Wave32To16Conversion stream you can use to go from IEEE to 16 bit samples

WaveChannel32 would need to be modified to accept IEEE input, as it currently accepts 16 bit. In fact, WaveChannel32 is a bit redundant if your input is already 32 bit; why do you need to use it?

Apr 13, 2011 at 4:32 PM

Hmm, good question :)

currently I have CreateInputStream method which returns WaveChannel32. When I changed it to WaveStream, I was not able to set volume on stream. Ok, for my reasons I can use

initially I thought that to the wasapiout I must pass all streams in the same format, but I'm working in exslusive mode so this is not very actual. I'm also using WaveChannel32.Sample event for visualisation purposes.

But how to make output volumelevel indicator (like in windows volume mixer) if I don't have OnSample event.



And one more question? is there an option to convert 24 bit wav to 32?

One think I would like to achieve is to create peak file(stream, double array...) from any format which I can decode using naudio. In other words, I would like get samlpes with range between <0;1> from any wavestream.

Coordinator
Apr 14, 2011 at 8:12 PM

check the latest NAudioDemo, it can now play 24 bit, 32 bit float and 8 bit WAV files

Mark

Coordinator
Apr 14, 2011 at 8:12 PM

I should add, I still need to test with mono files at those bit depths. I'm hoping to find time to make a series of small test files soon.

Mark