gtreshchev / RuntimeAudioImporter

Runtime Audio Importer plugin for Unreal Engine. Importing audio of various formats at runtime.
MIT License
308 stars 67 forks source link

Toggling mute without hitching in UE5.3 #63

Open mxbi opened 5 months ago

mxbi commented 5 months ago

Hi! Thank you for such an awesome plugin.

I want to implement push-to-talk functionality and so want to frequently mute and unmute a recording.
I initially used Start Capture and Stop Capture, but that caused hitching as described in https://github.com/gtreshchev/RuntimeSpeechRecognizer/wiki/6.-Minimizing-freezes#capturable-sound-wave.

Following that, I tried using Toggle Mute to improve performance, but the hitching persists. Looking at the source, it looks like for UE5.3, this is aliased back to Start/Stop Capture:

https://github.com/gtreshchev/RuntimeAudioImporter/blob/main/Source/RuntimeAudioImporter/Private/Sound/CapturableSoundWave.cpp#L172-L184

Is there any recommended way to do this for UE5.3+?

gtreshchev commented 5 months ago

Hi, thanks for the feedback :)

The ToggleMute function used to work in earlier engine versions, but starting from version 5.3, it no longer functions correctly and leads to crashes, especially on Windows (I assume this issue may occur on other platforms as well). To avoid crashes and make sure it always works correctly, I modified it to essentially be implemented as the StartCapture<->EndCapture starting from version 5.3.

For now, I'm not sure if it's possible to solve this in-place, so unfortunately it's on hold for now.

q2a3z commented 2 hours ago

@gtreshchev Sorry my amatuer response before. I rellay appriceate your project, it easy to use and reliablity. Thank you so much. But the ToggleMute in 5.3 is rellay annoying me. I finally found the bug, and contrubite the code to EpicTeam. If you had be the member of EpicGame , you can see it. https://github.com/EpicGames/UnrealEngine/pull/12092 Briefly, they forgot to set the CaptureThread to nullptr when the thread stop. When you call StartStream again will cause the check been Error.

So this issus only effect on Windows.

70

If you have time you can check by yourself. Thanks your wonderful pluing again.