-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sound buffers? #141
Comments
I think it is specific software/hardware combination, since I stumbled into that error in related to Idtech GoldSource engine on some HL versions and Dreamcast version. But this is not the place for discussing HL, I think. |
Not necessarily, as I've experienced it on a number of different machines with wildly different hardware setups over the years. |
Apparently this is an issue with sound system synchronisation and has apparently been fixed in the Doom 3 BFG Edition. |
Maybe you could try to tweak the "com_asyncSound" cvar to see if there is any differences (need to be done at compilation or startup time): 0: mix sound inline (in the main thread) |
Default was 3. No difference with 0 and 1. No sound at all with 2. I did see mention of a cvar that could "fix" it but apparently it caused cutscene audio to desync. |
Ok, this is maybe related to the specific OpenAL implementation being used also |
BTW, this is the comment that mentioned a variable for audio sync https://steamcommunity.com/app/208200/discussions/0/343786746010619195/#c343787920131961205 I also tried disabling vsync, |
This has always happened to me throughout Win XP and Win 10 and two different motherboards and two Soundblaster cards and happens now with the source port and 120 fps base.dll. I will test more. After playing awhile, it is quite immersion breaking to me since I am sound sensitive, especially when I have modded the weapon firing rates to be faster. However the 120+ fps now makes it worth dealing with!!! |
Is this even a bug? |
I don't think it's an issue in the BFG edition of the game. I don't have the BFG edition so I'm unsure if the difference in the game files or the engine. It only affects the sound of the gun, not the actual shots. |
No need to gaslight us over an obvious bug, DanielGibson. We know better being interested in modding a 15 year old game and this conspiracy is well out in the open to us. The real question is what are the sound coders trying to hide here and why are you helping them? It's been 15 years and the truth must come out! |
Mind your manners, @thoughtartist. This is your first and only warning. |
The fundamental problem is that sound is only updated around 10 times per second, by the async timer in the async thread: https://github.com/dhewm/dhewm3/blob/master/neo/sound/snd_system.cpp#L680-L688 ( unsigned int dwCurrentBlock = (unsigned int)( inTime * 44.1f / MIXBUFFER_SAMPLES );
// inTime is current Time in milliseconds since the game was started
// MIXBUFFER_SAMPLES = 4096 (it's a constant defined somewhere)
// 44.1f / MIXBUFFER_SAMPLES == 0.010766602
// ...
if ( dwCurrentBlock < nextWriteBlock ) {
return 0; // !!!
}
// ...
currentSoundWorld->MixLoop( sampleTime, numSpeakers, finalMixBuffer );
// ...
nextWriteBlock = dwCurrentBlock + 1; so only if So imagine the gamecode tries to play a sound right after
(empty lines added to make those blocks more visible) As a side-note (mostly to myself) that async thread thing is pretty broken, it tries to only get the Unfortunately, I'm not sure how to fix this issue, I'd have to find out if this "only update every 4096 samples" stuff is really needed and if it is, work around it somehow, and otherwise call |
For some reason sounds were only updated/started about every 100ms, which could lead to delays of up to around 100ms after a sound gets started (with idSoundEmitterLocal::StartSound()) until OpenAL is finally told to play the sound. Also, the actual delay drifted over time between 1ms and 100ms, as the sound ticks weren't a fixed multiple of the (16ms) gameticks - and the sound updates didn't even happen at the regular 92-94ms intervals they should because they run in the async thread which only updates every 16ms... Because of this, the machine gun and other rapid firing weapons sounded like they shot in bursts or left out shots occasionally, even though they don't. Anyway, now sound is updated every 16ms in the async thread so delays are <= 16ms and hopefully less noticeable. You can still get the old behavior with com_asyncSound 2 if you want.
I might have a fix (which assumes that the calls to software mixing functions were superfluous) - now sound is updated 60 times per second instead of 10 times per second which keeps delays below 16ms. Windows binaries: dhewm3-oal-timing-fix.zip You can set Thanks in advance for testing! |
You got it 🎉. That is so much better. It's even more obvious with the plasma gun. Thank you very much. I even tested with a little mod that increased the fire-rate of the machinegun and plasmagun and that was really good too. |
Great, I'm glad it works! |
It happened a lot more since 504b572 Update sounds at ~60Hz instead of ~10Hz, fixes #141 (because then MixLoop() is more likely to be called in the narrow timeframe this can happen during level load) but could happen before. So far I only observed it when starting a new game in Classic Doom 3. See comment in the change and #461 for more information.
For some reason sounds were only updated/started about every 100ms, which could lead to delays of up to around 100ms after a sound gets started (with idSoundEmitterLocal::StartSound()) until OpenAL is finally told to play the sound. Also, the actual delay drifted over time between 1ms and 100ms, as the sound ticks weren't a fixed multiple of the (16ms) gameticks - and the sound updates didn't even happen at the regular 92-94ms intervals they should because they run in the async thread which only updates every 16ms... Because of this, the machine gun and other rapid firing weapons sounded like they shot in bursts or left out shots occasionally, even though they don't. Anyway, now sound is updated every 16ms in the async thread so delays are <= 16ms and hopefully less noticeable. You can still get the old behavior with com_asyncSound 2 if you want.
It happened a lot more since 504b572 Update sounds at ~60Hz instead of ~10Hz, fixes dhewm#141 (because then MixLoop() is more likely to be called in the narrow timeframe this can happen during level load) but could happen before. So far I only observed it when starting a new game in Classic Doom 3. See comment in the change and dhewm#461 for more information.
One thing has always bothered me about id Tech 4 games - Doom 3, Quake 4, and Prey specifically; Wolfenstein doesn't seem to have this problem - and that's the way rapid-fire weapons sound. Under sustained fire, the machine gun, chaingun, and plasma rifle all sound as if they're "missing" their firing sounds every few shots. Other things suffer from this, too, like footstep noises. I suspect it's a problem with the sound buffer size and response times, but I can't find any console variables to set to fix it.
I'd asked about this on the Doomworld forums, but was directed to ask here instead; is there some oddity to the id Tech 4 sound engine at work here? I can confirm that it happens in both vanilla Doom 3 (Windows 1.3.1) and in a release build of dhewm3 from last week.
The text was updated successfully, but these errors were encountered: