Sound Help

Blitz3D Forums/Blitz3D Beginners Area/Sound Help

mintybreath(Posted 2007) [#1]
I am learning how to do sound playing in my games. I need a little help. I guess i dont understand it or something. It seems farely simple, but evertime when i try, it says that the sound does not exist. any tips on how to fix this. Or could you please post some example code for how to use sound. some example code would probably help alot.

Thanks, appreciate the help!


Matty(Posted 2007) [#2]

mysoundhandle=loadsound("put your filename in here.")
if mysoundhandle=0 then runtimeerror("Probably your filename was wrong or it was an invalid sound file?")
repeat

if keyhit(57) then 
;space bar was hit
mysoundchannelhandle=playsound(mysoundhandle)
;note normally you would record the channelhandle if you wanted to alter the volume, pause, or pan a sound while it is playing.  You do not need to free the channelhandle produced by playsound, although you do need to free the soundhandle created from loadsound when tidying up memory


endif 

until keydown(1)
freesound mysoundhandle


Hope that helps somewhat.


mintybreath(Posted 2007) [#3]
ok that does help. I will try that out. Thanks alot!