-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Remove range check in SoundEffectInstance.Pitch.set #7515
base: develop
Are you sure you want to change the base?
Conversation
This seems fairly safe to me. Even if porting an old XNA game depended on it being range limited like it was before they surely didn't let it overflow and capture exceptions during gameplay. The only thing i would suggest is to decide on what the rules are with range of the pitch moving forward. Do we guarantee at least 2 octaves on all platforms? Do we need more than 2 octaves? |
While removing the limit here makes sense, we have to be careful as to which value we pass to the implementation. As of now, implementions are assuming this limit. Uncapping it might expose them to crashes. For example, not all OpenAL implentations are equal, Android might crash below -1 and above 1, while on PC any value should be safe (OpenAL and XAudio should be able to support near infinite shifts on PC). This PR looks safe in regard to DesktopGL and WindowsDX but we should safe check on mobile and consoles (I'll try to safe check the console side of things). |
I looked into every platforms expected range and error handling:
So in regard to this PR, we should add a clamp on OpenAL We have nothing to do for WindowsDX since it will clamp the values to +/- 10 octaves. For consoles, we definitely need to add a clamp (I'll look into it if this PR moves forward). |
@notexplosive if you address what @mrhelmut mentioned we can move forward with this. Or i can close it. |
76b5e8b
to
01412d4
Compare
If I understand the feedback correctly, I think I did what @mrhelmut requested. (sorry for the force-push, I screwed up line endings and had to un-screw up the line endings). Thank you for your patience! Sorry for leaving this PR for so long |
Thank you for updating, and no worries, we're trying to catch up with PRs. It seems that Thanks! |
Hi! First time contributing, please be gentle!
I ran into a problem where I couldn't set the Pitch of a sound effect instance below
-1.0f
or above1.0f
without throwing an exception. This is on purpose, according to the docs, but 1 octave up/down is really limiting!I saw discussion of it in this ancient PR and it seems there's no technical reason for this limitation. The best justification I can imagine is "That's how XNA did it." (I have no evidence of this, total guess).
My proposal is pretty straightforward: we just get rid of the range check and let AL handle it. I'm not changing any of the math for backwards compatibility, plus 1.0 == 1 octave is actually pretty elegant, I just wish I could have 2.0, or 10.0!
I'd be happy to add/modify a test for this, but I wasn't able to run the unit tests because I can't get Monogame to build on my machine (attempting to build via Visual Studio 2019 using
MonoGame.Framework.DesktopGL.sln
and/orMonoGame.Tools.Windows.sln
).