0

I need to create a virtual audio device programmatically on Windows so I can write sample data to it and have other applications on the system use it as a microphone. I'm using Windows 10 and looking for a solution in rust or c++.

The idea is to create an audio stream from a file and write or redirect this stream to an audio input device that other programs can use as a microphone.

I've looked into using the Windows Core Audio API, but I'm having trouble finding examples or documentation on how to create virtual audio devices programmatically. I've also looked into using the WASAPI but I'm unsure if this is the right approach.

Any help would be greatly appreciated. Thank you!

Ahmed Tounsi
  • 1,482
  • 1
  • 14
  • 24
  • Is this any help https://superuser.com/questions/117625/how-to-create-a-virtual-audio-device-and-stream-audio-input-with-it or this https://stackoverflow.com/questions/11789624/windows-virtual-microphone-in-c – Richard Critten Dec 24 '22 at 13:14
  • Nope, I've seen both questions and they suggest using VAC and Virtual cable, both are closed-source programs. What I'm looking for is the way these programs create virtual devices. Thank you for your reply! – Ahmed Tounsi Dec 24 '22 at 13:25
  • You will need to create an Audio Driver then see https://learn.microsoft.com/en-us/windows-hardware/drivers/audio/getting-started-with-wdm-audio-drivers – Richard Critten Dec 24 '22 at 13:45

1 Answers1

0

I went through this exercise recently and it took me several weeks as an experienced developer new to kernel mode driver development. I started with this sample and needed to add a ioctl support for data transfer from user mode to kernel mode. https://github.com/microsoft/Windows-driver-samples/tree/main/audio/simpleaudiosample

N8Zach
  • 26
  • 1
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 09 '23 at 01:09
  • Um…. Not sure what is unclear. I provided a link to the sample driver. Adding ioctl support for data transfer is covered in numerous articles and kinda beyond the scope of the question. – N8Zach Mar 10 '23 at 03:56
  • I am trying to do exactly same and it's hard to even figure how all pieces are connected together; could you please share a sample of this ? The ioctl for data transfer sounds like the easier part of the solution, according with the info that could be found in internet on how to proceed with it. But dealing with the sample architecture and being sure of what are you doing is a bit more complex -_-U – forlayo Mar 17 '23 at 21:07
  • It is very complex. I’ve been a developer for 25 years and it challenged me immensely. I gleaned a lot of insight from the archive here:https://www.freelists.org/list/wdmaudiodev – N8Zach Mar 19 '23 at 02:47
  • I also found the examples here helpfull: https://www.codeproject.com/search.aspx?q=Ioctl&x=0&y=0&sbo=kw – N8Zach Mar 19 '23 at 02:57
  • @N8Zach I'm also looking to do something similar. I want to start off with the SimpleAudioSample from Microsoft but the functionality where the sample writes the input data to file, I want to replace it with routing the input to the audio endpoint (which I do not write/control) that is actually driving the system speakers. Do you think IOCTL is the route I need to go for this goal? – getacoafeza May 03 '23 at 11:21
  • @getacoafeza I’m very confused by your question. It would probably be best if you start a new thread as it seems unrelated. I’ve never written a speaker driver. – N8Zach May 06 '23 at 04:53