Search code examples
c++windowsgoogle-chromemicrophonems-media-foundation

Media Foundation Virtual Microfone


Albeit there is an API for creating virtual webcams in Media Foundation (https://learn.microsoft.com/en-us/windows/win32/api/mfvirtualcamera/nn-mfvirtualcamera-imfvirtualcamera) it does not support audio and I cannot find a way how to implement a virtual microphone using Media Foundation. The requirements are:

  • The implementation should be in user-space (no kernel-space driver involved).
  • The sound data will be generated inside the microphone implementation, e.g. a sine wave, etc.
  • The virtual microphone should be usable for conference calls, e.g. in Hangouts on the Chrome browser.

Do you know if there is a way how to implement such a virtual microphone using Media Foundation or are you aware of any workaround that fulfills the requirements, please?


Solution

  • To be recognized as a microphone by conferencing apps I am not aware of any solution other than a custom kernel-mode driver. I went through this exercise recently and it took me several weeks as an experienced developer new to kernel mode driver development.

    This sample driver will do what you want including playing the sin tone: https://github.com/microsoft/Windows-driver-samples/blob/main/audio/simpleaudiosample/SimpleAudioSample.sln.

    I believe the MSVAD sample also does this.

    If you want it to do anything else (like play sounds from a wav file) there is a lot of code and complexity involved in communicating data from user-mode to kernel-mode and feeding it to the driver.