Win 7 - Set Volume

From: Peter (BOUGHTONP) 2 May 2011 14:21
To: ALL1 of 21
I want a script so I can type "vol 50" and the volume gets changed to 50%, "vol 0" and it mutes, and so on.

I'm finding a whole bunch of long over-complicated explanations for things when I just want a simple script to save me a bit of time.

I found this page:
http://msdn.microsoft.com/en-us/library/ms679141(VS.85).aspx

But if I put either...
code:
SetMasterVolume 0.5
or
code:
SetMasterVolume 0.5 , null

...into a VBS file it gives error
quote:
Type Mismatch: 'SetMasterVolume'


The useless piece of shit doesn't give me any clue what type is mismatched, and nothing I try works, and Google is no help either.


All I want to do is programmatically change master volume - why is it so much effort!? :'(
From: af (CAER) 2 May 2011 15:47
To: Peter (BOUGHTONP) 2 of 21
Possibly something to do with VB's weirdass syntax where if you call a function you have to assign its return value to a variable? That might not be the case, mind - my only experience with VB is doing macro stuff in Excel 2003.
From: Chris Cooper (DEATHTERRAPIN) 2 May 2011 15:57
To: Peter (BOUGHTONP) 3 of 21
That function seems to be part of a native API, you're not going to be able to call that from vbs afaik.

This command line tool can set volume, I used it myself last week.
From: Peter (BOUGHTONP) 2 May 2011 16:01
To: af (CAER) 4 of 21
Good thought, but didn't help. :(

Tried both:
code:
Dim Bert
Bert = SetMasterVolume( 0.5 , NULL )

and
code:
Call SetMasterVolume( 0.5 , NULL )


But both give same error.


(There's some silly rule about when you can/can't use parentheses for multi-arg function calls, if I didn't use them here I got errors about that, but the other code only works if I don't use them. Don't you just love Microsoft! :@)
From: Peter (BOUGHTONP) 2 May 2011 16:22
To: Chris Cooper (DEATHTERRAPIN) 5 of 21
quote:
That function seems to be part of a native API, you're not going to be able to call that from vbs afaik.

Huh? Why the hell not?

quote:
This command line tool can set volume

No it can't, it can increase or decrease the volume, but not set it.

And for some reason it uses a scale of 65536 for doing so.

Which means I need to do:
code:
nircmd changesysvolume -65535
nircmd changesysvolume 65535 * <vol>/100


Except bloody Windows command line doesn't do maths, so it's not quite that simple...

code:
set /a v = 65535 * %1 / 100
C:\path\to\nircmd.exe changesysvolume -65535
C:\path\to\nircmd.exe changesysvolume %v%


Which works, but is really ugly. :/


I hate Microsoft. :@
EDITED: 2 May 2011 16:25 by BOUGHTONP
From: Chris Cooper (DEATHTERRAPIN) 2 May 2011 16:55
To: Peter (BOUGHTONP) 6 of 21

It can set volume - use setsysvolume.
And its 0-65535 because sound volumes in windows are 16 bit integers.

From: Peter (BOUGHTONP) 2 May 2011 17:10
To: Chris Cooper (DEATHTERRAPIN) 7 of 21
Grrr! Stupid badly written documentation page made me miss that.


Just because Windows uses 16-bit integers doesn't mean it doesn't make sense to use them. Should be normallised to 100.00 instead.


Anyway, something else that'd be handy, is being able to display what the actual volume level is. Properly, using numbers, instead of just having three different images, and the difference between the 33..65 and 66..100 one being a single feint pixel! :@

Don't suppose you know of anything that does that?
From: Chris Cooper (DEATHTERRAPIN) 2 May 2011 17:25
To: Peter (BOUGHTONP) 8 of 21
Nope, sorry.
From: Kenny J (WINGNUTKJ) 2 May 2011 19:08
To: Peter (BOUGHTONP) 9 of 21
Are your ears able to perceive the differences in volume that accurately?
From: Peter (BOUGHTONP) 2 May 2011 20:24
To: Kenny J (WINGNUTKJ) 10 of 21

Sometimes. Maybe. :P

 

My point was more the other direction though - we probably don't need sixty five thousand levels.

 

It could either use 1 byte instead of 2, and then just have a direct 1:1 mapping of percentage to volume, or - in case there is some obscure software that requires it - make it a 2-byte float so it's no effort for programmers/users to translate, because it's still a percentage, but you've still got that precision if necessary.

EDITED: 2 May 2011 20:24 by BOUGHTONP
From: af (CAER) 2 May 2011 20:47
To: Peter (BOUGHTONP) 11 of 21
The 16-bit thing for volume is probably related to the bit depth of standard CD audio, although apparently that's a signed integer.
From: Peter (BOUGHTONP) 2 May 2011 20:54
To: af (CAER) 12 of 21
Not sure why it would need to be same, but meh.

It'd be nice if the page would say why it's signed. I can't think of any logic in having negative volume? :S
From: PNCOOL 4 May 2011 17:36
To: Kenny J (WINGNUTKJ) 13 of 21
He just wants to turn it all the way up to 11.
From: Peter (BOUGHTONP) 4 May 2011 17:53
To: PNCOOL 14 of 21
Actually... if you do know a way to amplify beyond 100% that'd be handy.

With some things (e.g. Last.fm) I can set everything to 100% and it'll still play quieter than, for example, BBC iPlayer at 3 and 50%.
From: PNCOOL 4 May 2011 17:56
To: Peter (BOUGHTONP) 15 of 21
There are probably some crap audio booster applications somewhere, but it'll no doubt distort the signal more as well. I don't even like the Windows volume sliders on 100%.
EDITED: 4 May 2011 17:56 by PNCOOL
From: ANT_THOMAS 4 May 2011 18:01
To: Peter (BOUGHTONP) 16 of 21
I think iPlayer content is just mixed significantly louder than normal stuff anyway. It's much louder than everything else I play on XBMC, including broadcast TV and downloaded content.
From: Peter (BOUGHTONP) 4 May 2011 18:12
To: ANT_THOMAS 17 of 21
Well yeah, but it's not the only thing.

I tend to have YouTube on about 40% (with Win at 50%), and I think I might have Vimeo even lower.

But then Jango I put at 100%, and then vary Win's level from 60% upwards (which is now much easier, yay), because they don't have a normalised catalogue (and some songs just sound better louder/quieter anyway).

Can all get rather frustrating. :/
From: ANT_THOMAS 4 May 2011 18:22
To: Peter (BOUGHTONP) 18 of 21
Well yeah, videos on YouTube vary in volume too, not a lot to do about it.
From: PNCOOL 7 May 2011 20:29
To: ANT_THOMAS 19 of 21
ITV's player's pretty cool, as it seems to dip the volume lower for the adverts on anything I normally watch. It's a pity they can't do that on the actual TV, as usually the adverts are shouting at me instead.
From: Peter (BOUGHTONP) 7 May 2011 20:33
To: PNCOOL 20 of 21
Heh, that's surprising, but nice to hear.

But... is there actually anything on ITV that's worth watching? :S