Good afternoon, I have the following problem. I want to add BGM_BattleTheme, which consists of 2 parts: Opening and Main Part.
Opening should be played once per battle and Main Part is looped.
I did through Audio Component, and when Opening finished playing, for some reason Event On Audio Finished, which should start Main Part, is not running. What could be the problem?
Wanted to share some ideas worth trying, as well as some recommendations when dealing with sample-accurate audio pieces (which you will need in order to seamlessly concatenate/stitch together audio clips).
My first recommendation would be to create this system inside a MetaSounds object, as the new Quartz audio engine offers sample-accurate audio processing. Running this process else will likely run into delays/latency between the game thread and the audio render threads, resulting in potential gaps between concatenated clips.
Perhaps consider creating a MetaSounds object with two inputs; one for your BGM’s “Intro” and one for the BGM’s “Main Loop”. Then, connect the “Intro” wave player’ OnFinished event to the “Main Loop” wave player’s Play input:
Yes, that’s the way to go, only one thing about it - if you want a seamless stitch you should trigger your main loop from the On Nearly Finished pin.
Also, if it wasn’t clear, on the blueprint side you’ll only need to Spawn Sound 2D with that metasound, and pass in the two wave assets to play, with Audio Parameter Controller Interface as target.
Hmm, if you’re on UE4 and onAudioFinished is not firing, perhaps double check there aren’t any auto-destroy booleans enable/active when creating/triggering the sound (this may prevent the onAudioFinished event). Would test with a printString just in case.
Otherwise, can try binding a custom event to the UAudioComponent’s OnAudioFinished delegate:
If all else fails, I’d consider preloading the Intro and Body parts of your BGM, then triggering both at the same time, but adding a Delay node before the Body loop. The delay’s float duration would be equal to the duration of the Intro. You may need to tweak the float slightly to provide a seamless overlap. Adding a short reverb tail to the intro would also help mask any minuscule gaps.
Found the following post that may be helpful. It involves double checking and potentially using a different audio engine in your UE4 project, as it may resolve issues with the audio component delegates: