Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Macro:(Get) Master Volume-Actions- (insert) Master Volume???

If you have a question or need help, this is the place to be.
Post Reply
User avatar
zian
Site Admin
Posts: 569
Joined: Wed Jun 24, 2009 3:54 pm

Macro:(Get) Master Volume-Actions- (insert) Master Volume???

Post by zian »

(Get) Master Volume - Actions - Actions - Action -(insert) Master Volume???
How can I do this?

I have spent hours creating some macros that allow me to change my Fader & Balance control on my older Creative SoundBlaster Live 5.1. I use the macros pretty much to fade from front to rear speakers and visa-versa. It isn't the "prettiest" of macros and it has lots of mouse moving and button click emulations (I'm not too good at the Post/Send Message functions...AT ALL).
But it works.

When I would run these Macros (or even when I don't) Just tweaking the fader-balance controls of my SurMix2.exe app/window "manually" it changes the volume levels pretty drastically...I think this is a Creative/Driver bug.

Right now I have the Macro's set to go to a certain % of Master Volume towards the end of the macro (see images). What I would like is a way of getting the Master Volume level...before the Macro has run...and then RE-setting the volume to that same level at the end of the macro.
Make sense?

Sort of like...
get volume level/do all other actions/insert-reset original volume level...done. ;)

Thanks much for any help.

Image
eventghost.net
Be there or be square.
User avatar
jinxdone
Plugin Developer
Posts: 443
Joined: Tue Jan 02, 2007 4:08 pm

Re: Macro:(Get) Master Volume-Actions- (insert) Master Volume???

Post by jinxdone »

Sure, you can get the master volume level from the windows mixer with the eg.WinApi.SoundMixer.GetMasterVolume() python command.

I think it would be better to control the mixer application by sending windows messages rather than moving the mouse cursor btw. I don't have a creative card though so I dont have an example on that right now.
User avatar
zian
Site Admin
Posts: 569
Joined: Wed Jun 24, 2009 3:54 pm

Re: Macro:(Get) Master Volume-Actions- (insert) Master Volume???

Post by zian »

Thanks for the reply jinxdone,

I have been "playing" around with that particular command for a while now (mostly trial & error...so far nothing but errors). I have seen it posted in a number of topics and honestly I'm sort of lost. After I insert the command (as is) into EG I proceed to get a long string of red error text. I haven't a clue what to do with the that comand before during or after the command.
But I am trying to learn...a bit.

Yup, I guessed that doing all of this would be better/easier with send/post messages...but. I'm lost there too. I have downloaded and used WinInspector to try to find/learn what messages are doing what with the soundmixer app...But that was ALL completely Greek to me.

But thanks a bunch for pointing me in the right direction jinxdone.

Maybe a stupid question...
with "eg.WinApi.SoundMixer.GetMasterVolume()"
do I need to put my soundcard ID (or anything) into the "()" at the end of that code?

btw...
I have also tried the SoundMixerEX plug-in thinking it might give me more Mixer controls on my PC but that was all red error codes too. :(

Thanks again.
eventghost.net
Be there or be square.
User avatar
jinxdone
Plugin Developer
Posts: 443
Joined: Tue Jan 02, 2007 4:08 pm

Re: Macro:(Get) Master Volume-Actions- (insert) Master Volume???

Post by jinxdone »

Paste this into EG and try running the macro. Does it work? (it should print a line with a number in it into the log view)

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="851">
    <Macro Name="eg.WinApi.SoundMixer.GetMasterVolume()" Expanded="True">
        <Action>
            EventGhost.PythonCommand(u'print(eg.WinApi.SoundMixer.GetMasterVolume())')
        </Action>
    </Macro>
</EventGhost>
If you do get some error when running that command then please post the EG version number and the error messages you are getting.. (you can copy & paste from the log view)
User avatar
zian
Site Admin
Posts: 569
Joined: Wed Jun 24, 2009 3:54 pm

Re: Macro:(Get) Master Volume-Actions- (insert) Master Volume???

Post by zian »

I pasted it and executed it jinxdone,
I didn't get any red text in the log and I did get a long number as the very last line of three in the log...
eg.WinApi.SoundMixer.GetMasterVolume()
print(eg.WinApi.SoundMixer.GetMasterVolume())
20.9948882277


That is/was my master volume level huh?
Sweet. That is the closest I have come so far.
But still a ways to go.
Thanks again.
eventghost.net
Be there or be square.
User avatar
zian
Site Admin
Posts: 569
Joined: Wed Jun 24, 2009 3:54 pm

Re: Macro:(Get) Master Volume-Actions- (insert) Master Volume???

Post by zian »

Getting closer...

I took the code from above that you gave me and I made that work with my volume up/down macros. I have now have a working OSD with my Sound Levels as a percent (with help from another thread/topic).

I think my isse has been I was missing one "(" at the front of the code I have been trying to use from another thread.

Now if I only new how to put that into the sourround mixer macro...and then use it to set the sound level back to "pre-macro" levels. I'll be happy.


btw...
The OSD for Vol. up/down shows a percentage/number value. Is it possible to do it in just a bar graph across my screen? That would be SWEET.
But first things first.
eventghost.net
Be there or be square.
User avatar
jinxdone
Plugin Developer
Posts: 443
Joined: Tue Jan 02, 2007 4:08 pm

Re: Macro:(Get) Master Volume-Actions- (insert) Master Volume???

Post by jinxdone »

Just store the value in a variable and after the macros have executed set the volume back again with the eg.WinApi.SoundMixer.SetMasterVolume().

A quick example that gets master volume and stores it, does something in between(in my case it sets volume to 5% and waits 1 second), then set the master volume back to what it was in the beginning. Simple.

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="851">
    <Macro Name="Set volume and restore it" Expanded="True">
        <Action>
            EventGhost.PythonCommand(u'tmpvol = eg.WinApi.SoundMixer.GetMasterVolume()')
        </Action>
        <Action>
            System.SetMasterVolume(5.0, 0)
        </Action>
        <Action>
            EventGhost.Wait(1.0)
        </Action>
        <Action>
            EventGhost.PythonCommand(u'eg.WinApi.SoundMixer.SetMasterVolume(tmpvol)')
        </Action>
    </Macro>
</EventGhost>
It should be perfectly doable to display a bar according to the volume percentage, but I'm not sure if anybody has made a plugin for that yet..
User avatar
zian
Site Admin
Posts: 569
Joined: Wed Jun 24, 2009 3:54 pm

Re: Macro:(Get) Master Volume-Actions- (insert) Master Volume???

Post by zian »

GREAT!!!
It worked like a charm jinxdone.

I think having these issues and getting help (and your explanations) have taught me a thing or two about Python & EG.

Thanks again my friend.
eventghost.net
Be there or be square.
baruchno
Posts: 8
Joined: Thu Sep 03, 2009 10:03 pm

Re: Macro:(Get) Master Volume-Actions- (insert) Master Volume???

Post by baruchno »

Hi im using this command to get my master volume

eg.WinApi.SoundMixer.GetMasterVolume()

and when i use this command to disaply it

OSD: Vol Up ({int(eg.result)}%)

it works but always gives me 100%

any suggestions please ?
Post Reply