Game Development Community

Wheeled Vehicle Engine Sound

by Daniel Neilsen · in Torque Game Engine · 03/25/2003 (2:10 pm) · 15 replies

Hi Guys,

I am having a problem where the engine sounds are fine to start with but, after I suicide and respawn, the engine sound for the previosu vehicle (I am assuming it is anyway) seems to still be there but at the spawn point of the new vehicle.

The old engine sound then remains at that point in a continuous loop. I have checked the onRemove function and the sounds are certainly being cleaned up there.

Just wondering if anyone else has encountered this or knows of a fix.

It may be that it is something to do with changes I have made in the vehicle code but I suspect that this may be a HEAD issue as I didnt really alter that kind of stuff.

#1
03/25/2003 (2:16 pm)
i've encountered this with an unaltered HEAD
#2
03/25/2003 (2:52 pm)
ok,
phew, that confirms that it isnt my code then.

Anyone have any ideas why that would be happening?

Throught testing I know that WheeledVehicle::onRemove IS running and it does do this.

if(mEngineSound)
   alxStop(mEngineSound);
mEngineSound = 0;

Which, to me, means it shoudl be killing the engine sound but it isnt.
#3
03/25/2003 (3:53 pm)
Daniel,

I am just going to throw this out there, too see if it may help (sorry, we don't have any vehicles in our game). I ran into major problems with trying to stop any sounds that I had started with alxPlay(). I was attempting the same type of code that you are using:
if (isObject(ModFinished))
   alxStop(ModFinished);
Like you, it was not stopping the sound from playing. Stepping through the code, I noticed that the reference to ModFinished was the object ID, not the handle (which is required as a parameter to alxStop). Here is the code that I am using now to correctly start and stop a sound:
$audioHandle = alxPlay("ModFinished");

....later on in the mission....

if ($audioHandle != 0)
   alxStop($audioHandle);

Rich
#4
03/25/2003 (4:00 pm)
I am running this sound from the engine, not from script, but what you have written is a good suggestion.

Unfortunately, I think it is already doing that.

(This is just from memory)
mEngineSound = alxplay(WheeledVehicle::Sound[EngineSound], &getTransform());

I wonder if it needs to be checked with
if (mEngineSound != 0)
rather than
if (mEngineSound)

That might be worth a try. Anyone else have any ideas?
#5
03/25/2003 (5:00 pm)
Daniel,

I should have picked up on it being C++ code instead of script (been a long day). As far as calling alxPlay and alxStop in the code here is what I have used:
if (NULL_AUDIOHANDLE  != (mWavHandle = alxCreateSource(&desc, fileBuffer, 0))) 
   alxPlay(mWavHandle);

...

if (mWavHandle != NULL_AUDIOHANDLE)
{
   alxStop(mWavHandle);
   mWavHandle = NULL_AUDIOHANDLE;
}
Don't know if that helps...

Rich
#6
03/25/2003 (5:03 pm)
That could work.
Ill give that a try whenI get home tonight and let you know how I get on.
Thanks Rich
#7
03/26/2003 (1:48 pm)
I gave it a try and it didnt seem to make any difference in this situation rich although the audio setup of the wheeled vehicle class is a little different so I am not sure if I have applied it correctly.

Do you have an example of an instance where you used this so I can replicate it? eg. player footsteps or something.

If we can get it to work it should probably be patched into HEAD as it is a HEAD bug.
#8
03/26/2003 (3:58 pm)
Daniel,

The sample code I referenced came from a mod that I made to engine/gui/guiAviBitmapCtrl.cc (see this thread for the complete mod). Here are the three functions that setup, play and stop a sound:
bool GuiAviBitmapCtrl::sndOpen()
{
   char               fileBuffer[1024];
   Audio::Description desc;

   // Build the audio description
   desc.mVolume    = 1.0f;
   desc.mIsLooping = false;
   desc.mIs3D      = false;
   desc.mType      = 0;

   // Create the audio source
   dSprintf(fileBuffer, sizeof(fileBuffer), "%s", mWavFilename);
   mWavHandle = alxCreateSource(&desc, fileBuffer, 0);

   return (mWavHandle != NULL_AUDIOHANDLE);
}

void GuiAviBitmapCtrl::sndStart()
{
   if (mWavHandle != NULL_AUDIOHANDLE)
      alxPlay(mWavHandle);
}

void GuiAviBitmapCtrl::sndStop()
{
   if (mWavHandle != NULL_AUDIOHANDLE)
   {
      alxStop(mWavHandle);
      mWavHandle = NULL_AUDIOHANDLE;
   }
}
I also tried to find code similar to yours (and that I am familiar with), you might want to checkout the function Precipitation::prepRenderImage in engine/game/fx/precipitation.cc as it looks more like your code.
If you want to, zip up and email me the mod you created (assuming it is a mode) and I would be more than happy to debug it with you.

Rich

[edit]
Fixed my poor grammar.
[/edit]
#9
03/26/2003 (4:51 pm)
Well,
You should be able to test with the default racing mod. Just set up a car with an engine audio sound and drive around. Then suicide(ctrl k) and when your vehicle respawns, you will hear your current vehicles engine plus another engine that is at max volume (instead of idle volume)
#10
03/27/2003 (1:29 am)
While we're at this subject, has anyone else encountered the problem that if a vehicle is spawned outside hearing range, the engine sound never starts playing? Also, on some occasions the engine sound seems to stick at 0/0/0, which I believe is a bug in OpenAL because it's DLL-dependend...

All in all, I must say that I'm not impressed with OpenAL. Especially the channel limit is annoying, plus there are dozens of DLLs out there. One seems to work on integrated cards, another one works for creative cards, etc.
#11
03/27/2003 (3:47 am)
Daniel,

Using the information you supplied, I was able to setup the engine sound. Here I the steps that I followed:

1) Since I don't have any engine sounds I "borrowed" outrider_engine.wav from Tribes 2. I created the directory racing\data\sounds\ and placed the wav file there.

2) I then modified racing\server\scripts\car.cs and added the below code at Line #29:
datablock AudioProfile(ScoutEngineSound)
{
   filename    = "~/data/sounds/outrider_engine.wav";
   description = AudioDefaultLooping3d;
   preload     = true;
};
3) While editing racing\server\scripts\car.cs, I uncommented the below line (around line #147 after the above modifications):
engineSound = ScoutEngineSound;
4) I ran the racing mod using the below command line:
torqueDemo -mod racing

Once the mission started, I had an engine sound that appears to be working correctly (i.e. idle sound when stopped, gets louder when I drive around,...etc.). After driving away from the spawn point I press -K to commit suicide. After I am respawned the only sound I hear is the engine idling sound (which I believe is the desired result). I even drove over to where I committed suicide to see of the old engine sound might still be playing and it was not.

I am using the current HEAD (i.e. current through change # 3171) and the original OpenAL drivers that GG's distributed.

Rich
#12
03/27/2003 (5:28 am)
Quote:
has anyone else encountered the problem that if a vehicle is spawned outside hearing range, the engine sound never starts playing? Also, on some occasions the engine sound seems to stick at 0/0/0, which I believe is a bug in OpenAL because it's DLL-dependend...

All in all, I must say that I'm not impressed with OpenAL. Especially the channel limit is annoying, plus there are dozens of DLLs out there. One seems to work on integrated cards, another one works for creative cards, etc.
Yes, yes, yes and yes... I'm encountering exactly the same problems since months and couldn't find the problem yet ... It would be GREAT if anybody who knows the OpenAL stuff in Torque could look at this... (Mark F. has said he will look into it a couple of weeks ago, so let's hope the best...)
#13
04/11/2003 (4:48 am)
I recently tried the newly released OpenAL driver, and the results are underwhelming. The engine sounds behave exactly as in the previous drivers, plus this driver doesn't play the GUI sounds properly.
#14
04/11/2003 (9:11 am)
yep, no improvement whatsoever in that regard... same problems as before... :/
#15
11/23/2003 (5:16 pm)
I'm having the issue under Linux (RedHat 7.3) that I don't get any engine sounds regardless of the build I make (release or debug) using the latest head.

I've also added the deathcar mod and the explosions do work, but I never get the engine sounds.

FYI, I just purchased the sdk and have never played with the racing mod before, so I've never had engine sounds to compare a working version of the game to.

Is there anything I can try ingame to try and turn the sounds on?

Also, how do you get the racing game to run without running -game demo and then selecting the racing game from the main menu?