Engine Starter Sound Questions
by Ronald J Nelson · in Torque Game Engine · 04/26/2007 (10:59 am) · 4 replies
OK first off I have integrated the Transmission for vehicles resource into my code and have made a ton of changes to it. Included in that is a working ignition system. Now I want to add the final touches to it with the sound system.
What I need to now is how to detect if the start engine sound which I have called mStartEngineSound is finished and use that to start the regular engine sound?
Here is my function area where I start my engine:
Obviously there is a lot more to my code than that, but that is the part where my engine sound is currently started up. To be honest I don't know what calls can be made to determine if the sound is finished or not and I guess a While statement would probably work to hold things up before starting the the actual engine sound. Let me know if I am totally off on that.
Any help would be appreciated.
What I need to now is how to detect if the start engine sound which I have called mStartEngineSound is finished and use that to start the regular engine sound?
Here is my function area where I start my engine:
void WheeledVehicle::setIgnition(const bool& _active)
{
// If the ignition state is already set, early out...
if (ignition_Active == _active)
{
return;
}
// Set the new ignition state.
ignition_Active = _active;
// If the ignition is now active...
if (ignition_Active)
{
// On the client...
if (isClientObject())
{
// Create and play the new audio, making sure the audio handle is set.
mEngineSound = alxPlay(mDataBlock->sound[WheeledVehicleData::EngineSound], &getRenderTransform());
}Obviously there is a lot more to my code than that, but that is the part where my engine sound is currently started up. To be honest I don't know what calls can be made to determine if the sound is finished or not and I guess a While statement would probably work to hold things up before starting the the actual engine sound. Let me know if I am totally off on that.
Any help would be appreciated.
#2
HOWEVER!!!! When the while statement is in use, the whole game pauses. Why??
04/30/2007 (2:38 pm)
OK I got it working with this code:// On the client...
if (isClientObject())
{
// Create and play the new audio, making sure the audio handle is set.
mStartEngineSound = alxPlay(mDataBlock->sound[WheeledVehicleData::StartEngineSound], &getRenderTransform());
alxSourceMatrixF(mStartEngineSound, &getTransform());
alxSourcef(mStartEngineSound, AL_GAIN_LINEAR, 0.8f);
alxSourcef(mStartEngineSound, AL_PITCH, 1.0);
while(alxIsPlaying(mStartEngineSound))
{
//Pause
}
alxStop(mStartEngineSound);
mStartEngineSound = 0;
mEngineSound = alxPlay(mDataBlock->sound[WheeledVehicleData::EngineSound], &getRenderTransform());
}HOWEVER!!!! When the while statement is in use, the whole game pauses. Why??
#3
04/30/2007 (2:41 pm)
One more thing is there some way to set the Gain to the volume level based in a Audio profile?It would be a hell of a lot easier that constantly recompiling each time I make an adjustment.
#4
05/01/2007 (9:30 pm)
*BUMP*
Torque 3D Owner mb
http://tdn.garagegames.com/wiki/TorqueScript_Console_Functions_1
alxGetStreamPosition or alxIsPlaying might work.