Muting winamp - scripting Thread last updated on 2006-06-09 18:10:24

Posted by member 302889 on 2006-06-09 10:36:34

Hi all,

i've written this code to mute winamp but it doesnt seem to be working correctly. can someone offer some advice?

At the start of my script file i set a var to say whether winamp is muted or not

*Script var ampMuted "0" ;

Posted by member 302889 on 2006-06-09 10:37:59 link

for some reason half of my post was missing. here it is again...

Hi all,

i've written this code to mute winamp but it doesnt seem to be working correctly. can someone offer some advice?

At the start of my script file i set a var to say whether winamp is muted or not

*Script var ampMuted "0"

Then i have this script to take the current value of winamps volume from xlabel, save it in a var and then mute winamp by setting volume to 0. If winamp is already muted (ampMuted = 1) then it should take the current value from before it was muted and set the volume of winamp to that value and return the ampMuted var to 0.

*Script bang !ampMute
*Script gotoif ("%{ampMuted}" = "1") muted
*script exec !varset currentvol "[volume()]"
*script exec !Amp_SetVolume 0
*script exec !varset ampMuted 1
*Script exit
*Script label muted
*script exec !Amp_SetVolume {currentvol}
*script exec !varset ampMuted 0
*Script ~bang

All that happens when i use this script is that the volume of winamp is lowered to 14% (which is a weird number for it to be lowered to) and when i try to unmute it nothing happens.

Can someone tell me where my scripting is going wrong?

i am using dynamp 0.43, xlabel 3.6, and mzscript 0.8.6l.

cheers

Posted by member 37809 on 2006-06-09 12:22:12 link

you're missing a % and should probably export the volume when you're unmuting it. you also need a !labelinfoexport or !parseevars there. muting a channel is independent of volume level i think.

Posted by member 302889 on 2006-06-09 13:52:11 link

i've not got a normal soundcard on my pc (i produce music) so i can't use the normal windows volume controls as they don't work at all. The only way i can mute winamp is by actually turning the volume of winamp itself down to 0.

is this what you menat by missing a percent? (on the 3rd line)

"[volume()%]"

why do i need !labelinfoexport or !parseevars and where do you think i should put them?

cheers for your help so far

Posted by member 212670 on 2006-06-09 15:23:19 link

I think tnl was refering to the 8th line: {currentvol} should be %{currentvol} to expand your saved var.

Also, the !parseevars he was talking about goes here, and you need two more %s:

*script exec !ParseEvars !varset currentvol "%[volume()]%"

And, that will set the currentvol as a percentage of your volume, like "95%", so you'll probably want to get rid of the % there... so:

*script exec !ParseEvars !varset currentvol "%[remove(volume, '%')]%"

That will set currentvol to a number only, like "95"

Note the missing ' around volume. If you have the single quotes around it, it'll use the actual word, and not expand it to have the % removed.

This presents what is another problem. The volume bangs for dynamp/geekamp is a range from 0 to 255! Not a percentage, which is what xlabel exports. This probably also explains your volume level problem. So, you'll need to do a little math on the number to turn it to a value from 0 to 255.

You'll also want to be exporting the winamp volume, not the master volume, so you need volume('winamp').

So, finally...

*script exec !ParseEvars !varset currentvol "%[remove(volume('winamp'), '%')]%"
*script exec !varmul currentvol 255
*script exec !vardiv currentvol 100

That will make currentvol the variable that you finally want to use with !Amp_SetVolume %{currentvol}.

Posted by member 212670 on 2006-06-09 17:26:39 link

Final script looks like:
*Script bang !ampMute
*Script gotoif ("%{ampMuted}" = "1") muted
*script exec !ParseEvars !varset currentvol "%[remove(volume('winamp'), '%')]%"
*script exec !varmul currentvol 255
*script exec !vardiv currentvol 100
*script exec !Amp_SetVolume 0
*script exec !varset ampMuted 1
*Script exit
*Script label muted
*script exec !Amp_SetVolume %{currentvol}
*script exec !varset ampMuted 0
*Script ~bang


(Sorry for all the edits... and ya, I was bored.)

Posted by member 302889 on 2006-06-09 18:10:24 link

Excellent, i understand all of that and now it doesn't seem like such a hard thing to do.

I've had so many attempts at this myself i'd kinda given up hope.

Thanks very much xcal. I'll have a look at the slider scripts again now and see if i can understand it more. The stuff to do with exportevars was a bit confusing to me but if i look at where it is in the script i might figure it out now.

Cheers

a very grateful lordlupin