Advice on writing a virtual sound device driver

Hi everyone:

I’m somewhat new to Windows device drivers. I’ve written a handful of software-only kernel drivers. Mostly just as a test. I’ve never written any hardware (sound) drivers though.

So now I need to see if I can write a software-only driver that can act as a virtual (U S B.) sound input. It should accept sound data via network and present it in the system as a virtual sound device (say, a microphone, or a sound input device) to let other running software (in user land) to use it as if it was a physical microphone.

So I have a couple of questions, if you don’t mind:

  1. Is it worth attempting to write this in the kernel? I’d rather do it in user-land, if possible.
  2. If the only way to do this is in the kernel, can someone guide me where shall I start next?

It would really help if there was a code sample that I can review that does a similar thing.

I understand that there are technically two questions in one here: how to receive data via a network (from the kernel) and how to create a virtual sound device.

There are plenty of discussions here on virtual audio drivers. Search them out.

The real time constraints are always going to be an issue. Also it will be difficult to implement the network part in kernel mode as part of the audio driver. I’d suggest doing that part in user mode and providing the data to your audio driver to present to the audio stack. The samples here are a good place to start: https://github.com/microsoft/Windows-driver-samples/tree/main/audio

Also I don’t know why you want to emulate a USB audio device, that is likely to result in other complications that are entirely outside of the objective.

So now I need to see if I can write a software-only driver that can act as a virtual (U S B.) sound input.

No, you want a driver that acts as virtual sound input Forget about USB – that’s entirely irrelevant to your task.

There are commercial products that can do this today. Virtual Audio Cable is one of them.

Have you even looked at the Microsoft samples? There is a “Simple Audio Sample Device Driver” that does 90% of the work for a virtual audio device. All you have to do is add a back-door ioctl to feed the audio in. Well, it’s still a fair amount of work, but the structure is there.

https://learn.microsoft.com/en-us/samples/microsoft/windows-driver-samples/simple-audio-sample-device-driver/

I really appreciate your input guys! I’ll look at those samples that you linked to.

Yes, I agree. I don’t know why I said USB. Probably just thinking of a hardware device. But if it’s virtual, it doesn’t matter, right.

@Tim_Roberts that’s a great idea, I didn’t think about implementing the networking part in the user land and piping the data into the sound driver through IOCTL. It will need some buffer too keep the incoming data, so user mode service would probably be the best way to go.

Thanks again!