Game Development Community

Schedule a Sound File

by Danny Wyatt · in Torque Game Engine · 05/02/2006 (9:59 am) · 3 replies

I am trying to schedule a sound file to play during the game and I need the correct way to do this. I'm calling it like this but it's not working.

schedule(1000, alxPlay, EnviroSound);

EnvrioSound is the sound Profile.

any help is greatly appreciated, thanks.

#1
05/02/2006 (10:10 am)
You need to set the object to NULL, ie:

Quote:
schedule(1000, 0, alxPlay, EnviroSound);

And most likely also add "" marks to your argument, ie:

Quote:
schedule(1000, 0, alxPlay, "EnviroSound");

Have fun!
#2
05/02/2006 (10:19 am)
I'm assuming you've set up your audio correctly, it should look something like this

At the top of client/audioProfiles.cs
// Channel assignments (channel 0 is unused in-game).

$GuiAudioType     = 1;
$SimAudioType     = 2;
$MessageAudioType = 3;
$EnviroAudioType  = 4;

Somewhere in server/audioprofiles.cs
datablock AudioDescription(EnvironmentSounds)
{
   volume   = 1.0;
   isLooping= true;
   is3D     = false;
   type     = $EnviroAudioType;
};

datablock AudioProfile(myEnviroSound)
{
   filename = "~/data/sound/myEnviroSound.ogg";
   description = EnvironmentSounds;
   preload = true;
};

Some of the commands available to you through script
$EnviroHandle = alxPlay(myEnviroSound); //play the sound
alxStop($EnviroHandle); //stop the sound

To schedule
function playEnviroSound()
{
   $EnviroHandle = alxPlay(myEnviroSound);
}
   schedule(1000, "playEnviroSound");
#3
05/03/2006 (5:18 am)
Thanks ! Yes I do have my description and profile set up but the function you've got there works perfect. Thanks again.