Event not properly stopped after playing

Hi! I have a randomly appearing issue with playing an event from start. I’m using the UFMODAudioComponent in my own actor, play an event (it’s a music track), let’s say it reaches bar 16, then I call Stop() on the component so the audio stops. Now, there is a like 5% chance that the next time I’m calling Play() on the component, it just resumes at bar 16 instead of starting from the start.

I’m setting the volume to zero before calling Stop(), because it’s using FMOD_STUDIO_STOP_ALLOWFADEOUT which means it doesn’t actually stop until the volume is zero if I understand that correctly. But still, even when doing that right before calling Play(), there’s a random chance that the track will just continue where it stopped instead of restarting.

Any ideas what could cause this, is there another way of forcing the component to reset the event and start over? I’ve been trying to destroy the component and create it again, but that causes other issues.

The weirdest part is that this just started happening recently, while I had no issues in the two years before that with the same setup… and I checked my Git history, I didn’t change any code that would effect this.

Thanks!

I’m afraid we’ll need more information to diagnose this issue.

Does the affected event feature any AHDSR modulators or event conditions?

Does the issue only occur if you start the event almost immediately after stopping it, or does it sometimes happen even when several seconds elapse between Stop() and Play()?

  • We’re using event/transition conditions to switch between our loop regions - based on a parameter (with a quantization interval of 1 bar) - if that’s what you mean.
  • no AHDSR
  • since I’m trying get rid of this issue, I’m even stopping the event twice - once when it should stop and then once again right before i’m playing it the next time (which is usually at least 10 seconds later)

One thing I’ve also noticed recently, and maybe this is related to the issue: Sometimes when clicking on the Stop button in FMOD Studio, it doesn’t stop instantly but continues for a while (or until I click the button again). Maybe we changed something somewhere in the project that would cause this and it’s not a UE4/code fault?

Thanks again!

When auditioning an effected event in FMOD Studio, after clicking the stop button the first time, does the stop button regularly flash until the event finally stops? If so, this indicates that the event has non-immediate stopping behavior that it is attempting to play out.

There are two ways to give an event non-immediate stopping behavior. The first is to attach an AHDSR modulator to an event property (which you’ve mentioned is not the case); the second is to assign an event condition to an instrument or logic marker in the event.

An event condition is a kind of trigger condition that causes an instrument or logic marker’s trigger behavior to depend on the event’s play state. As of the time of writing (June of 2021), we support “Stopping” and “Not Stopping” event conditions - which is to say, we support making an instrument or logic maker’s trigger behavior depend on whether the event is playing or stopping.