Noticeable gap in sequence node on sound cue and OnAudioFinished

I am trying to make a seamless looping music cue, that has an intro clip and a loop clip. When I use the Sequence node in a Sound Cue to make them play back to back, there is a noticeable gap between them.

The same gap occurs if I make a Blueprint which simulates the Sequence node, by switching an AudioComponent’s Sound Base to the looped clip on the event OnAudioFinished.

How do I avoid this gap? I have tested that the clips should play seamlessly by appending the loop clip to the start clip in Audacity; there is no gap between the two clips as exported from my DAW.

I’m assuming your “gap” is on the order of a frame or two – as in, it manifests as a “clip” sound as the sound is discontinuous.

The issue is that the sequence and OnAudioFinished features are not intended for audio processing and, in terms of timing, will be on the order a game frame and not anywhere near the accuracy for audio processing. The intention of those features is more for gameplay or to play different audio files in sequence. Your audacity example is concatenating sample-accurately. When you enable “looping” on a wave player node, that’s also looping sample-accurately.

I’d recommend for your case to not to depend on the OnAudioFinished() or sequencer node to sequence your sound.

Instead, maybe something like this could work:

  1. make your initial sound asset have a slight fadeout at the end,
  2. then I’d use the sound’s duration and a BP delay node equal to the duration minus some smallish time (roughly equal to your first sound’s fadeout),
  3. then play your continuously looping sound with a manually created audio component, then call “FadeIn” on the audio component.

I believe you can also do the above in a sound cue using a delay node and an enveloper node with a volume curve that fades the sound in.

Unfortunately the timing with the Delay node is also not consistent. In the editor preview, it is exactly timed, but in PIE or standalone it does not seamlessly start the looping part.

Yes, nothing that uses timing based off the main thread (or any thread not on the audio mix thread) is not going to be sample accurate. The looping flag/node is sample accurate because it sets a flag that is used in the device mixing layer that signals that the audio file continue decoding at the beginning of the file when it reaches the end. Because this happens in the audio mixer thread, it sample accurate. One of the design goals of the new audio engine I am hoping to return to working on will allow for more sample accurate timing as it’ll use our own multi-platform mixer.