[Gambas-user] gb3: gb.sdl.sound: How to adjust the volume of a sound being played
Kevin Fishburne
kevinfishburne at ...1887...
Sat Jul 16 09:36:44 CEST 2011
On 07/16/2011 02:26 AM, Kevin Fishburne wrote:
> I have some code:
>
> ' General declarations.
> Public Ocean As Sound = New Sound(GUI.basepath& "/sound/Ocean.wav")
> Public SeawashHeavy As Sound = New Sound(GUI.basepath& "/sound/Seawash,
> Heavy.wav")
> Public Lake As Sound = New Sound(GUI.basepath& "/sound/Lake.wav")
> Public SeawashMedium As Sound = New Sound(GUI.basepath&
> "/sound/Seawash, Medium.wav")
> Public River As Sound = New Sound(GUI.basepath& "/sound/River.wav")
> Public SeawashLight As Sound = New Sound(GUI.basepath& "/sound/Seawash,
> Light.wav")
>
> Public Sub Initialize()
>
> ' Start basic environmental sound effects.
>
> ' Start water effects.
> Channels.Count = 32
> Channels.Volume = 0
> Ocean.Play(-1)
>
> End
>
> How do I adjust the volume of any of the sounds? I've read the docs
> which say that Channel is a class but other than that they are as
> spartan as a pine box. I've tried some random combinations and exposing
> the methods, etc., just by typing, but am getting nowhere. Thanks as always
Funny how I keep replying to myself. I can only hope someone else reads
these and all their questions are answered.
After a process similar to beating my head against a brick wall until
blood starts seeping from my ears, I found that this code works fine
(knock on wood):
' Gambas module file
' Audio module
' General declarations.
Public sOcean As Sound = New Sound(GUI.basepath & "/sound/Ocean.wav")
Public cOcean As Channel
Public sSeawashHeavy As Sound = New Sound(GUI.basepath &
"/sound/Seawash, Heavy.wav")
Public cSeawashHeavy As Channel
Public sLake As Sound = New Sound(GUI.basepath & "/sound/Lake.wav")
Public cLake As Channel
Public sSeawashMedium As Sound = New Sound(GUI.basepath &
"/sound/Seawash, Medium.wav")
Public cSeawashMedium As Channel
Public sRiver As Sound = New Sound(GUI.basepath & "/sound/River.wav")
Public cRiver As Channel
Public sSeawashLight As Sound = New Sound(GUI.basepath &
"/sound/Seawash, Light.wav")
Public cSeawashLight As Channel
Public Sub Initialize()
' Start basic environmental sound effects.
' Start water effects.
cOcean = sOcean.Play(-1)
cOcean.Volume = 0
cSeawashHeavy = sSeawashHeavy.Play(-1)
cSeawashHeavy.Volume = 0
cLake = sLake.Play(-1)
cLake.Volume = 0
cSeawashMedium = sSeawashMedium.Play(-1)
cSeawashMedium.Volume = 0
cRiver = sRiver.Play(-1)
cRiver.Volume = 0
cSeawashLight = sSeawashLight.Play(-1)
cSeawashLight.Volume = 0
End
That was done through sheer trial and error, sadly. +1 for heads on bricks!
--
Kevin Fishburne
Eight Virtues
www: http://sales.eightvirtues.com
e-mail: sales at ...1887...
phone: (770) 853-6271
More information about the User
mailing list