Page 1 of 8

AudioEndpoint

Posted: Sat Jul 19, 2014 11:16 am
by Sem;colon
Hello everyone,

I created a new AWESOME plugin I'd like to share with you; it's called "AudioEndpoint"

What does it do?
-It monitors your audio devices:
(That means it generates an event when an audio device changes:
-Attach headphone to PC -> generates event
-The default audio capture or render device changes -> generates event
-An audio device becomes deactivated or activated -> generates event
...)
-It can also set the system default audio render device:
(e.g. you have a TV connected via HDMI and some headphones connected via jack, now you can use this plugin to switch your PC audio output between Headphones and TV speakers.)

It only works with Windows Vista or higher!

Now, have fun with the plugin :-)

Change-log:
v2.3.3:
-Lots of Bug Fixes
-Removed feature "Advanced audio endpoint state changes (property changes)" as it was buggy and causes a lot of issues
v2.3.2:
-Fixed a bug: "Get Default Audio Device" was not working in combination with "Set Volume"
-Added action: "Get Audio Device By Name" to get an audio device by its name instead of its unique ID. You can use wildcards. The first device where the name matches will be returned to be used in one of the other actions - for example, to change the default audio device. This is useful when running Windows 10, as after OS upgrades and/or driver updates the IDs that are used to reference an AudioEndpoint can change, but the name usually stays the same.
-Some small bugfixes
-Updated AudioEndpointControl lib by jonib with the latest sources, this (hopefully) increased the stability
This version is not tested with EG 0.4 and therefore may not work with it!
v2.2.1:
-Replaced action "Set Default Audio Render" with "Set Default Audio Device" (you can now choose the role and flow direction of the default device you would like to set)(your configured actions will still work, but you'll need to add the new one if you like to add or change something)
-Replaced action "Next Default Audio Render" with "Next Default Audio Device" (you can now choose the role and flow direction of the default device you would like to set)(your configured actions will still work, but you'll need to add the new one if you like to add or change something)
-Replaced action "Previous Default Audio Render" with "Previous Default Audio Device" (you can now choose the role and flow direction of the default device you would like to set)(your configured actions will still work, but you'll need to add the new one if you like to add or change something)
-Extended actions "Get Mute", "Set Mute", "Get Volume" and "Set Volume" by the possibility to set settings for capture devices
-Extended actions "Get Mute", "Set Mute", "Get Volume" and "Set Volume" by the possibility to use the output of the "Get Default Audio Device" action to determine which audio device should be changed
v2.1.2:
-Added options to the plugin what events you like the plugin to be triggered (volume/mute events, device state events and advanced device state events(new))
-Some bug fixes
-Modified version of the AudioEndpointControl by jonib, should work with EG 0.4 and 0.5
v2.1.0:
-Added action "Get Mute": Returns True if a specific audio endpoint is muted, and False if not
-Added action "Set Mute": Set mute for a specific audio endpoint (ON, OFF or TOGGLE)
-Added action "Get Volume": Returns the current volume of a specific audio endpoint
-Added action "Set Volume": Set the volume for a specific audio endpoint. Can be absolute or relative
-Events are generated if the volume changes on any audio endpoint
-Events are generated if the mute state changes on any audio endpoint
-Updated AudioEndpointControl by jonib with the latest sources
-Plugin is now in the .egplugin format for easy installation
v2.0:
-The plugin now uses the AudioEndpointControl library provided by jonib and not uses external tools any more.
-Replaced action "Get Default Audio Render" with "Get Default Audio Device" (you can now choose the role and flow direction of the default device you would like to get)
-Extended actions "Set Default Render", "Next Default Audio Render" and "Previous Default Audio Render" (It's now possible to select a role for the default render device you set (Console, Communication, Multimedia))
-Some responses may have changed, check your macros after updating!
v1.4:
-Added guid
-Added action "Get Default Audio Render"
-Added action "Next Default Audio Render"
-Added action "Previous Default Audio Render"
-Bug fixes
v1.2:
-Added support link
-Added icon
-Fixed a bug: Audio output was sometimes wrongly notified as "cannot be found" when trying to set it as default device

Re: AudioEndpoint

Posted: Sat Jul 19, 2014 4:39 pm
by kalia
Thanks Sem;colon. Definitely something that I can utilize.

Thanks,

kalia

Re: AudioEndpoint

Posted: Sat Jul 19, 2014 10:34 pm
by EpicCyndaquil
Awesome work, I can already see the default audio device changes appearing in the log - exactly what I needed. :D

Re: AudioEndpoint

Posted: Wed Jul 23, 2014 7:43 am
by blaher
Very nice. Works well in Win 7. :)

Re: AudioEndpoint

Posted: Thu Jul 24, 2014 9:19 am
by V_J
Nice one! Might be interesting in my case, when playing back audio through hdmi, but it stops when the screen goes to sleep. Rather than keep the pc awake, I might opt to switch audio device...

Re: AudioEndpoint

Posted: Fri Jul 25, 2014 9:55 pm
by Sem;colon
Thank you all for the positive feedback! :)

New version! (v1.2):
-Added support link
-Added icon
-Fixed a bug: Audio output was sometimes wrongly notified as "cannot be found" when trying to set it as default device

Re: AudioEndpoint

Posted: Thu Aug 14, 2014 1:54 am
by blaher
V_J wrote:Nice one! Might be interesting in my case, when playing back audio through hdmi, but it stops when the screen goes to sleep. Rather than keep the pc awake, I might opt to switch audio device...
Another option is to have 2 macros, each triggered by events from the creating and ending of whatever audio program you use, and then use powercfg to either enable monitor sleeping (after 15 minutes in the example below), or disable it.

Edit: Oops, I see you've already list the idea of keeping the PC awake, but I will leave this here in case it helps someone else.

Re: AudioEndpoint

Posted: Mon Aug 18, 2014 2:08 am
by blaher
I'm getting a notpresent event, but it seems to be there and working. Is this normal?

12:04:02 AudioEndpoint.State.ACTIVE.AMD HDMI Output (AMD High Definition Audio Device) ['{0.0.0.00000000}.{2be0ffbe-14b9-4650-9a51-e6d01e1351d3}']
12:04:02 AudioEndpoint.Default.Render.Console.AMD HDMI Output (AMD High Definition Audio Device) ['{0.0.0.00000000}.{2be0ffbe-14b9-4650-9a51-e6d01e1351d3}']
12:04:02 AudioEndpoint.Default.Render.Multimedia.AMD HDMI Output (AMD High Definition Audio Device) ['{0.0.0.00000000}.{2be0ffbe-14b9-4650-9a51-e6d01e1351d3}']
12:04:02 AudioEndpoint.State.NOTPRESENT.AMD HDMI Output (AMD High Definition Audio Device) ['{0.0.0.00000000}.{7017985c-9584-4724-b112-4957cbac262d}']

Re: AudioEndpoint

Posted: Mon Aug 18, 2014 11:19 am
by Sem;colon
Well, the plugin shows you events that are created by Windows OS - I guess this can have a lot of reasons, if it works I wouldn't pay much attention.

Re: AudioEndpoint

Posted: Wed Apr 08, 2015 2:48 pm
by mitchelltrout
Hmmm, not sure if I am maybe using it wrong. But it does not detect when my headphones are plugged in or unplugged.

Image

And I am just unplugging it and plugging it back in to see if it generates an event.
Image

Re: AudioEndpoint

Posted: Thu Apr 09, 2015 6:57 pm
by Sem;colon
Hello mitchelltrout,

looks like the audio chip Lenovo uses doesn't notify the OS if you plug/unplug headphones - or at least not the way it happens with my Realtek chip.

However, there are some system events that are currently not transferred into EG.
The good news:
I verified on a Lenovo Notebook that these events are triggered if you plug/unplug the headphones .
The bad news:
Those events look the same for if you plug or unplug the headphones...
Also they look "ugly".

If you like to try, replace the __init__.py in the plugin folder with this one:
__init__.py
(5.3 KiB) Downloaded 401 times

Re: AudioEndpoint

Posted: Thu Apr 09, 2015 7:23 pm
by mitchelltrout
Thank you! It is working perfectly. When I disconnect the headphones no event fires, which is fine. And when I connect headphones it fires a few events, one of which was all I needed to automatically set the volume. Thanks again, I have had some great help from you guys on these forums!

Re: AudioEndpoint

Posted: Tue Sep 29, 2015 7:59 am
by blackwind
Can I get a "Get Default Audio Renderer" action so I can take action based on the current default?

Re: AudioEndpoint

Posted: Tue Sep 29, 2015 4:33 pm
by Sem;colon
Yes, it would not be difficult to implement that.

I currently use a variable in eg.globals that is filled by the events the plugin generates.
But the information is also stored in the plugin itself, e.g. the id of your default render device is stored in eg.plugins.AudioEndpoint.plugin.activeAudioEndpoint
If you would prefer the name over the id, you can get it via eg.plugins.AudioEndpoint.plugin.audioEndpointIDToNameDict[eg.plugins.AudioEndpoint.plugin.activeAudioEndpoint]

Re: AudioEndpoint

Posted: Tue Sep 29, 2015 9:40 pm
by blackwind
It seems eg.plugins.AudioEndpoint.plugin.activeAudioEndpoint isn't being updated. The following code, which I believe should work, doesn't:

Code: Select all

curId = eg.plugins.AudioEndpoint.plugin.activeAudioEndpoint
curIndex = eg.plugins.AudioEndpoint.plugin.audioEndpointIDs.index(curId)
newIndex = (curIndex + 1 if curIndex + 1 < len(eg.plugins.AudioEndpoint.plugin.audioEndpointIDs) else 0)
newId = eg.plugins.AudioEndpoint.plugin.audioEndpointIDs[newIndex]
newName = eg.plugins.AudioEndpoint.plugin.audioEndpointIDToNameDict[newId]
eg.plugins.AudioEndpoint.SetRender(newId)
activeAudioEndpoint keeps returning the original value, so it doesn't cycle through as I wanted.