TGEA 1.7 Bug - SFX FMod stereo sounds playing too fast
by David Wyand · in Torque Game Engine Advanced · 04/24/2008 (9:01 pm) · 2 replies
Greetings!
While making use of the SFX FMod module I noticed that my stereo audio samples would play twice as fast as they should. These were being used as 2D sounds, and after checking them in Audacity they appeared to be fine. My three test samples were all 16-bit and 44.1kHz, and it didn't matter if I saved them as WAV or OGG files.
After some hunting, I believe that the number of bits per sample was being calculated incorrectly for FMod. It appears that FMod wants to know the sample rate per channel rather than for the sample as a whole (which it appears is what the more general method is set up to calculate). The short of it was we were telling FMod that we have a 32-bit sample (2 16-bit channels) when we should have been telling it we have 16-bits per channel.
The change that seems to work is to just divide our total sample rate by the number of channels. Line 42 of sfxFMODBuffer.cpp goes from this:
to this:
My 2D stereo sounds now play as they should, and none of the mono sounds (ie: footfalls) have been affected.
- FMod Dave, a.k.a. LightWave Dave :o)
While making use of the SFX FMod module I noticed that my stereo audio samples would play twice as fast as they should. These were being used as 2D sounds, and after checking them in Audacity they appeared to be fine. My three test samples were all 16-bit and 44.1kHz, and it didn't matter if I saved them as WAV or OGG files.
After some hunting, I believe that the number of bits per sample was being calculated incorrectly for FMod. It appears that FMod wants to know the sample rate per channel rather than for the sample as a whole (which it appears is what the more general method is set up to calculate). The short of it was we were telling FMod that we have a 32-bit sample (2 16-bit channels) when we should have been telling it we have 16-bits per channel.
The change that seems to work is to just divide our total sample rate by the number of channels. Line 42 of sfxFMODBuffer.cpp goes from this:
U32 bitsPerSample = res->getSampleBits();
to this:
U32 bitsPerSample = res->getSampleBits() / channels; // DAW: Added the channels division
My 2D stereo sounds now play as they should, and none of the mono sounds (ie: footfalls) have been affected.
- FMod Dave, a.k.a. LightWave Dave :o)
About the author
A long time Associate of the GarageGames' community and author of the Torque 3D Game Development Cookbook. Buy it today from Packt Publishing!
Associate Matt Fairfax
PopCap