Game Development Community

Audio problem

by gamer · in Torque Game Engine · 02/07/2007 (3:15 pm) · 5 replies

I am using TGE 1.4.2, I can't get the audio working in game. I want to play the music once the mission starts.
function StartAmbienceSound(){
   
   if(!isObject(ForestBirdCallsSound)){
      exec("~/client/scripts/sound.cs");
   }

   if($AMBIENCE_SOUND1)alxStop($AMBIENCE_SOUND1);
   $AMBIENCE_SOUND1 = alxPlay(ForestBirdCallsSound);
   
   
}
//client/scripts/sound.cs
new AudioDescription(AudioInGame)
{
   volume   = 1.0;
   isLooping= false;
   is3D     = false;
   type     = $MusicAudioType;

};
datablock AudioProfile(ForestBirdCallsSound)
{
   fileName = "~/data/sound/forestBirdCalls.ogg";
   description = AudioInGame;
   preload = true;
  
};

I got this error when executing sound.cs
AudioProfile: data dataBlcok not networkable(use datablock to create). any idea?
thanks

#1
02/07/2007 (3:22 pm)
You shouldn't use datablocks for music, since a datablock has to be transfered from the server to the client. Use "new".
#2
02/07/2007 (4:06 pm)
Thanks Stefan!!! that solved the compiling error. However when I am in game, the sound won't start. It would start if I just play it outside the game. what's wrong?
new AudioDescription(AudioInGame)
{
   volume   = 1.0;
   isLooping= false;
   is3D     = false;
   type     = $MusicAudioType;

};
new AudioProfile(ForestBirdCallsSound)
{
   fileName = "~/data/sound/forestBirdCalls.ogg";
   description = AudioInGame;
   preload = false;
  
};
#3
02/07/2007 (5:33 pm)
How are you calling it in your game?

It should be:
alxPlay( "ForestBirdCallsSound" );

Put that alxPlay somwhere, usually in game.cs if it's ambient to play it.
#4
02/08/2007 (11:49 am)
I used alxPlay(ForestBirdCallsSound), either way they returned a handle 0.
So I tried AudioEmitter in my mission Map instead.
But there's no way to turn on the AudioEmitter except switch to world editor mode and click on the object manually.
please help
#5
02/14/2007 (9:41 pm)
Hi i am also facing a unique problem in audio TGE 1.5
i have vehicle engine sound look at my audio description
datablock AudioDescription(AudioClosestLooping3d)
{ //auto
volume = 0.50;
isLooping= true;

is3D = true;
ReferenceDistance= 40.0;
MaxDistance= 100.0;
type = $SimAudioType;
coneInsideAngle = 360;
}; //engine sound
this is used in the wheeledvehicle datablock
problem is , the other in-game 2d sound volume is changing after the vehicle colloid with the environment.
following the client sounds and server sound implementation properly.
what could be the problem.

thanks in advance