Commit graph

25 commits

Author SHA1 Message Date
Daniel Gibson
4567f26539 Fix scaling down volume of all sounds, #179 #326
Commit 3c01757d27 introduced scaling down all sounds to prevent too
many loud-ish sounds from making OpenAL scale the overall volume down.

The problem is that before this change, many sounds had a volume > 1.0,
but vastly different: e.g. player_machinegun_fire was 5.039685 (14dB)
and player_chaingun_fire was 1.414214 (3dB).
But in the end, all volumes were clamped to 1.0 before setting AL_GAIN
(because AL_GAIN only supports values between 0 and 1 by default), so
the machinegun and chaingun had the same volume after all.

When scaling those down to 1/3 of the original volume, some sounds that
used to have a volume of >= 1.0 (=> AL_GAIN set to 1.0) had a volume
lower than 1.0, so they suddenly the chaingun sounded quiter than
the machinegun. While theoretically this is more correct than before
(after all, the sound shader of player_chaingun_fire set a much lower
 volume than that of player_machinegun_fire), it doesn't sound like it
used to (even with the old software sound backend!).

Clamping to 1.0 *before* scaling to 1/3 should restore the old behavior
(of all sounds with volume > 1.0 before clamping using the same AL_GAIN)
while still avoiding the issue of having OpenAL (Soft) scale down the
overall volume when shooting a metal wall with the shotgun.

Unsurprisingly the same problem (inconsistent weapon volumes due to
incorrect sound shaders setting the volume way to high and thus relying
on being clamped to 1.0) that occurred with my volume *= 0.333 hack
also happens when reducing the global volume.
So apply that global volume scale *after* clamping to 1.0

see https://github.com/bibendovsky/eaxefx/pull/28#issuecomment-1367436162
2022-12-31 02:00:30 +01:00
Daniel Gibson
aedf0b4b21 Fix endless loop when decoding OGGs, #390
In idSampleDecoderLocal::DecodeOGG() `totalSamples` was 1 and
`reqSamples` was 0, which caused an endless loop.. this was caused by
idSoundWorldLocal::ReadFromSaveGame() setting
`chan->openalStreamingOffset` to an odd number, I think due to
`currentSoundTime` being an odd number.
To fix that, I round up `chan->openalStreamingOffset` to a (very) even
number, and to be double-sure I also added a check in DecodeOgg() to
make sure it exits the loop if `reqSamples` is 0.
2021-06-22 02:59:59 +02:00
Daniel Gibson
5f346c7355 Add s_alReverbGain CVar to reduce intensity of reverb effects, fix #365
It can be set to a value between 0.0 and 1.0.
1.0 sounds like it did before introducing this cvar; as many people
found the the effect way to strong, I made 0.5 the default value
2021-04-27 20:08:59 +02:00
Daniel Gibson
954ff88759 Properly pause sounds when entering menu, fixes #330
Otherwise especially looped sounds continue playing while the menu
is open, especially noticeable when opening the menu while firing
the chaingun (the whirring sound continues playing).
2021-04-27 20:08:59 +02:00
Daniel Gibson
13ac657ebf Make deleting listenerSlot in idSoundWorldLocal::Shutdown() work
the problem was that the sources were still associated to it, because
they get deleted after the listenerSlot: the sources get freed in
idSoundSystemLocal::Shutdown() which is called by
idCommonLocal::ShutdownGame() in line 3217,
while the listenerSlot is deleted via idSessionLocal::Shutdown()
-> delete sw/rw -> idSoundWorldLocal::~idSoundWorldLocal()
-> idSoundWorldLocal::Shutdown() - and idSessionLocal::Shutdown() is
called in idCommonLocal::ShutdownGame() line 3211, before the other.

I'm not gonna mess with the order of deleting things in ShutdownGame(),
but it's sufficient to unassociate the effect slot from the source
when destroying the emitters in idSoundWorldLocal::Shutdown(),
by adding a call for that to idSoundChannel::ALStop() - and destroying
the emitters before deleting listenerSlot.

Before this fix, with ALSOFT_LOGLEVEL=3 you got the following warning:
  (WW) Error generated on context 0x5578fce2a280, code 0xa004,
  "Deleting in-use effect slot 1"
Thanks for openal-soft's KittyCat for pointing this out!
2021-04-12 19:17:12 +02:00
Turo Lamminen
cbd59321a8 Fix uninitialized members in idSoundWorldLocal 2021-04-12 19:13:39 +02:00
Boris I. Bendovsky
fa51007a6f Calculate EFX occlusion as in Creative's EFX-Util 2021-01-15 17:57:39 +01:00
Daniel Gibson
504b572ae4 Update sounds at ~60Hz instead of ~10Hz, fixes #141
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.
2020-07-12 04:43:53 +02:00
Daniel Gibson
5919717d05 Fix looping .wav sounds with leadin, fixes #291
If the main sound in a shader was a .wav
(soundShader->entries[0]->hardwareBuffer == true), only that sound was
played (and looped with AL_LOOPING), even if a leadin was configured.
If the main sound was an .ogg it worked.
Not it should always work.
2020-06-01 22:13:41 +02:00
Daniel Gibson
3c01757d27 Scale down volume of all sounds, fixes #179
so even with many loud sounds the overall volume isn't reduced by
OpenAL - apparently OpenAL scales down all sounds temporarily if the
mixed result would be too loud or sth like that.
Just sending all sounds to OpenAL with a lower volume prevents that from
happening (just set your system speaker volume a bit higher if needed).
This problem was especially noticable when shooting at metal walls with
the shotgun (each pellet produces an impact sound so it gets kinda loud)
2018-02-12 03:31:34 +01:00
dhewg
35bd70ea46 Improve environment suit sfx
Set AL_LOWPASS_GAIN like EAX did under the hood.
Set the same filter via AL_DIRECT_FILTER on sources.

This should bring the overall sfx closer to EAX:
<kaan_> it sounds awesome

All infos provided by KittyCat from #openal.
2012-01-11 19:29:35 +01:00
dhewg
16958d070b Fix [record|play|time]Demo for x86_64
These are still fragile due to restored stale pointers (!).
But at least the vanilla demos can now be used to check for
performance regressions.
2012-01-10 22:54:01 +01:00
dhewg
d8acc43aca Port the D3XP environment suit effect to EFX
Use a AL_LOWPASS_GAINHF filter to muffle sfx.
2012-01-10 17:45:37 +01:00
dhewg
bdbee3543c Cleanup EFX code
Add error checking.
Add debug printf()s, enable via EFX_VERBOSE.
2012-01-10 17:45:37 +01:00
dhewg
ece2adbdcd Port EAX to EFX
First attempt at porting the EAX reverb code to EFX.
This only works when the ALC_EXT_EFX extension is supported by
the OpenAL vendor (which is not the case for the OSX supplied
framework, use OpenAL soft instead).

The current stable version of OpenAL Soft (v1.13 as of this
writing) can barely handle this additional workload, current
master is highly recommended when using this feature.
2012-01-08 22:04:56 +01:00
dhewg
736ec20d4d Untangle the epic precompiled.h mess
Don't include the lazy precompiled.h everywhere, only what's
required for the compilation unit.
platform.h needs to be included instead to provide all essential
defines and types.
All includes use the relative path to the neo or the game
specific root.
Move all idlib related includes from idlib/Lib.h to precompiled.h.
precompiled.h still exists for the MFC stuff in tools/.
Add some missing header guards.
2011-12-19 23:21:47 +01:00
dhewg
18f9793732 Get rid of the intenal useOpenAL
Useless now, there is only OpenAL.
2011-12-14 18:24:06 +01:00
dhewg
4e26e1ac6f Don't use idAudioHardware to get the speaker count
Use the CVar s_numberOfSpeakers for that, its already stored
in there.
Add the same (!= 2 && !=6) check as in the audio backends since
the mixer is limited to these 2 values.
2011-12-14 18:24:05 +01:00
dhewg
690967c276 Split EAX usage off OpenAL
New define ID_OPENAL_EAX to enable the deprecated EAX on top
of OpenAL.
OpenAL Soft can now be used.
2011-12-11 16:56:11 +01:00
dhewg
962c0e6032 Fix sound channel saving/restoring for x86_64
Let's not store pointers as int to file. The code already allocs
channels on invalid pointers - well, afer fixing it ;)
2011-12-10 15:36:13 +01:00
dhewg
6b1e27b157 Trivial pointer cast fixes for x86_64 2011-12-10 15:36:09 +01:00
dhewg
120d560722 Fix -Wconversion-null warnings
converting to non-pointer type ‘int’ from NULL
2011-12-10 15:36:00 +01:00
dhewg
79ad905e05 Fix all whitespace errors
Excluding 3rd party files.
2011-12-10 15:35:54 +01:00
dhewg
ff493f6847 Fix quoting in GPL headers 2011-12-10 15:34:48 +01:00
Timothee 'TTimo' Besset
fb1609f554 hello world 2011-11-22 15:28:15 -06:00