SFX Bug: Modifying pitch requires restarting the source.
by Stefan Lundmark · in Torque Game Engine Advanced · 11/19/2008 (10:00 am) · 11 replies
Upon changing the pitch of a sound source, you have to completely stop the sound and play it again for the sound to be affected by the pitch. I'm doing this in advanceTime (), and upon using play () on the source again after I've stopped it, the sound also plays at alot lower volume.
I'm going to assume these are both bugs, since it really kills the usefullness of SFX for anything else than simple music. Also, source->setPitch () is used in WheeledVehicle, which further hints that this should work.
I'm going to assume these are both bugs, since it really kills the usefullness of SFX for anything else than simple music. Also, source->setPitch () is used in WheeledVehicle, which further hints that this should work.
#2
OpenAL.
11/19/2008 (11:58 am)
1.7.1, but if you suspect this has changed in 1.8 I'd be happy to check there and port back.OpenAL.
#3
11/19/2008 (11:59 am)
I'll take a peek at this later today and post back.
#4
There are two possibilites here...
1. your OpenAL driver/dll is bad (are you running Vista?).
2. the source you think is playing is not actually the one that is playing.
It is worth moving to 1.8 for various other fixes (better OGG support) and it would make debugging this issue easier, but i can't see anything that would specifically solve this issue.
Also i would suggest running the XAudio provider if you can or if not DirectSound on Windows... in general native APIs are gonna run better on Windows than crossplatform systems like OpenAL and OpenGL.
11/20/2008 (9:21 am)
Ok i can't see why this would be happening for you Stefan...void SFXSource::setPitch( F32 pitch )
{
AssertFatal( pitch > 0.0f, "Got bad pitch!" );
mPitch = pitch;
if ( mVoice )
mVoice->setPitch( mPitch );
}
void SFXALVoice::setPitch( F32 pitch )
{
AL_SANITY_CHECK();
mOpenAL.alSourcef( mSourceName, AL_PITCH, pitch );
}As you can see above setting the pitch from C++ (and script) will redirect the call to the active voice which immediately requests OpenAL to change the pitch.There are two possibilites here...
1. your OpenAL driver/dll is bad (are you running Vista?).
2. the source you think is playing is not actually the one that is playing.
It is worth moving to 1.8 for various other fixes (better OGG support) and it would make debugging this issue easier, but i can't see anything that would specifically solve this issue.
Also i would suggest running the XAudio provider if you can or if not DirectSound on Windows... in general native APIs are gonna run better on Windows than crossplatform systems like OpenAL and OpenGL.
#5
11/20/2008 (9:51 am)
I tested TGEA 1.8 OpenAL in Stronghold on Vista and although it performed weirdly i was still able to succesfully use setPitch( 2 ) on one of the looping environment sounds.
#6
(Honestly, on XAudio: even on stock 1.7.1 builds we got all sorts of issues, button sounds in Stronghold wouldn't play, noisy sound distortion, etc. So pretty much forgot about it after that. Did use the latest SDK at that time, August 2008. Tried on several computers.)
Could be a driver issue for sure, but FMOD works great and so does many games. Not running Vista, either. Guess I'm out of luck.
"Performed weirdly", as in? Thanks for your response!
11/21/2008 (5:43 am)
Edit: Setting the provider to DirectSound makes the sound placement in my speakers improve alot, and now both realtime pitch and volume works! Thanks for the tip. (Honestly, on XAudio: even on stock 1.7.1 builds we got all sorts of issues, button sounds in Stronghold wouldn't play, noisy sound distortion, etc. So pretty much forgot about it after that. Did use the latest SDK at that time, August 2008. Tried on several computers.)
Could be a driver issue for sure, but FMOD works great and so does many games. Not running Vista, either. Guess I'm out of luck.
"Performed weirdly", as in? Thanks for your response!
#7
www.vimeo.com/2306728
Some details:
* I'm setting the transform in advanceTime ().
* I'm playing the sound in onAdd (). The sound is 3D and looping.
* The source sound file is a 44khz 16bit mono sound. Ogg.
11/21/2008 (7:32 am)
Still getting pops and artifacts. It only happens when you change orientation. Here's a video of it:www.vimeo.com/2306728
Some details:
* I'm setting the transform in advanceTime ().
* I'm playing the sound in onAdd (). The sound is 3D and looping.
* The source sound file is a 44khz 16bit mono sound. Ogg.
#8
First be sure what provider is actually enabled... there was a bug in 1.7 at one time where the selection from the options dialog wasn't working correctly. Look in the console log and it will tell you the provider it just enabled. I suspect what you think was DirectSound is actually XAudio or FMOD.
> FMOD works great
FMOD usually is great... because it uses its own software mixer and does not rely on DirectSounds 3D services. This is the same reason that XAudio is so good... it doesn't use "3D" sound hardware... it mixes the sound itself in software.
> "Performed weirdly", as in?
Wildly inconsistent framerate when sounds play... like a 30 second long frame for instance. Not bad performance, but buggy behavior of some sort.
11/21/2008 (10:06 am)
That video and your described experience sounds more like DirectSound to me... in fact i'm certain that it is.First be sure what provider is actually enabled... there was a bug in 1.7 at one time where the selection from the options dialog wasn't working correctly. Look in the console log and it will tell you the provider it just enabled. I suspect what you think was DirectSound is actually XAudio or FMOD.
> FMOD works great
FMOD usually is great... because it uses its own software mixer and does not rely on DirectSounds 3D services. This is the same reason that XAudio is so good... it doesn't use "3D" sound hardware... it mixes the sound itself in software.
> "Performed weirdly", as in?
Wildly inconsistent framerate when sounds play... like a 30 second long frame for instance. Not bad performance, but buggy behavior of some sort.
#9
Yes, the video was indeed with DirectSound. Before switching to DS (when I used OpenAL) I barely couldn't hear anything resembling sound. Just noise and hiss on my left speaker. The video sounds miles better than previous attempts with OpenAL...
Before:
Now:
I'm not comparing to FMOD. Just saying it works, perhaps to rule out any possibility of broken hardware. I don't know much about this stuff so trying to give as much detail as possible because I think SFX is a great initiative.
Well, no hurt in taking a look at XAudio again. :)
11/21/2008 (1:05 pm)
Quote:
That video and your described experience sounds more like DirectSound to me... in fact i'm certain that it is.
Yes, the video was indeed with DirectSound. Before switching to DS (when I used OpenAL) I barely couldn't hear anything resembling sound. Just noise and hiss on my left speaker. The video sounds miles better than previous attempts with OpenAL...
Before:
sfxStartup... Provider: OpenAL Device: SB X-Fi Audio [EC00] Hardware: No Buffers: 16
Now:
sfxStartup... Provider: DirectSound Device: SB X-Fi Audio [EC00] Hardware: No Buffers: 16
I'm not comparing to FMOD. Just saying it works, perhaps to rule out any possibility of broken hardware. I don't know much about this stuff so trying to give as much detail as possible because I think SFX is a great initiative.
Well, no hurt in taking a look at XAudio again. :)
#10
Right now, the pitch is setup to the change of a throttle for the aircraft and should never change unless the throttle is being changed. This may be some kind of effect that those providers are adding, but it doesnt seem likely. In any case, this might be a bug or it might not.
05/14/2009 (11:11 am)
There seems to be some kind of bug with XAudio, FMOD and possibly a few other providers. Using what Stefan setup for pitch, it seems when a vehicle (aircraft in this case) is speeding up/slowing down, the pitch changes. DirectSound seems to be the only provider that doesnt do this. This is a custom vehicle class that this is hooked in to, but it shouldnt matter. This also exists in the T3D beta.Right now, the pitch is setup to the change of a throttle for the aircraft and should never change unless the throttle is being changed. This may be some kind of effect that those providers are adding, but it doesnt seem likely. In any case, this might be a bug or it might not.
#11
05/15/2009 (4:55 am)
I always test with stock vehicles, or else there's really no point in reporting anything. Unfortunatly, my tests between stock and custom classes were consistent.
Associate Tom Spilman
Sickhead Games