Hello,
Short intro: I've been using Autohotkey for years here and then.. back with more interest since V2. Really great and enjoyable.
Short question: Is there a RELIABLE way to determine if an audio device/component can RECORD something (aka "capture audio").
I've read a lot.. but it all boils down that there's no sure way to do so. I've used the "soundcard analysis script" from
https://www.autohotkey.com/docs/v2/lib/Sound.htm#device
but the results have been even more confusing.
Sometimes, microphones have a "Capture" label for their respective component name (very good - and language independent as it seems, worked on a german Windows), sometimes other mics don't have any component name at all ( ...uhhh..),
sometimes there's a component name labeled "Microphone" but not "Capture" (... okay.. so.. different labels possible?), sometimes whatever microphone means in the language of the Windows installation ( .. oh my..*sigh*),
sometimes there's a component name labeled "Microphone" for the speaker (!) component of the microphone (headphone jack at the mic to hear your voice), so the corresponding row in the soundcard analyis GUI says something like
"component: Microphone" -"Device: Speaker - Blue Yeti" , the "real" microphone (identified via muting and volume settings, it was the "real" one) has no component name at all ( *heavy sigh* ) but the device reads "Device: Microphone - Blue Yeti" ....
Yes, it's very confusing. No way I could boil that down to a logic which identifies and filters the audio devices for their recording capabilities.
Is there NO method to "ask" a device and its components "are you a record-capable component of this device" ?
Thanks!
RELIABLE way to identify if an audio device can record audio?
Re: RELIABLE way to identify if an audio device can record audio?
Well.. I'll give the answer myself, maybe it'll be useful some day..
Short version: I converted parts of the "old" Vista Audio Control library to AHK 2.0
https://www.autohotkey.com/board/topic/21984-vista-audio-control-functions/
because using this library you can identify audio devices/components with a "capture" data flow (mics for example)
and I used a subset of the functions and wrote an additional one for my needs.
It's not that easy (ComObjects, DllCalls and quite a stuff sourrounding this stuff have changed with AHK V2) and there doesn't seem to be much interest, so no full explanation here, sorry (would take a while).
But as I said.. look out for the Vista Audio Control library, study it and use the "right" parts...
Short version: I converted parts of the "old" Vista Audio Control library to AHK 2.0
https://www.autohotkey.com/board/topic/21984-vista-audio-control-functions/
because using this library you can identify audio devices/components with a "capture" data flow (mics for example)
and I used a subset of the functions and wrote an additional one for my needs.
It's not that easy (ComObjects, DllCalls and quite a stuff sourrounding this stuff have changed with AHK V2) and there doesn't seem to be much interest, so no full explanation here, sorry (would take a while).
But as I said.. look out for the Vista Audio Control library, study it and use the "right" parts...
-
- Posts: 1
- Joined: 16 Feb 2023, 05:17
Re: RELIABLE way to identify if an audio device can record audio?
I also want to port VA.ahk to v2, even if parts of it, but I just cannot figured it out. Could you share some code or examples?
Re: RELIABLE way to identify if an audio device can record audio?
I could, but I've only ported the parts which I needed.. mainly those which deal with the "flow" of the data (which is needed to determine if a device is capable of recording) and all the functions which are needed to set everything up (like enumbering devices) in the first place.deluxghost wrote: ↑10 Apr 2023, 02:05I also want to port VA.ahk to v2, even if parts of it, but I just cannot figured it out. Could you share some code or examples?
I won't promise they are ported "right" and bug free.
They work for me..
What do you need?
I can post the whole bunch of ported VA - code which I've done so far, but as I said, I'm not too sure of the quality (I'm not to sure I use everything of the ported code, so there may very well be even crash-prone sections in it which I've never discovered because they were never used in the first place).
Re: RELIABLE way to identify if an audio device can record audio?
i was on a similar question just few days agoOliverK wrote: ↑17 Mar 2023, 18:40Well.. I'll give the answer myself, maybe it'll be useful some day..
Short version: I converted parts of the "old" Vista Audio Control library to AHK 2.0
https://www.autohotkey.com/board/topic/21984-vista-audio-control-functions/
because using this library you can identify audio devices/components with a "capture" data flow (mics for example)
and I used a subset of the functions and wrote an additional one for my needs.
It's not that easy (ComObjects, DllCalls and quite a stuff sourrounding this stuff have changed with AHK V2) and there doesn't seem to be much interest, so no full explanation here, sorry (would take a while).
But as I said.. look out for the Vista Audio Control library, study it and use the "right" parts...
viewtopic.php?f=82&t=115832
and same as deluxghost i am nit that skilled, to transport code out of ahkv1 into v2
i searched a easy way to toggle MicMute with a hotkey , and done cycles and ideas wiht mikeyww
Re: RELIABLE way to identify if an audio device can record audio?
Funny.. I created an AHK script (with optional GUI) to do just that.. it was the reason I had to port the VA code in the first place.
Maybe I'll just post the whole code here.. it's gotten quite big for such a simple task and consists of several files.
Re: RELIABLE way to identify if an audio device can record audio?
You should. It might be good and searched In the future. And probably some professional can shorten it.
My problem was sound mute was a one liner and mic mute was nearly impossible specially if you got multiple devices like a plug in headset or plug in microphone you might not use always...
So yeah lemme see it ✌
Re: RELIABLE way to identify if an audio device can record audio?
Yeah.. that's one of the problems.. audio device handling is quite a complex topic.
I'll see what I can do, the project consists of several files, even multiple PDF files for documentation which can be shown via the integrated help function... there's even a "non-gui-mode" and several startup parameters and stuff.... I'll have to see how I can upload all this stuff here (or I'll have to link to a file storage service, a kind of git hub service or something like that).
Re: RELIABLE way to identify if an audio device can record audio?
Ok ok then, honestly I did not thought it is such a big thing... I just could tell you if you would figure out a "new" solution it would be a thing.
Even a port of the VA library into AHKv2 could be a pleasure for the "community"
I am not able to do such stuff otherwise I might give it a think about it.
Well I like AHK a lot but still incredible complicated for me even while I started to understand that language now...
Even a port of the VA library into AHKv2 could be a pleasure for the "community"
I am not able to do such stuff otherwise I might give it a think about it.
Well I like AHK a lot but still incredible complicated for me even while I started to understand that language now...
Re: RELIABLE way to identify if an audio device can record audio?
I've looked into source code of other projects with similar objectives (managing/muting audio devices), like "Microsoft PowerToys" (which has a mic mute function and its source code is freely available) and .. it does essentially the same.
So it seems there's no other way if an "official" tool implemented it in the same way.
The problem is not AHK itself in my opinion. The problem is, that you have to dive in Dll - Calls (via AHKs DllCall - function) and the like, meaning you're calling functions from different Window APIs.. where you have to convert variables for calls into different data types back and forth, dealing
with pointers, even releasing of memory sometimes and and and..
This is nothing which is specific for AHK, stuff like this gets nasty in every language which is not the language with which the APIs have been coded (C++ mostly), Visual Basic calls to DLL stuff don't look much friendlier for example.
I'll have to look up the project files and maybe have a look into the code again before releasing it, so it will take some days maybe.
Re: RELIABLE way to identify if an audio device can record audio?
Well your choice , otherwise throw it. There is a solution you get referred here... use another program
Or use VA library from 2010
I want to try a workaround version with my basic skills.
Something like a common possible solution.
Like mute device 1-20 with error throws of you unplug a device between those numbers.
Or use VA library from 2010
I want to try a workaround version with my basic skills.
Something like a common possible solution.
Like mute device 1-20 with error throws of you unplug a device between those numbers.
Re: RELIABLE way to identify if an audio device can record audio?
Here it is.. the VA library with the converted code is located in VA_V2.ahk (only partially converted),
MuteAudioDevices.ahk is "the main file".
Expand everything in a folder and execute MuteAudioDevices.ahk, doc file can be found in en_Manual_MuteAudioDevices.pdf (english version)
or opened via the help menu of the GUI.
MuteAudioDevices.ahk is "the main file".
Expand everything in a folder and execute MuteAudioDevices.ahk, doc file can be found in en_Manual_MuteAudioDevices.pdf (english version)
or opened via the help menu of the GUI.
- Attachments
-
- MuteAudioDevices.zip
- ZIP-file containing the code itself, help files (pdf files) etc.
- (459.24 KiB) Downloaded 73 times
Re: RELIABLE way to identify if an audio device can record audio?
Hey cool thank youOliverK wrote: ↑14 Apr 2023, 15:34Here it is.. the VA library with the converted code is located in VA_V2.ahk (only partially converted),
MuteAudioDevices.ahk is "the main file".
Expand everything in a folder and execute MuteAudioDevices.ahk, doc file can be found in en_Manual_MuteAudioDevices.pdf (english version)
or opened via the help menu of the GUI.
My last few script issues did not worked good. So I stopped for some days to relax... work also.
I give it a look next few days thanks for sharing.
Re: RELIABLE way to identify if an audio device can record audio?
Note: to just browse capture capable audio devices, toggle the "only capture devices" in the settings menu, see attachment.
The code itself is far from perfect: for example, if you don't toggle the "ony capture devices" button it doesn't use the VA library but the built-in sound device functions of AHK,
because this part (where all audio devices were listed and could - and still can - be muted with their recording AND playback functionality) was completed earlier, I had to resort to the VA port because I didn't see a way
to identify capture capable devices with AHK functionality alone.... of course I could have used the VA library throughout the code if I would have known this before.
The code itself is far from perfect: for example, if you don't toggle the "ony capture devices" button it doesn't use the VA library but the built-in sound device functions of AHK,
because this part (where all audio devices were listed and could - and still can - be muted with their recording AND playback functionality) was completed earlier, I had to resort to the VA port because I didn't see a way
to identify capture capable devices with AHK functionality alone.... of course I could have used the VA library throughout the code if I would have known this before.
-
- Posts: 63
- Joined: 02 Jul 2020, 11:55
Re: RELIABLE way to identify if an audio device can record audio?
you guys are amazing. I had a similar problem to these problems myself within the past couple of days. I also found the VA library, and I also considered converting it or partially converting it for my needs, but up to now I've been too lazy to really dig into it. Instead I found a NirSoft tool that mostly does what I need, namely enumerating devices and switching devices. Now I just have some hacky thing in v2 that calls into the NirSoft app when I need it, and it works. This may be a reasonable solution for someone else in my position, who isn't really in a hurry to mess with that API....
Re: RELIABLE way to identify if an audio device can record audio?
Throw it online thenSandyClams wrote: ↑24 Apr 2023, 09:42you guys are amazing. I had a similar problem to these problems myself within the past couple of days. I also found the VA library, and I also considered converting it or partially converting it for my needs, but up to now I've been too lazy to really dig into it. Instead I found a NirSoft tool that mostly does what I need, namely enumerating devices and switching devices. Now I just have some hacky thing in v2 that calls into the NirSoft app when I need it, and it works. This may be a reasonable solution for someone else in my position, who isn't really in a hurry to mess with that API....
-
- Posts: 63
- Joined: 02 Jul 2020, 11:55
Re: RELIABLE way to identify if an audio device can record audio?
@Tobgun1, my thing just toggles between the two connected audio devices that I use personally, those being my TV out and my headphone out. It doesn't seem particularly related to what's being attempted in this thread, even though the underlying tool is. It's also implemented kinda weird, I'll prob do some more work trying to make it palatable to another human before I encourage anyone else to use it. Though if you're absolutely dying for it feel free to let me know, I have no idea how inspired I will ever be to keep up with the thing
Re: RELIABLE way to identify if an audio device can record audio?
@SandyClams yeah sure totaly not witty the effort BUT
It is always someone searching it, and maybe not asking for it or searching a solution .
So everything online can be get googled and can be usefull.
So I recommend always to share stuff and safe it online so google can find it.
But if cuse I do not know how much work it is and how much solution it might be.
So your choice
It is always someone searching it, and maybe not asking for it or searching a solution .
So everything online can be get googled and can be usefull.
So I recommend always to share stuff and safe it online so google can find it.
But if cuse I do not know how much work it is and how much solution it might be.
So your choice
Re: RELIABLE way to identify if an audio device can record audio?
Yes, I stumbled over the NirSoft tool also .. but I found the VA library more .. elegant in a way, because you don't need another component to rely on.. just AutoHotkey.SandyClams wrote: ↑24 Apr 2023, 09:42you guys are amazing. I had a similar problem to these problems myself within the past couple of days. I also found the VA library, and I also considered converting it or partially converting it for my needs, but up to now I've been too lazy to really dig into it. Instead I found a NirSoft tool that mostly does what I need, namely enumerating devices and switching devices. Now I just have some hacky thing in v2 that calls into the NirSoft app when I need it, and it works. This may be a reasonable solution for someone else in my position, who isn't really in a hurry to mess with that API....
I guess at the end of the day the NirSoft tool just uses the same Windows API anyway.. the fact that the NirSoft tool ("SoundVolumeView v2.41" from nirsoft.net I guess) works beginning with Windows Vista is a hint in that direction.. VA library means "Vista Audio library", because the API is around since Windows Vista.
Who is online
Users browsing this forum: No registered users and 30 guests