Reading compressed wave files on windows with WindowsMediaAudioFormat

I’m trying to read compressed wave files (*.wav). I noticed that windows and macOS are able to play those files. I have added the following in my code to load wav files:

                #if JUCE_WINDOWS
                manager.registerFormat(new WindowsMediaAudioFormat(), false);
                manager.registerFormat(new CoreAudioFormat(), false);

This works well on macOS, but on windows the WindowsMediaAudioFormat() isn’t able to load a simple wav file. MP3 files are loaded as expected.
The windows media player itself plays MP3 and wav files, even the compressed ones.

Is this behavior normal or is there a way to use also other codecs than mp3 on windows to read audio files?

It depends on the actual codec, but you are right in that you can’t read e.g. ADPCM compressed wav files on Windows. Is that perhaps the codec you’d like to use?

Apparently reading ADPCM on Windows is done with the XAudio2 API, which isn’t supported in JUCE at the moment.

Thanks for getting back. I expected that WindowsMediaAudioFormat reads all audio files that the media player can play.

At the moment I do not see how WindowsMediaAudioFormat works. Why does it load mp3 files but not uncompressed wav files for example? Do you think this is a problem with my windows installation?

I don’t think it’s an installation problem.

There are multiple media related SDKs on Windows, the WindowsMediaAudioFormat uses the Windows Media Format 11 SDK. It can open .mp3, .asf and .wma files. These are supported on Windows along with uncompressed .wav files opened by WavAudioFormatReader.

Things we don’t use right now: there is the Microsoft Media Foundation API, which should be able to open many different formats, including ADPCM encoded .wav files. I managed to open a mono ADPCM file with it, but I can’t figure out how to open a stereo file.

Groove Music is also unable to open this same stereo file, which is the UWP successor of Windows Media Player. As a UWP app it probably uses the Media Foundation API, so maybe there is no way to decode that file with that SDK. Windows Media Player can open the file, it must be using something else.

There is also XAudio2 which should also support ADPCM, but it’s focused on constructing a signal processing graph and then playing sounds in real time, so it doesn’t lend itself to being wrapped into a format decoder.

That’s all assuming we were talking about ADPCM all along, which seems to be a niche codec focusing on digital telephony applications.


Thanks for the research and the detailed description.

There are some sample libraries out there that use compressed wav files. A user reported that some emu samplers can read those files.

Looks like this is something exotic. I also found out that there are different compression algorithms. Even macOS wasn’t able not read all of them. Looks like you can put inside a RIFF format what you want…

I leave it as it is. People always have the option to convert the samples to uncompressed wav files manually.