Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Cross-Platform Development => Topic started by: dizzy on August 26, 2005, 03:24:27 am

Title: The "static" sound problem
Post by: dizzy on August 26, 2005, 03:24:27 am
Hi there

Just wanted to start a separate thread on this topic because hopefully we will have many messages on this one.

I want to help track this problem down.

So, the "static sound" problem under linux I thought initially it was that when for example you used the afterburner each second it had a small  noise or when someone was talking the same thing.

But I think I got it all wrong. Last night I started to play RaiderWars 2.1 and I think I got biten by the problem. For example in the compaign briefings and the mission briefings that I can hear a little clear sound then a VERY STRONG NOISE (hard to support it with headphones) then again a little clear sound then again very strong noise and so on. Is this the "static" problem you were talking of ?

Can you give me any hints what should I try to track it down ?

Notice that the problem didnt showed up in the briefings of the "demo" campaign, they just show up in Raider Wars...
Title: The "static" sound problem
Post by: WMCoolmon on August 26, 2005, 04:02:22 am
I've got the same problem, it makes the briefings essentially unbearable to listen to.
Title: The "static" sound problem
Post by: Col. Fishguts on August 26, 2005, 04:46:34 am
I noticed that bug too, but only sometimes. I can run the same build 2 times, and once the problem is there and next time it's not.

EDIT: Actually, I'm speaking of Windows builds, so it may not be Linux specific.
Title: The "static" sound problem
Post by: dizzy on August 26, 2005, 09:54:41 am
Oh, being not totally Linux specific makes it very interesting I guess :) Also notice that the same problem happened with the Trascendant campaign when the Trascendent talked to you. Back then I thought the noise was part of the talk because it was suposed to sound funky and like a vision. But now after playing RW 2.1 I realised it was actually this bug, heh. Taylor was saying something about 16 bit mono sound that triggers this.

What is the difference of sound format between RW 2.1 and EMW 2.0 campaigns (I'm asking mainly Col. Fishguts as I see he is with the TBP team) ? I have never had any issue with EMW only with RW so and Trascendant so far.
Title: The "static" sound problem
Post by: taylor on August 26, 2005, 10:27:48 am
The static thing only happens with WAVE files that are 16-bit, mono, 11025 Hz.  Converting that same file to 8-bit works, or to 22050 Hz works, or to stereo works.  It's also only in the streaming code since that same file loaded through ds.cpp plays fine.  The only thing that I can figure is that it's some type of buffer size issue.  Actually I know it's a buffer size issue, just not sure why.

When the buffer is computed I divide it by MAX_STREAM_BUFFERS since it will use that many buffers in rotation.  This is a memory saving tactic since each stream could be using quite a few megs of ram otherwise.  In this one case though, not doing it will make the audio play fine.  After looking at that for a little bit last night I figured out that the static will happen when the buffer size equals the samples per sec of the WAVE file, in this case 11025.  Simple increasing the value resulting from the divide by 1 fixes the static.  I'm not totally sure why since being 1 less than the samples per sec works fine too.  This is one that I probably don't want to know the answer to though.

Anyway, it is fixed now and will be going in CVS after I've had a little more time to wake up and get something to eat.  This particular problem was specific to the OpenAL code and not a platform thing so Windows OAL builds would experience it as well.
Title: The "static" sound problem
Post by: WMCoolmon on August 26, 2005, 12:07:48 pm
Wow, that was a fast bugfix. :yes:

I think I may have CVS'd it too. *goes to check*
Title: The "static" sound problem
Post by: dizzy on August 26, 2005, 12:12:15 pm
Taylor, thanks for looking into this. But by the same rationale it whould mean it can be triggered in other cases too if somehow the buffer size matches something with the other formats too. Now I dont know enough information to make a specific guess but possible guesses are:
- buffer size matches 22050 for 22050 samples/mono ?
- buffer size matches 22050 for 11025 samples/stereo or 41050 for 22050 samples/stereo ?
Title: The "static" sound problem
Post by: taylor on August 26, 2005, 12:22:23 pm
I never did test all of the instances, only one, but I'm pretty sure that that one 22050 case didn't have the static.  Either way though the code check assumes that any time the buffer size equals the samples/sec there will be static and changes the buffer size accordingly.  Even if it is this one set of particular values which causes the problem I don't want it ever showing up again with a different format.
Title: The "static" sound problem
Post by: dizzy on August 26, 2005, 01:22:51 pm
Just updated CVS. Your fix looks (or better I should say "sounds") fine so far. Thank you again :)