How to set sound playback volume?
Posted: Wed Dec 04, 2024 11:40 pm
Hi all,
I'm a new user, enjoying SpiderBasic so far.
Just curious how the volume of a sound can be altered in code.
Here's what I've been working with, starting from the documentation and modifying it based on what I'm reading.
I'm not able to get the volume to change, whether it's a .wav or .mp3 file.
Thanks for any feedback.
I'm a new user, enjoying SpiderBasic so far.
Just curious how the volume of a sound can be altered in code.
Here's what I've been working with, starting from the documentation and modifying it based on what I'm reading.
I'm not able to get the volume to change, whether it's a .wav or .mp3 file.
Code: Select all
InitSound()
Procedure Loading(Type, Filename$, ObjectId)
Debug Filename$ + " loaded (id = " + ObjectId + ")"
PlaySound(0) ; play the sound
EndProcedure
Procedure LoadingError(Type, Filename$)
Debug Filename$ + ": loading error"
EndProcedure
; Register the loading event before calling any resource load command
BindEvent(#PB_Event_Loading, @Loading())
BindEvent(#PB_Event_LoadingError, @LoadingError())
; This works and plays fine
If LoadSound(0, "raf-self-control.mp3") ; Be sure this sound is available (the source file should be saved in the SpiderBasic/Examples drawer)
; This doesn't seem to adjust the volume
;PlaySound(0,#PB_Sound_Loop,50)
; This also doesn't seem to do anything
SoundVolume(0, 0)
EndIf