Help with creating a function

BlitzMax Forums/BlitzMax Beginners Area/Help with creating a function

Olla(Posted 2006) [#1]
Noob question, help needed. I would like to write a general sound function to use in my program, but after many unsuccessfully attempts I gave up so any help on this is much appreciated... What I'm after is a function that I can call with 3 input parameters:

1. Name of loaded sample
2. Which of the allocated channels it should be played in.
3. Its volume.

Here is a dummy non-working example of what I'm looking for.. Hopefully you know what I mean ;-)
...
...

Global Volume#
Global SFXChannel:TChannel = AllocChannel()
Global SND_Boom:TSound = LoadSound ("Data/Sounds/Boom.wav")

..
..

Play_Sound (SND_Boom,SFXChannel,.9)
..
..

Function Play_Sound (Sample,Channel,Volume)

If Channel <> Null Then
Channel.SetVolume(Volume)
PlaySound(Sample, Channel)
EndIf

EndFunction


Jesse(Posted 2006) [#2]
try passing parameters to your function like this
Function Play_Sound (Sample:TSound,Channel:TChannel,Volume#)

if it doesn't work let me know what kind of error you are getting. everything else looks good.


Olla(Posted 2006) [#3]
Hi Jesse,

It works! ;-) thanks for the tip.