Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Pipe mic audio through #18

Closed
SoraHjort opened this issue Jul 29, 2022 · 14 comments
Closed

Feature: Pipe mic audio through #18

SoraHjort opened this issue Jul 29, 2022 · 14 comments

Comments

@SoraHjort
Copy link

From what I've seen so far of the soundboard is that it's quite nice.

However there are a few features I feel are missing, though the biggest would be piping the mic through to the virtual cable. The ability to select a input device to pipe out to a primary output (but maybe not the secondary output) would be ideal for this.

So in it's current state is almost perfect for streams (adding the ability to assign hotkeys to specific sound effects would also be nice for this). However for personal use in discord, there is this gap. I do have a sort of a workaround, but it's ancient and adds in a long delay between what is said and what is transmitted. (where as the soundboard is nearly instant)

@micahmo
Copy link
Owner

micahmo commented Aug 1, 2022

The ability to select a input device to pipe out to a primary output (but maybe not the secondary output) would be ideal for this.

Hi @SoraHjort, can you explain a little more what you mean by this? SoundBoard is a primary source of sound, and it already has the ability to pipe its audio to one or more output devices. I'm confused by your suggestion to select an input device since SoundBoard doesn't deal with input.

adding the ability to assign hotkeys to specific sound effects would also be nice for this

Yes, that would be a very nice improvement! Thanks for the suggestion!

@SoraHjort
Copy link
Author

Hi @SoraHjort, can you explain a little more what you mean by this? SoundBoard is a primary source of sound, and it already has the ability to pipe its audio to one or more output devices. I'm confused by your suggestion to select an input device since SoundBoard doesn't deal with input.

The issue/suggestion is in relation being able to use the soundboard and a mic at the same time.

Let's use Discord as an example, cause it's fun to mess with friends. To play the soundboard over the mic on discord you set the Input audio device to, let's say VB-Audio, and have the soundboard set to it the same but for the Output device. However, now you can't talk into your mic and for discord to receive that, since Discord is no longer set to receive input audio from your microphone.

So by giving the soundboard a input audio device to let you pipe audio from a selected input device (IE: Microphone), to have it output on the same device it has set as output.

Or to put it visually. A diagram.
image

Hopefully this clears up what I meant by my suggestion.

I did find a better workaround that gives a more live transmission. But it does require two virtual cables in conjunction with a mixer, basically extra steps. **
Though it would be nicer and simpler on the end user to not have to deal with that kind of work around.

**(For anyone wants to know the workaround, Basically VB-Cable + VB-Cable Voice Meter + Voice Meter's packed in mixer)

On the hotkeys:

Yes, that would be a very nice improvement! Thanks for the suggestion!

If you do implement hotkeys, I would recommend including Left and Right variants on modifier keys, as well as the F13-F24 keys if possible. Which yes those F13+ keys do exist and Windows has built in support for them. They're leftovers legacy support from old old keyboards that actually had them. But these days they're often used in conjunction with software for keyboard, mouse, other peripheral hardware (Or Autohotkey) for programs that support them.

@micahmo
Copy link
Owner

micahmo commented Mar 10, 2023

Hey @SoraHjort, I'm not sure if you still use SoundBoard, but I have added a couple of new features in v1.10.0. The first is the ability to pass through audio, hopefully as you had in mind in your original request. I'm not sure if the latency will be quite as low as you want (should be similar to the listen feature in Windows), but it's worth a shot!

The second is hotkeys. There are some limitations to WPF in terms of distinguishing Left and Right modifier keys, but I was able to support F12-24. Let me know what you think.

@SoraHjort
Copy link
Author

SoraHjort commented Mar 22, 2023

Sorry for the late response, only now had a chance to get to testing it.

On selecting a input device it creates and error. No input audio goes through. And when the soundboard is closed, while an input device is selected after encountering the error, it is unable to be reopened. Instead requires opening up the old version and using "clear configuration" to restore the ability to open up the current version.

The error occurs regardless what input device, whether it's a microphone, motherboard's line in, or (for testing) a virtual cable.

So unfortunately, I am unable to test the audio pass through.

Hotkeys do work, even up to the F24 keys. so thank you.

Though they only work while the soundboard is in focus, would be ideal if it could be done without the soundboard being focused. But if WPF limits you on that then that'll be alright.

Eitherway, despite the issues, thank you for your continued work on the soundboard. I understand this stuff takes time and work, and appreciate you doing this.

Error:

System.Runtime.InteropServices.COMException (0x8889000A): Exception from HRESULT: 0x8889000A
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   at NAudio.Wave.WasapiOut.Init(IWaveProvider waveProvider)
   at SoundBoard.MainWindow.HandleInputOutputChange()
   at SoundBoard.MainWindow.HandleInputDeviceSelection(Guid deviceGuid)
   at SoundBoard.MainWindow.<>c__DisplayClass43_0.<InputDeviceMenuOpened>b__0(Object _, MouseButtonEventArgs args)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

@micahmo
Copy link
Owner

micahmo commented Mar 22, 2023

Sorry for the late response, only now had a chance to get to testing it.

No problem whatsoever, I'm glad you saw this, and I appreciate your help. I should be the one apologizing for how long it took to add the feature. Unfortunately this project has been low on my list.

On selecting a input device it creates and error. No input audio goes through.

I'm very sorry about that! Of course none of the multiple systems with which I tested before publishing had this error! 😊 But everyone's system is different, so we can hopefully figure out what's going on here. What OS are you running?

when the soundboard is closed, while an input device is selected after encountering the error, it is unable to be reopened.

For future refence (in case you help test this more), you can remove the selected input by editing the config file. It is located in %appdata%\SoundBoard\soundboard.config and you can make sure InputDeviceGuid has no value, like InputDeviceGuid=""

Though they only work while the soundboard is in focus, would be ideal if it could be done without the soundboard being focused.

Have you tried setting global hotkeys? They should work regardless of the focused app.

I will research the error you had and get back to you. Thanks!

@micahmo
Copy link
Owner

micahmo commented Mar 22, 2023

Hi again,

I found that the observed error code, 0x8889000A, represents an attempt to open an audio output device that is exclusively held by another application.

https://www.hresult.info/FACILITY_AUDCLNT/0x8889000A

I was able to reproduce your error by creating a sample app to exclusively hold my device. We would need to figure out what app is at fault on your system. I did find this exact error in another repo, and it was related to running the VoiceMeeter mixer.

StreamWhatYouHear/SWYH#41

Maybe you could try running SoundBoard without the VoiceMeeter mixer running?

Another option is to disallow exclusive audio device access in the output device properties. You might need to restart after changing that setting in case any app already has exclusive access.

image

Hopefully we will make some progress with these troubleshooting steps!

P.S. I'm using this opportunity to add more error handling around the audio passthrough feature. The next release should detect whether there are any issues with any input/output devices, and should also warn the user about this particular exclusive error.

@micahmo
Copy link
Owner

micahmo commented Apr 14, 2023

Hey @SoraHjort, I hope you're doing well. I haven't heard back from you regarding my latest questions/suggestions (which is perfectly fine, you're under no obligation to help me test this, nor even use the app if it doesn't suit your needs 😊).

As mentioned previously, the error you encountered seems to be due to another application locking your audio output device. While I can't speculate on what it is, I can add some error handling to prevent that scenario from crashing the app and corrupting the configuration.

I have published a small update (v1.10.1) to do just that, and if you ever get a chance to test further, please try that version.

P.S. Don't forget about trying global hotkeys. 😊

@SoraHjort
Copy link
Author

Sorry again for not getting back quicker.

On global keys, do apologize for not seeing the global key option, it does work.

As for the audio pipe through issue, turns out the issue on my system was not exclusivity mode, but purely VoiceMeter. What ever it does differently compared to any other program I got causes the issue. (It should only hook into three specified devices but it apparently hooks into all of them).
But regardless it is the cause of the issue on my end.

A side issue with this, when the error message pops up, it breaks the Pause/Stop buttons when playing a sound until you restart the soundboard.
They appear for a frame or two before disappearing, while the sound continues to play.

The delay is minimal, more than acceptable, especially compared to old out of date alternatives.


Probably the only suggested change I could make in relation to the pipe-through feature is an option to set a device as "sound effects only". So while you would have the main virtual cable be the device for programs like Discord to capture voice and soundboard, you could also then set a device to just hear the sound effects so you yourself can hear the sound effects when you play them.

Currently, you can set multiple devices which before the pipe-through would allow for that setup. But since the pipe-through you also hear your own voice when setup like that.

Maybe a middle click to set the device, which shows a green checkmark instead of blue to indicate which is the "Hear Soundboard Sounds only"? That way you, locally, can hear the soundboard sounds, while those you are transmitting to, will hear both your voice and sounds.

Hopefully what I just said makes sense.

Anyway, thanks for continuing to work on this.

@micahmo
Copy link
Owner

micahmo commented Apr 17, 2023

Sorry again for not getting back quicker.

Not at all, I appreciate all the feedback and suggestions. Never feel like you have to get back right away.

On global keys, do apologize for not seeing the global key option, it does work.

I'm glad to hear that!

As for the audio pipe through issue, turns out the issue on my system was . . . purely VoiceMeter. . . . it is the cause of the issue on my end.

Very strange! I have VoiceMeeter on my system as well and didn't see the issue, although I'm sure it has a very different configuration. Regardless, I'm glad that's solved for you!

when the error message pops up, it breaks the Pause/Stop buttons when playing a sound until you restart the soundboard.

I'm having a hard time reproducing this as my test for causing the original issue (locking the audio device in another app) causes the sounds to stop as well as the buttons to disappear. I might not worry too much about this one, though. Things are in kind of an unusual state once there's an error accessing the output.

The delay is minimal, more than acceptable, especially compared to old out of date alternatives.

I'm very glad to hear that!

while you would have the main virtual cable be the device for programs like Discord to capture voice and soundboard, you could also then set a device to just hear the sound effects so you yourself can hear the sound effects when you play them.

That makes total sense, the output selection should be separate for sounds and passthrough. I will work on that.

@micahmo
Copy link
Owner

micahmo commented Apr 17, 2023

Hi @SoraHjort, I just wanted to run this design by you before publishing it. Going off your last suggestion, I made audio passthrough its own section where you can pick an input and one or more output devices. There is still a separate section for selecting one or more output devices which only apply to sounds. What do you think?


image


image

@SoraHjort
Copy link
Author

That looks like it'll work. Though, to help with confusion maybe have a note next to the "Output Device" on the passthrough menu with something like "(Soundboard only)" or something.


As for not running into the error with VoiceMeeter, do you run the VoiceMeeter program? Or simply just use the virtual cable it comes with? The error only occurs when you have this program running and fully loaded and then try to change the passthrough input
image

@micahmo
Copy link
Owner

micahmo commented Apr 17, 2023

to help with confusion maybe have a note next to the "Output Device" on the passthrough menu with something like "(Soundboard only)" or something

Good idea!

do you run the VoiceMeeter program

Yes, I did run the full app and couldn't reproduce the issue. 😞 Again, not sure if there's some subtle configuration difference. But not much we can do about VoiceMeeter grabbing the devices exclusively.

@micahmo
Copy link
Owner

micahmo commented Apr 18, 2023

Check out v1.10.2 and let me know if it's sufficient to close this issue. Thanks!

@SoraHjort
Copy link
Author

Yep, it works. Thank you.

Did have a minute or two of confusion on how to get it setup, since the setup in my head was different than the implementation. Basically, I confused myself.

But the way you did implement it I can see having some good case uses that allows from that flexibility, more so than I had intended in the suggestion. Good Work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants