volume adjust during form load and unload

ncks82
03-09-2004, 01:51 PM
how to set the sound to maximun when form load and to is defualt when form unload ??

i know i need to use waveoutgetvolume and waveoutsetvolume but how can i set the volume to max when form load and back to default when form unload???

i the max value is h0000 >??? :huh:
i dont know of this.

help please~!!!

Bljashinsky
03-09-2004, 04:14 PM
What are you using to play the music? This thread has an example program in it: http://www.visualbasicforum.com/showthread.php?t=131314

ncks82
03-09-2004, 06:13 PM
What are you using to play the music? This thread has an example program in it: http://www.visualbasicforum.com/showthread.php?t=131314


i have downloaded the zip earlier, but this is not i want...
anyway, thanks Bljashinsky for you help !!!


i'm using playsound API.
what i want is when the form is load, the volume is set to max automatically and set back to default when form unload.

i think i should use
waveoutsetvolume and waveoutgetvolume...but i donno what's the value for max sound and to set back to its default sound.
and i've follow the tutorial in http://www.mentalis.org/apilist/w.shtml ,
but i dont know how to apply it to my form. :(

please help~

Bljashinsky
03-09-2004, 06:26 PM
Did you read the samples? They are pretty good on that site. As for the max volume on the site it says:

A value of 0xFFFF represents full volume, and a value of 0x0000 is silence.

RedKnight
03-09-2004, 07:27 PM
i got this form the API-Guide Program which is the best program i found for free about the winAPI

here is the link (only 2.20mb)
ApiGuide (http://www.allapi.com)

'Example submitted by Danjel Nyberg
'It needs a textbox (Text1) and three command buttons (Command1, Command2, Command3)
Private Declare Function waveOutSetVolume Lib "Winmm" (ByVal wDeviceID As Integer, ByVal dwVolume As Long) As Integer
Private Declare Function waveOutGetVolume Lib "Winmm" (ByVal wDeviceID As Integer, dwVolume As Long) As Integer
Private Sub Command1_Click()
Dim a, i As Long
Dim tmp As String
a = waveOutGetVolume(0, i)
tmp = "&h" & Right(Hex$(i), 4)
Text1 = CLng(tmp)
End Sub
Private Sub Command2_Click()
Dim a, i As Long
Dim tmp, vol As String
vol = Text1
tmp = Right((Hex$(vol + 65536)), 4)
vol = CLng("&H" & tmp & tmp)
a = waveOutSetVolume(0, vol)
End Sub

Private Sub Command3_Click()
Dim luserSetting As Long
Dim a, i As Long
Dim tmp As String
a = waveOutGetVolume(0, i)
tmp = "&h" & Right(Hex$(i), 4)
luserSetting = CLng(tmp)
Text1 = luserSetting
For i = luserSetting To 0 Step -35
Text1 = i
DoEvents
vol = i
tmp = Right((Hex$(vol + 65536)), 4)
vol = CLng("&H" & tmp & tmp)
a = waveOutSetVolume(0, vol)
Next i
For i = 0 To luserSetting Step 35
Text1 = i
DoEvents
vol = i
tmp = Right((Hex$(vol + 65536)), 4)
vol = CLng("&H" & tmp & tmp)
a = waveOutSetVolume(0, vol)
Next i
End Sub

i added the command3

P.S
To XVBF - i love the new look

CrashDaddy
03-09-2004, 08:37 PM
Should that link be to api.net?

100th Post Crash (hehe)

RedKnight
03-09-2004, 09:17 PM
opps your right heres the right link:
APi Guide (http://www.allapi.net)

ncks82
03-10-2004, 12:53 AM
i got this form the API-Guide Program which is the best program i found for free about the winAPI

here is the link (only 2.20mb)
ApiGuide (http://www.allapi.com)

'Example submitted by Danjel Nyberg
'It needs a textbox (Text1) and three command buttons (Command1, Command2, Command3)
Private Declare Function waveOutSetVolume Lib "Winmm" (ByVal wDeviceID As Integer, ByVal dwVolume As Long) As Integer
Private Declare Function waveOutGetVolume Lib "Winmm" (ByVal wDeviceID As Integer, dwVolume As Long) As Integer
Private Sub Command1_Click()
Dim a, i As Long
Dim tmp As String
a = waveOutGetVolume(0, i)
tmp = "&h" & Right(Hex$(i), 4)
Text1 = CLng(tmp)
End Sub
Private Sub Command2_Click()
Dim a, i As Long
Dim tmp, vol As String
vol = Text1
tmp = Right((Hex$(vol + 65536)), 4)
vol = CLng("&H" & tmp & tmp)
a = waveOutSetVolume(0, vol)
End Sub

Private Sub Command3_Click()
Dim luserSetting As Long
Dim a, i As Long
Dim tmp As String
a = waveOutGetVolume(0, i)
tmp = "&h" & Right(Hex$(i), 4)
luserSetting = CLng(tmp)
Text1 = luserSetting
For i = luserSetting To 0 Step -35
Text1 = i
DoEvents
vol = i
tmp = Right((Hex$(vol + 65536)), 4)
vol = CLng("&H" & tmp & tmp)
a = waveOutSetVolume(0, vol)
Next i
For i = 0 To luserSetting Step 35
Text1 = i
DoEvents
vol = i
tmp = Right((Hex$(vol + 65536)), 4)
vol = CLng("&H" & tmp & tmp)
a = waveOutSetVolume(0, vol)
Next i
End Sub

i added the command3

P.S
To XVBF - i love the new look


thanks for ya reply. may i know what's the 3rd button for ??? what's the purpose? can u explain to me ?






a = waveOutGetVolume(0, i)
tmp = "&h" & Right(Hex$(i), 4)
Text1 = CLng(tmp)


is this mean i get the current volume and assign it to text 1 ??
i is the current value ?? and i dont understand understand why

tmp = "&h" & Right(hex&(i),4) ?>>> this is for what purpose?

y it want to extract 4 digit from the right ??

and


Private Sub Command2_Click()
Dim a, i As Long
Dim tmp, vol As String
vol = Text1
tmp = Right((Hex$(vol + 65536)), 4)
vol = CLng("&H" & tmp & tmp)
a = waveOutSetVolume(0, vol)
End Sub



and this is more confusing, :huh:
is it it set the volume typed in the textbox ??

why this 2 line is required ?

tmp = Right((Hex$(vol + 65536)), 4)
vol = CLng("&H" & tmp & tmp)

???
please explain~~
thanks

RedKnight
03-10-2004, 01:09 AM
i dont really know whats goin on in the code sry i was hopin that some one tell you about it i just found it in api guide

the command1 is to get the volume and to make it in numbers instead of hex
then command2 is to set the volume by makin the text1 into hex
then i added the command3 to show you how to use it to get the usersetting then chage it by trun the volume down the back up to usersetting,
thats all i know about the code sry - i never used the getvolume and setvolume before

ncks82
03-10-2004, 01:16 AM
i've tried on it....
i think it's only max based on my sound card, if i've set my sound card to certain level, the max is constraint by my sound card...

what i want is it go to the max level of my sound card and max volume in my volume control in my speaker .

is it possible ??

anyways, thanks for every help !!!
i'm really appreciated @@@!! ;)

RedKnight
03-10-2004, 01:25 AM
the wavesetvolume sets the waveout of the soundcard mixer what you wont is the the master volume - but i dont know how to do that

ncks82
03-10-2004, 01:56 AM
the wavesetvolume sets the waveout of the soundcard mixer what you wont is the the master volume - but i dont know how to do that


master volume ?
what's that ??

RedKnight
03-10-2004, 01:58 AM
open up your volume control in the bottom-right beside the clock on the taskbar

ncks82
03-10-2004, 02:00 AM
i dont really know whats goin on in the code sry i was hopin that some one tell you about it i just found it in api guide

the command1 is to get the volume and to make it in numbers instead of hex
then command2 is to set the volume by makin the text1 into hex
then i added the command3 to show you how to use it to get the usersetting then chage it by trun the volume down the back up to usersetting,
thats all i know about the code sry - i never used the getvolume and setvolume before



tmp = Right((Hex$(vol + 65536)), 4)


y need to plus 65536, as i know 65536 is H10000, what vol need to plus it ?

RedKnight
03-10-2004, 02:04 AM
The low-order word contains the left-channel volume setting, and the high-order word contains the right-channel setting. A value of 0xFFFF represents full volume, and a value of 0x0000 is silence.
If a device does not support both left and right volume control, the low-order word of dwVolume specifies the volume level, and the high-order word is ignored.

copied form api guide

ncks82
03-10-2004, 02:17 AM
The low-order word contains the left-channel volume setting, and the high-order word contains the right-channel setting. A value of 0xFFFF represents full volume, and a value of 0x0000 is silence.
If a device does not support both left and right volume control, the low-order word of dwVolume specifies the volume level, and the high-order word is ignored.

copied form api guide


i know, but why want to plus 65535 ??

RedKnight
03-10-2004, 02:25 AM
im sry i really dont know much about this subject

Bljashinsky
03-10-2004, 07:08 AM
To set the master volume is pretty complicated but can be done using APIs. This thread explains it all: http://www.visualbasicforum.com/showthread.php?threadid=52035

ncks82
03-11-2004, 07:39 AM
ok ..thanks ya everyone !!!!!

i owed u guys a favours !!!!

thanks!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum