Download

Lag with OnAudioFinished event?

I’ve got two parts of a song, I’d like to play the first part once, then infinitely loop the second part. I’ve set up one sound cue for the intro, and one looping sound cue for the rest. Using a blueprint I attach the second to the first using the OnAudioFinished event of the first sound, but there is always a small lag in between when the first sound is done and when the second one starts. I can do somewhat better by playing the first sound, then delaying a set amount of time and playing the second one, but while this can sometimes remove most of the skip, it definitely doesn’t seem reliable. Is there a way to get rid of the skip that occurs with OnAudioFinished?

Unfortunately our system doesn’t have any way to seamlessly stitch two sounds seamlessly together. We rely on the hardware to tell us when the sound is finished which means the buffer is already empty at the point we get notification and so there is inevitably going to be a brief delay while we provide the next sound to it. You could also use the concatenate node directly in the SoundCue but the result will be roughly the same.

Using a delay is going to get you close, but as you said, you’re never going to be able to perfectly line it up because the audio hardware is consuming the buffer at its own pace and so we can’t perfectly line things up.

Hi GitRHero-
You are correct; the OnAudioFinished event does work, but experiences a small (and therefore audible) lag time. The way I usually do this kind of thing is just inside of the SoundCue itself, using a Delay node. The timing of this usually works pretty well, provided you don’t have a hard edit at the end of your intro piece (make sure you have a small fade-out; reverb is usually nice here). If you need absolutely perfect timing, you could start the loop at the same time as the intro, but use an Enveloper node to mix the loop from zero volume up to 1.0 volume at the point you need it. Seamless audio transitions are not currently available, but will be in the future as our audio system matures. Hope this helps.
Best-
Zak

Okay, thanks for the responses. I’ll find some kind of workaround for now!

Hi,

Has there been any progress on the seamless audio transition or change on plans?
Or perhaps is there a way to stream audio in a buffer like unity does (usefull for music related games)?

We want to procedurally build music based on the player’s action.

Thank you

im getting good results in blueprint by getting sound duration and setting when the different samples play based on that

Thanks, this is by far the best method i found for chaining sound effects - sometimes it does result in a gap, although much smaller than using the OnAudioCompleted event.

Has anything changed in 5 years? I’m still struggling to concatenate 2 audio files seamlessly