Multiple instances of an SFXSource producing volume problems
by Dusty Monk · in Torque Game Engine Advanced · 07/21/2009 (2:07 pm) · 2 replies
Working with some vehicle sounds. I've set up a looping engine sound that plays correctly. I'm modulating the pitch in ::updateEngineSound by the vehicle's velocity, and that is working great. The sound file in question is just a 44Mhz mono sound, and I'm using the DefaultAudio3DLooping profile.
However, when I create multiple vehicles (all using the same sound file), only one vehicle will play the sound at the correct volume. The other vehicles all have the sound sharply muted (though it is playing). I've stepped through the code and the modulated volume value getting fed to the source is the same for all instances of the source.
Has anyone seen or experienced anything like this? I'm using TGEA 1.7.1, under Vista, and the sound provider is DirectSound, using the Primary Audio Driver.
I'm in the process of downloading FMod to see if it has the same problem using that as a provider, but honestly I'd prefer to stick with stock DirectSound if possible.
Dusty
Windstorm Studios
However, when I create multiple vehicles (all using the same sound file), only one vehicle will play the sound at the correct volume. The other vehicles all have the sound sharply muted (though it is playing). I've stepped through the code and the modulated volume value getting fed to the source is the same for all instances of the source.
Has anyone seen or experienced anything like this? I'm using TGEA 1.7.1, under Vista, and the sound provider is DirectSound, using the Primary Audio Driver.
I'm in the process of downloading FMod to see if it has the same problem using that as a provider, but honestly I'd prefer to stick with stock DirectSound if possible.
Dusty
Windstorm Studios
About the author
Dusty Monk is founder and president of Windstorm Studios, an independant game studio. Formerly a sr. programmer at Ensemble Studios, Dusty has worked on AAA titles such as Age of Empires II & III, and Halo Wars.
#2
Sorry for tuning in so very late, but I guess what you're seeing is the effect of buffer duplication with DirectSound. Duplicated buffers inherit the properties from their source buffers and if the pitch (frequency) has already been altered on the buffer, it'll end up affecting mFrequency in the SFXDSVoice.
I'm currently in the process of fixing this for Torque 3D.
To remedy the pitch problem, simply make the SFXDSVoice constructor not read out mFrequency from the buffer but rather store the original source frequency directly on SFXDSBuffer.
08/01/2009 (7:47 pm)
Sorry for tuning in so very late, but I guess what you're seeing is the effect of buffer duplication with DirectSound. Duplicated buffers inherit the properties from their source buffers and if the pitch (frequency) has already been altered on the buffer, it'll end up affecting mFrequency in the SFXDSVoice.
I'm currently in the process of fixing this for Torque 3D.
To remedy the pitch problem, simply make the SFXDSVoice constructor not read out mFrequency from the buffer but rather store the original source frequency directly on SFXDSBuffer.
Torque Owner Dusty Monk
Windstorm Studios
So this isn't a volume problem after all, but is a pitch problem. I've tracked it down to an issue with creating multiple voices using the same buffer. In SFXDSVoice::create, when we create a new instance of an SFXDSVoice, in the first case, the frequency given to the voice is 44100, which is the frequency of the source sound file.
The second instantiation of an SFXDSVoice, using the same buffer, produces a frequency of 8820.
When I make the call to setPitch, the pitch is modulated by the mFrequency of the SFXDSVoice. Sooo.. passing in a pitch of 0.2, against 8820 produces a *much* difference pitch than passing in 0.2 against 44100.
No idea why the second (and subsequent) calls to createVoice result in a voice with a different frequency than the orginal one.
Dusty