Game Development Community

[Bug Beta3] Auto Gunfire Audio Jamming-Resolved

by Steve Acaster · in Torque 3D Professional · 06/24/2009 (6:30 pm) · 6 replies

When firing a pretty fast rpm weapon, the gunfire audio sticks/jams/continues to play after trigger is released/weapon has stopped firing. Requires 2 or more seconds of sustained gunfire, and then continues playing shooting sound for a while. Does not occur on slower firing auto weapons.

Fire timeout = 0.05
Reload timeout = 0.01

On anything less than 0.05 XAudio doesn't like it and DirectSound really doesn't like it.

From Beta3 known issues - no idea if this is related ...
Quote:XAudio SFX device reports bad playback positions after seeking

This problem didn't crop up in beta2.

Resolved

#1
06/24/2009 (6:44 pm)

Okay, on to this. Couldn't reproduce with FMOD and OpenAL on Mac, but will look more thoroughly into this tomorrow.

XAudio is the weakest of the devices currently due to its pretty unorthodox API (the others at least have a fair amount of similarity), but it surprises me that DSound is giving issues as it turned out to be just about the most stable of all devices.

Are you seeing this with FMOD and OpenAL on Windows?

#2
06/24/2009 (7:13 pm)
I'm on Vista32, and don't have an FMOD available, actually just realised I don't have OpenAL anymore (HD blew up a while back).

Edit: It really doesn't like OpenAL after installing it, worse than DirectSound.
#3
06/24/2009 (7:23 pm)

Confirmed. Can reproduce this by cycling weapons at high speed. The weapon switching sound will then behave as you describe.

Think the SFXSource virtualization screws up.

Logged as THREED-502.
#4
06/29/2009 (4:21 am)

It's indeed the virtualization. The following changes seem to solve this issue. Could you give this a spin, Steve?

In core/util/timeSource.h change the GenericTimeSource::setPosition method to read:

void setPosition( TickType pos )
      {
         if( !isStarted() ) // This wasn't handled correctly before.
            mStartTime = pos;
         else
         {
            TickType savedStartTime = mStartTime;

            mStartTime = ( mTimer.getTick() - pos );
            if( mPauseTime )
               mPauseTime = ( mStartTime + ( mPauseTime - savedStartTime ) );
         }
      }

and in sfx/sfxSource.cpp change the method SFXSource::_releaseVoice to read:

void SFXSource::_releaseVoice()
{
   AssertFatal( !isStreaming(),
      "SFXSource::_releaseVoice() - must not release voices for streaming sources" );

   // If we're currently playing, transfer our playback position
   // to the playtimer so we can virtualize playback while not
   // having a voice.

   SFXStatus status = getLastStatus();
   if( status == SFXStatusPlaying || status == SFXStatusBlocked )
   {
      mPlayTime.setPosition( mVoice->getPosition() );
      mPlayTime.start(); // This was missing.

      if( status == SFXStatusBlocked )
         status = SFXStatusPlaying;
   }

   mVoice = NULL;
}

Thank you.
#5
06/29/2009 (6:40 am)
[Thumbs_up]
Yep, that seems to work fine now.
[/Thumbs_up]
#6
06/29/2009 (4:16 pm)

Thanks for testing.

THREED-502 is a goner.