Play Quantized is ignoring Start Time

Hi there! I’m summoning the wisdom of @dan.reynolds - hope you can help.

I’m working on a rhythm-based puzzle game with interactive music. Everything was working okay until I recently overhauled the music and rhythm system. Previously it was messy and unperformant, but functional.

The new version uses Quartz in UE4.27. I have a BP class called BeatMgr that fires off events on the beat that drive the gameplay - that part is all fine. The interactive music in this case is done by crossfading looping 32s stems. When BeatMgr is notified to add a new stem to the mix, it works out what the start time of the wave should be if it starts on the next beat and then uses PlayQuantized with the Quartz clock to start it on the right sample when the time comes. (BeatMgr then uses Cue params to do crossfading and stuff, that part’s all fine.) Basically, I’m trying to add a stem by starting the wave in sync with the other stems that are already playing.

The problem is, no matter what I plug into the “In Start Time” input parameter of PlayQuantized, it always starts at the beginning of the wave. Everything about this system works fine.

I’ve tried all the old tricks like using “force inline” on the wave asset so it’s not streaming (ideally I need it primed) and setting the AudioComponent to not auto-activate. I’ve tried not looping. I’ve tried tweaking just about everything on the wave, cue, sound class and component that I’d think would make a difference. Nothing will make it start anywhere than sample 0. The quantization works fine, it always starts on the beat, just the wrong beat.

This might be a bug, or it might be me. I’m happy to get my c++ on if I need to. Any help at all would be appreciated!

I tried to repro this on a clean project … and it worked as expected, so I guess I just need to figure out what’s different in my project, or what could cause a sound to behave differently like that.

Try setting your SoundWaves to be Seekable Streaming.

Thanks for the suggestion. I tried that, and while it did allow the waves to start at non-zero times, for some reason it through off the quantisation, and the loops sometimes started out of sync.

But - I think I’ve solved it another way. I turned off stream caching (I must have turned it on at some point while experimenting) and also increased the max cache size. For some reason, that stopped the streaming waves from playing at all, but when I switched off force streaming and seeking, it works. For now, they seem to start properly quantised and on non-zero start times.

Quartz should work with Stream Caching – Fortnite uses both quite a bit. I wonder if there was a bug however. Let us know if you see similar behavior in UE 5.0 (either EA or 5.0).