-
Notifications
You must be signed in to change notification settings - Fork 933
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 improvements #1450
Sound improvements #1450
Conversation
|
||
#define MAKE_PTRID(id) ((void*)(uintptr_t)id) | ||
#define GET_PTRID(ptr) ((ALuint)(uintptr_t)ptr) | ||
|
||
namespace | ||
{ | ||
|
||
// The game uses 64 units per yard, or approximately 69.99125109 units per meter. | ||
// Should this be defined publically somewhere? | ||
constexpr float UnitsPerMeter = 69.99125109f; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like Visual Studio 2013 does not support constexpr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to keep support for MSVC 2013? Our win builds are the only official ones...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, the 2013 CTP. I've used that for personal projects before, not the nicest of things to either install or use.
I'd rather see us drop 2013 support than tell people to install something that's literally named "Preview" to be able to compile.
Though dropping 2013 also probably means dropping Windows XP support, since 2015 and forward use the UCRT runtime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not be supporting Windows XP either. In linux land, if the distro is EoL, then we don't support it. Same for Microsoft, if they EoL WinXP (and hopefully Vista), then we don't officially support it either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I'm open to the idea of upgrading, is it worth it purely for 'constexpr'? Is there anything else we would gain? If we do want to go ahead, best take it to the forums to ask who's using 2013.
We should not be supporting Windows XP either. In linux land, if the distro is EoL, then we don't support it. Same for Microsoft, if they EoL WinXP (and hopefully Vista), then we don't officially support it either.
Generally agreed, but there's two types of support - we can allow things to run, but that doesn't mean we need to be accountable if someone can't get it working or reports a bug. Something that isn't officially supported can still happen to work, for a while anyway.
Sure, there's not much usecase for XP but if you happened to have a really old computer that is only used offline, there's no harm in not upgrading it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, but if the machine is used offline then you're not likely to be running OpenMW now then are you? ;)
If 'constexpr' is the straw that broke the camel's back for WindowsXP support, then so be it. We shouldn't be held behind for that.
BTW: We still support mingw right? So we still have WindowsXP compatible builds anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This instance of using constexpr
is far from necessary, so if it's that much of an issue I can just use plain const
. But it would still be a good idea to discuss it on the forums for when constant expressions come up elsewhere in the code base.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact this exact issue was already discussed in this PR a few weeks ago but no decision was made there. Personally I don't think XP support should be dropped just for constexpr
but there's always the option of using
if (MSVC_VERSION LESS 1900) add_definitions(-Dconstexpr)
;)
@@ -1021,7 +1021,7 @@ namespace MWSound | |||
|
|||
if(sound->getDistanceCull()) | |||
{ | |||
if((mListenerPos - objpos).length2() > 2000*2000) | |||
if((mListenerPos - objpos).length2() > sfx->mMaxDist*sfx->mMaxDist) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this is fine? IIRC the original game uses 2000, regardless of what's in the sound record. See bug 244 about loud ghostgate sounds, and the comment next to the definition of Play_RemoveAtDistance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was testing things around Seyda Neen and saw that sounds that were being culled had a max distance of 2000, so it seemed having the hardcoded cull distance at 2000 was unnecessary and potentially problematic if modded sounds wanted to be audible farther away.
In regards to Ghostgate, I checked and it doesn't seem to be obnoxiously loud like this. Although that may be due to OpenAL Soft now having a volume limiter (it reduces the overall gain when the output samples would clip). The video in bug 244 showcases what the sound is like in vanilla's software audio mode, which can have extra limitations due to needing to run on weaker CPUs. Unfortunately, there doesn't seem to be any examples of it in hardware/DirectSound3D mode for comparison.
I'll set the vanilla game up to run in Wine with emulated hardware audio to see how it behaves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now I've reverted it back to a hardcoded 2000, because I ran into another place where sounds became unnecessarily loud ('dagoth ur, outer facility'). However, I ran into a separate issue with sound sources of projectiles sometimes getting "lost" (intermittently the sound sources for the projectiles don't stop when they're supposed to, but are no longer being tracked either). I need to figure out what's going on with that before I update the PR.
@@ -622,6 +622,7 @@ void OpenAL_Output::init(const std::string &devname) | |||
} | |||
|
|||
ALC.EXT_EFX = !!alcIsExtensionPresent(mDevice, "ALC_EXT_EFX"); | |||
AL.SOFT_source_spatialize = !!alIsExtensionPresent("AL_SOFT_source_spatialize"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The !! stopped me for a second... that's a funny way to write static_cast<bool>
Anyway great change. This fixes the overly-loud riekling scream sounds, doesn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The !!
is something I picked up in earlier days using C (which didn't have an explicit bool type readily available). And it just seems more lean and elegant to me than static_cast<bool>(...)
. If it's an issue, I can actually change the flags to bools for the cast to happen automatically (I just wasn't sure if the size specifier worked properly with bools, but they do).
It does fix the riekling sounds, yes. cr/riek/moan.wav
is stereo for some reason (other sounds may be too), and this will properly handle it.
To avoid being able to accidentally cast a Stream* to a Sound*, or vice-versa.
Rather than checking every frame you're near the water, only check when the current cell changed (the sfx will only change when moving between interior and exterior). It also doesn't need to look through all playing sounds, as it's a local one not attached to a Ptr.
This replaces the pitch-shift effect when available.
Standard OpenAL does not spatialize non-mono sounds, although the game has some stereo sounds meant to play in 3D. The desired behavior can be achieved with the AL_SOFT_source_spatialize extension.
Also shorten them by putting them in the MWSound namespace
Updated. Removed There is one thing to note about this changeset, namely that returned In theory, the weather manager would just need to tell the sound manager what the current ambient sound is and its volume, and the sound manager can manage the Projectiles are a different story. Despite being things in the world they don't seem to have an associated |
And msvc 2013 failed again with: C:/projects/openmw/apps/openmw/mwsound/openal_output.cpp(398): error C2536: 'MWSound::OpenAL_SoundStream::MWSound::OpenAL_SoundStream::mBuffers' : cannot specify explicit initializer for arrays (C:\projects\openmw\MSVC2013_32\apps\openmw\ub_mwsound.cpp) [C:\projects\openmw\MSVC2013_32\apps\openmw\openmw.vcxpr |
I'd suggest just replacing the |
I think this PR should be fine as-is, but it would be nice to have another independent person test it, due to the scope of the changes. If anyone's tested, please tell us :)
The current SoundManager design feels a little weird to me. On the one hand it deals with world objects and their environment, on the other hand it also deals with actually playing/updating and buffers for all those sounds, talk to the OpenAL backend and other implementation details. Maybe it should do only do the backend and leave the managing part to World, Scene or another class, i.e. the sound subsystem no longer depends on World or another subsystem. In the event we wanted to refactor in that direction in the future, it might be beneficial to still support Sound objects being handled by the caller.
They're not handled as world objects because the original game doesn't handle them as such, and if they were then they'd have incorrect collision, you could grab a projectile to your inventory while it's in air, etc. |
I have played a bit and no obvious issues showed up. The new water filters work fine as far as I can tell. Didn't notice any change in the riekling moan loudness, though. |
It makes sense to me that the sound manager handles the sound lifetimes and their associations with world objects. It's the glue between the sound renderer and world state. That way we only have one place to worry about sound duplication (the same object playing the same sound multiple times), and making sure sounds are cleaned up when their associated Granted, I'm hardly an expert on sound system design. Most of the things I'm planning for I've not attempted to do in "production code" before, but this is how I would initially plan for them. Though I wouldn't necessarily discount alternative design ideas as long as it doesn't over-complicate things.
I don't mean to have an actual arrow object be the Ptr. I mean a live projectile would be its own class (where models and sounds and such are specified) and have a Ptr to reference live instances of it.
The riekling fix needs the |
Okay, that explains it. The latest Debian provides is 1.17 currently. |
I remember considering this idea back then, for some reason we discarded it but I don't remember why. |
@MiroslavR 1.18 is ready to ship on Debian, waiting for an uploader... |
shared_ptr
with related micro-allocations.ALC_EXT_EFX
extension.AL_SOFT_source_spatialize
extension.The website is currently down, so I'm unfortunately not able to provide links to related issues.