CodingWin 7 - Set Volume

 

Press Ctrl+Enter to quickly submit your post
Quick Reply  
 
 
  
 From:  Peter (BOUGHTONP)  
 To:  ALL
38431.1 
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!? :'(
0/0
 Reply   Quote More 

 From:  af (CAER)  
 To:  Peter (BOUGHTONP)     
38431.2 In reply to 38431.1 
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.
0/0
 Reply   Quote More 

 From:  Chris Cooper (DEATHTERRAPIN)  
 To:  Peter (BOUGHTONP)     
38431.3 In reply to 38431.1 
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.

0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  af (CAER)     
38431.4 In reply to 38431.2 
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! :@)
0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  Chris Cooper (DEATHTERRAPIN)     
38431.5 In reply to 38431.3 
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. :@
0/0
 Reply   Quote More 

 From:  Chris Cooper (DEATHTERRAPIN)  
 To:  Peter (BOUGHTONP)     
38431.6 In reply to 38431.5 

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

0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  Chris Cooper (DEATHTERRAPIN)     
38431.7 In reply to 38431.6 
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?
0/0
 Reply   Quote More 

 From:  Chris Cooper (DEATHTERRAPIN)  
 To:  Peter (BOUGHTONP)     
38431.8 In reply to 38431.7 
Nope, sorry.

0/0
 Reply   Quote More 

 From:  Kenny J (WINGNUTKJ)  
 To:  Peter (BOUGHTONP)     
38431.9 In reply to 38431.7 
Are your ears able to perceive the differences in volume that accurately?

Kenny
0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  Kenny J (WINGNUTKJ)     
38431.10 In reply to 38431.9 

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.

0/0
 Reply   Quote More 

 From:  af (CAER)  
 To:  Peter (BOUGHTONP)     
38431.11 In reply to 38431.10 
The 16-bit thing for volume is probably related to the bit depth of standard CD audio, although apparently that's a signed integer.
0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  af (CAER)     
38431.12 In reply to 38431.11 
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
0/0
 Reply   Quote More 

 From:  PNCOOL  
 To:  Kenny J (WINGNUTKJ)     
38431.13 In reply to 38431.9 
He just wants to turn it all the way up to 11.

0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  PNCOOL     
38431.14 In reply to 38431.13 
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%.
0/0
 Reply   Quote More 

 From:  PNCOOL  
 To:  Peter (BOUGHTONP)     
38431.15 In reply to 38431.14 
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%.

0/0
 Reply   Quote More 

 From:  ANT_THOMAS  
 To:  Peter (BOUGHTONP)     
38431.16 In reply to 38431.14 
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.
0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  ANT_THOMAS     
38431.17 In reply to 38431.16 
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. :/
0/0
 Reply   Quote More 

 From:  ANT_THOMAS  
 To:  Peter (BOUGHTONP)     
38431.18 In reply to 38431.17 
Well yeah, videos on YouTube vary in volume too, not a lot to do about it.
0/0
 Reply   Quote More 

 From:  PNCOOL  
 To:  ANT_THOMAS     
38431.19 In reply to 38431.16 
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.

0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  PNCOOL     
38431.20 In reply to 38431.19 
Heh, that's surprising, but nice to hear.

But... is there actually anything on ITV that's worth watching? :S
0/0
 Reply   Quote More 

Reply to All  
 

1–20  21

Rate my interest:

Adjust text size : Smaller 10 Larger

Beehive Forum 1.5.2 |  FAQ |  Docs |  Support |  Donate! ©2002 - 2024 Project Beehive Forum

Forum Stats