-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
PitchShift effect quality and performance tweaks for different pitch scale values #57985
Conversation
8372b1f
to
e4c3e6b
Compare
e4c3e6b
to
29b6ed9
Compare
If this gets merge to 3.X I can finally re-export my game to make it sound normal. Thanks for the PR. |
@EviTRea can you confirm that it fixes the issues in your project? Edit: Oh sorry, I forgot we are on master branch here. |
I don't know how to compile the engine and stuff, besides my (very short mini) game has been up for 2 months now, it's nothing urgent for me. |
Thanks! |
Cherry-picked for 3.5. |
Cherry-picked for 3.4.3. |
This broke someone's custom build because they're changing the pitch scale effect parameters several times a second. Why is it necessary to clear the buffers every time there's a change in the pitch scale parameters? It seems to be causing pops. I understand that once the parameters are changed all the buffers are filled with bad data but I'd rather have bad data than no data if it means avoiding a pop. |
Following up @ellenhp's comment, here is a minimal reproduction of pops occurring on |
Sadly it happens on me as well. My game was to lerp the pitch on character transform, and indeed the audio broke post-shift was fixed, but the transforming period is now completely silence. |
Sorry to hear that. I wasn't aware of such use case and how it will be affected. Thanks for the MRP @GlitchedCode |
Here's another MRP using Tween to lerp between pitch scales. I'm working on fixing this right now EffectTest.zip |
@akien-mga I think it has to be reverted as for now I don't have a solution to the issue with dynamic changing/lerping and I don't want it to break projects until I find better solution. Sorry and thanks in advance |
Regressions aside, thank you for the contribution @Listwon! Hopefully the issues can be worked out and if nothing more the type name changes and formatting fixes would be a welcome improvement for readability. I didn't chime in on this PR before it was merged but I don't personally think it's a good idea to conditionally bypass an effect like this does. I would rather allow users to switch the bus that an audio source is playing on when they need to change pitch, then change the bus back when they want the audio to sound nice again. In 3.x that's not possible, but bus changes during playback do work pretty well in 4.x. @EviTRea would it be possible to lerp pitch_scale on the player node instead of using the bus effect? That will mess with playback speed instead of doing a proper pitch shift, but the audio quality is much much better. |
I realized I didn't say why I don't want to conditionally disable effect like this. The main reason is that even if we do get lerping to work with these changes there's a near-guarantee that there will be a phase offset introduced by AudioEffectPitchShift, so when we go to disable the effect, we have to reconcile that phase offset otherwise there will be a loud pop as we transition from pitch shifted audio to passthrough audio. I'm not smart enough to do that, but it might be possible for someone who understands how the algorithm works. It will almost certainly require some amount of transition time though where the audio is gradually aligned to fit back into the original phase though. |
I don't know? |
Unfortunate that this has to be reverted. Hopefully someday it'll be patched up. In the 3.4.3 version, I mitigated the popping by lowering the |
Fixes #20198 and #55090
For pitch_scale close to 1.0f it simply passes untouched audio samples avoiding expensive calculations. For other pitch scales there are some quality improvements like clearing buffers when pitch scale changes or higher precision of buffers for calculations. This should prevent some artifacts.