[futurebasic] Changing Output Speaker Volumes

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 2002 : Group Archive : Group : All Groups

From: tedd <tedd@...>
Date: Fri, 22 Feb 2002 12:06:45 -0500
Hi:

Just to share.

The following code adjust the sound level in your Sound Control Panel.

In keeping with the gnome directives, please return your tray tables 
to upright positions before departing.

Thanks Alain.

tedd


' -------- Control Panel Sound Level Demo ----------
' by tedd with thanks to Alain.
' For grins, watch the sound control panel change while running.

DEFSTR LONG
DIM level&
end globals

Toolbox fn GetDefaultOutputVolume(long @level&) = OSErr 
`0x203C,0x022C, 0x0018, 0xA800
Toolbox fn SetDefaultOutputVolume(long level&)  = OSErr 
`0x203C,0x0230, 0x0018, 0xA800

dim err,a$, key%

WINDOW 1,"Control Panel Sound  Demo"
TEXT _Monaco,9

print
PRINT "Set Control Panel Sound level (0 = Off ... 9 = loudest),"
PRINT "<Q> quits"
DO
a$=INKEY$
key% = ASC(a$)-48
LONG IF key%>=0 AND key%<=9

err = fn GetDefaultOutputVolume(@level&)
PRINT "Old Volume: = ";hex$(level&)

' Note right and left channels. First two bytes is right chanel
' second two bytes is left channel -- range 00-100 HEX.

select key%
case 0
level& = 0x00000000
case 1
level& = 0x00190019
case 2
level& = 0x00320032
case 3
level& = 0x004B004B
case 4
level& = 0x00640064
case 5
level& = 0x007D007D
case 6
level& = 0x00960096
case 7
level& = 0x00AF00AF
case 8
level& = 0x00C800C8
case 9
level& = 0x01000100
end select

err = fn SetDefaultOutputVolume(level&)
PRINT "New Volume: = ";hex$(level&)
PRINT

BEEP: BEEP
END IF

UNTIL a$="Q" OR a$="q"

END






-- 
http://sperling.com