• Forum
  • Lounge
  • Do you guys have experience with Media F

Do you guys have experience with Media Foundation API?

Windows Media Foundation is MS's modern and native Audio API:

I dig trough internet to find an audio library that is modern and reguralrly maintained and one that is MIT licensed.
But unfortunatelly not such audio library exists.

I found some forums post elsehwere people are saying that audio library in C++ is the greatest "myth" in a sense that such libraries are very rare and not many people work with audio.

They even suggest that using native platform specific code for audio is the best way to go.

I personally use Media Foundation for already some time and find it to suit my needs, there are no programming limitations and there is no need for a license.

I even made a small MF library with which I can play various audio formats that most current audio libraries do not support.

However there is one issue I'm having, it difficult as hell to debug Media Foundation and it's difficult to write audio library because of many concepts that need to be learned and mastered, and I also have one issue that I'm not able to resolve for already some time.

I started to wonder how many people have experience with MF? since I see there are no MF based audio libraries on the internet at all.
PortAudio works well for both playback and recording, although it does have the problem that you can't tell it to only use one API, so when you list devices you get the same physicaly device on multiple virtual devices; one for each API that exposes it.

On Windows I believe the main sound API is WASAPI. I have an example of its usage for playback only here: https://github.com/Helios-vmg/napalm/blob/master/src/plugins/WasapiOutput/WasapiOutput.cpp
It's a lot of code, but it does a lot. It asynchronously reports the value of the system's volume slider for the application and cleanly handles default device switching.
Nice to see you maintain your own audio, how is WASAPI different from MF?
I mean isn't MF sucessor of WASAPI or are these unrelated technologies?
They're contemporary interfaces. Both were introduced in Windows Vista. It looks like WASAPI is a lower-level interface, in that it deals only with I/O of audio data to and from devices, as well as management of those devices, while WMF is a more integral solution. It deals with file formats, codecs, filters, DRM, etc. It also does video, not only audio. If all you need is audio input and output, I'd say it's overkill.
I'm already familiar to some extent with MF and don't wish to learn WASAPI or use any audio libraries, and documentation is good, and also I'll learn how stuff works under the hood.

What I wanted to know if anyone is skilled with MF maybe it could help me debug my problem but I'm afraid I'm on my own.
I hate when debugging gets hard.
Last edited on
I'd suggest giving PortAudio a try. It's really very simple to use.
I think the only thing it was missing was a way to query the device's preferred sample rate and such. You just tell PortAudio what you have and it deals with the conversion transparently.
I'd suggest giving PortAudio a try.

It is available as a vcpkg package, version 19.7, coincidentally.

I may take a look at it, but I also stumbled upon "soloud" library, it seems to be one of the best out there:

any comparisons between the 2?
I've never used it, but at a glance the API is reminiscent of OpenAL. Before sound cards became basically irrelevant and Creative became assholes and close-sourced it, OpenAL rendered audio sources in a virtual 3D space by changing the volumes in the different channels. You could also set a value for the speed of sound, and moving sources would get a Doppler effect applied based on their movement relative to the listener's position in the 3D space. In other words, exactly what you'd need to play sound effects in a 3D video game.

PortAudio (and WASAPI, since they're intended for the same use cases) is more basic. It just lets you select a device and send data to it. If you need to do mixing, panning, or any other effects more complex than a simple volume control, the application is expected to handle it.
On the other hand, video game-oriented libraries typically don't let you select the output device, and generally don't implement audio input.
Topic archived. No new replies allowed.