Soundboard (play through mic) in Rust?

I've been trying to make a soundboard (like Voicemod, since Voicemod has a limit to how many sounds you can upload and also is slow as hell) in Rust for some time now, but there is one step I cannot get past:
How can I create a virtual audio device and play sound into it?

FYI I'm using Tauri (https://tauri.app), though I don't think that should affect this.

If you are unsure what I mean:

  • user downloads my soundboard app
  • my soundboard app creates a virtual audio output <-- this is what I'm stuck on
  • user selects which microphone they would like to use to input their audio
  • user selects my virtual audio output on whichever app, e.g. Discord as their input device
  • user plays a sound on my soundboard app
  • my soundboard app plays a sound, on top of the sound from the user's selected input through the virtual audio output

I have researched long and hard about this, yet I cannot find:

  • a tutorial on how to make a Soundboard in Rust or how to make a virtual audio device in Rust
  • any code snippet that creates a virtual audio device itself rather than just requiring the user install VB Audio Cable's virtual device and playing through that

Responses I would like:

  • any code snippet on how to do this, with an explanation of what each line does (sorry if that is too much to ask for)
  • an explanation of how one would go about this with some package, or without any package (if possible?)

Thank you!

You mentioned VB-CABLE so you're presumably on Windows. Every OS will be slightly different.

There isn't any way to just create a new audio device from an application on Windows. You would need to write a device driver and have the user install it with Administrator privileges, so in effect you would just be rewriting VB-CABLE. If this is what you want, you can have a look at the WDM audio driver code samples from Microsoft.

Hm. That sucks, it seems so simple a task that I was sure there would be some native package or something.

Thanks for the audio driver code samples. I will look into writing one but it looks very complicated.
If anyone can suggest maybe a sample specifically made for a virtual audio device like this or a soundboard that would be great.

Thanks again.

Maybe Synchronous Audio Router can do what you want, but it hasn't been updated for a while.

You are right about it not being updated for a while.
For example, its latest build failed and I've just seen this:
"Windows 7 or later. If you are running a current version of Windows 10, Secure Boot is not supported."
in the system requirements section.

I don't think that will work, since most people will be using Secure Boot.

Thanks for the reply, though.

You can have a look at JACK, which is still maintained.

But it does seem like VB-CABLE is the most commonly used tool on Windows for this sort of thing.

This looks good.
Here's a Rust package I found that looks like it can communicate with JACK, but not actually start a JACK server: GitHub - RustAudio/rust-jack: Decent jack bindings for rust.
So I will continue looking.

Thanks for the idea!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.