Quartz: Fade in with PlayQuantized not working correctly

Hello

I’m currently building a music system for our game using Quartz to play wave assets sample-accurately, and I’m using metasounds as wave assets. The metasound is quite simple - just a wave player that starts playing a pre-entry sound wave (if it has one) before going into a main sound wave that will loop if it is set to do so.

I have built it as a state-based system, where a number of music layers can be associated with certain states. When a new state is queued, the system will crossfade into the layers of that state (if set to crossfade) over the duration of each pre-entry sound wave of the new layer. So all layer crossfades will line up, and be finished on beat 1 of the new state.

For fade-out, I’ve set up a callback using NotifyOnQuantizationBoundary and starting a fade-out when the event type of the callback is EQuartzCommandDelegateSubType::CommandOnAboutToStart. I couldn’t find any StopQuantized function for audio components.

For fade-in, I’m using the optional fade-in parameters of PlayQuantized. This works well enough when audio components are queued up to start on beat 1 of a clock that has not yet started, but not when queued up to play on a later beat. It seems like to me that the fade is started the moment PlayQuantized is called (or when the clock starts). If the delay until the sound starts playing is longer than the fade-in duration, the volume of the sound reaches its target value instantly when it starts playing, and if the delay is slightly shorter, it seems like the volume jumps to somewhere in the middle of the fade and then finishes the fade like normal.

See repro steps for more detail.

Is this intended behaviour? For now, I think I will perform the fade-in the same way as the fade-out.

Thank you in advance.

Steps to Reproduce

  1. Set up a quartz clock and start it.
  2. Queue up an audio component to play at a few bars in using PlayQuantized.
    1. Make sure to call PlayQuantized with a fade duration that is long enough to easily observe/hear.
  3. Observe the volume of the audio component’s sound in Audio Insights.
    1. When queued, the sound should show in Audio Insights with volume 0 (as it takes up a voice slot instantly with default settings).
    2. If the time queued is higher than the fade-in duration, the volume jumps instantly to the target volume when the sound starts playing, ignoring the fade-in settings.

Oh, I just saw that we’re actually on 5.6.1, not 5.7.

That’s a good callout and something we should support.

In the meantime I would do the fade inside of your MetaSound.

Are you building from c++? If we get a fix in for 5.8 would you want me to post the fix here?

Yes, that would be very helpful.

I did actually do the fade in the metasound before I saw that PlayQuantized has optional fade parameters. I’ll change it back to that for now - although the already defined fade curves for audio components are nice to work with as I want to be able to do other fades than just equal power.

Thank you!