# Magnet Region is slow to trigger

**URL:** https://qa.fmod.com/t/magnet-region-is-slow-to-trigger/18877
**Category:** FMOD Studio
**Created:** [June 11, 2022, 7:32pm UTC](https://qa.fmod.com/t/magnet-region-is-slow-to-trigger/18877 "2022-06-11T19:32:12Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![daisyowl](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/daisyowl/32/3663_2.png) [@daisyowl](https://qa.fmod.com/u/daisyowl)
#### Post date: [June 11, 2022, 7:32pm UTC](https://qa.fmod.com/t/magnet-region-is-slow-to-trigger/18877/1 "2022-06-11T19:32:12Z")

</div>

Hi! Recently I swapped to using a single timeline and magnet regions to swap between ambiences and songs in our game. I’m using several magnet regions, some of which are quantized, and some of which aren’t, for things I want to snap to instantly. The region conditions are using a single “User: Labeled” parameter.

It works, but instead of being instant, the _non-quantized_ transitions still take a long time to trigger, maybe something like 250-500ms if I had to guess. Is this just a limitation of magnet regions or is there anything we can do to make it react faster?

Our previous solution, starting and stopping events ourselves, was instant, so I don’t believe it has anything to do with buffer size.

---

<div class="post-metadata">

### Author: ![joseph](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joseph/32/264_2.png) [@joseph](https://qa.fmod.com/u/joseph)
#### Post date: [June 16, 2022, 1:34am UTC](https://qa.fmod.com/t/magnet-region-is-slow-to-trigger/18877/2 "2022-06-16T01:34:54Z")

</div>

I’m afraid we’ll need more information to diagnose this issue. Does the issue occur only in-game, or can it be reproduced in FMOD Studio? Are you able to take a video of a session in which this occurs?

I should mention that ~20 ms of latency is expected when using transition markers or magnet regions with parameter trigger conditions, due to the unavoidable limitations of scheduling sample data playback.

---

<div class="post-metadata">

### Author: ![daisyowl](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/daisyowl/32/3663_2.png) [@daisyowl](https://qa.fmod.com/u/daisyowl)
#### Post date: [June 18, 2022, 11:56pm UTC](https://qa.fmod.com/t/magnet-region-is-slow-to-trigger/18877/4 "2022-06-18T23:56:43Z")

</div>

ok here’s a video, you can see the delay from clicking the scene to the audio changing

(make sure volume is on)

it’s the same ingame and in studio, and definitely much longer than 20ms. playing events is a LOT lower latency than switching between magnet regions.

---

<div class="post-metadata">

### Author: ![daisyowl](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/daisyowl/32/3663_2.png) [@daisyowl](https://qa.fmod.com/u/daisyowl)
#### Post date: [June 18, 2022, 11:57pm UTC](https://qa.fmod.com/t/magnet-region-is-slow-to-trigger/18877/5 "2022-06-18T23:57:39Z")

</div>

![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/7/7286c7716d463ed3cec2fec31dec41c86ee9282d.png)

also, this is the magnet region for “silence” which has no transition timelines or quantization or anything

also: this is FMOD studio 2.01.11, windows 10

---

<div class="post-metadata">

### Author: ![magomusica](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/magomusica/32/420_2.png) [@magomusica](https://qa.fmod.com/u/magomusica)
#### Post date: [June 19, 2022, 11:59pm UTC](https://qa.fmod.com/t/magnet-region-is-slow-to-trigger/18877/6 "2022-06-19T23:59:30Z")

</div>

Probably one of 2 reasons: either you have a seek speed set on your Scene parameter, or the assets in that event are set to “Stream” which will always introduce latency as it loads/unloads.

---

<div class="post-metadata">

### Author: ![daisyowl](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/daisyowl/32/3663_2.png) [@daisyowl](https://qa.fmod.com/u/daisyowl)
#### Post date: [June 20, 2022, 6:37am UTC](https://qa.fmod.com/t/magnet-region-is-slow-to-trigger/18877/7 "2022-06-20T06:37:55Z")

</div>

Checking both those things, it looks to me like it’s Instant, and none of the assets are streaming

![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/6/66f86e9e7673032e7003770853f6b061c8b1b024.png)  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/d/d22fd6924a33ee4ff71b3700c8e3ff92db75546a.png)  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/7/701db46aee4a000a3941456598036fdc2e1106e3.png)

---

<div class="post-metadata">

### Author: ![joseph](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joseph/32/264_2.png) [@joseph](https://qa.fmod.com/u/joseph)
#### Post date: [June 22, 2022, 6:00am UTC](https://qa.fmod.com/t/magnet-region-is-slow-to-trigger/18877/8 "2022-06-22T06:00:10Z")

</div>

Is the following sufficient to explain the latency you’re seeing?

> [@Transitions latency when changing parameter](https://qa.fmod.com/t/transitions-latency-when-changing-parameter/14383/35):
>
> FMOD internally updates every 20ms unless you change this setting via FMOD\_STUDIO\_ADVANCEDSETTINGS. To ensure no gaps in timeline playback we schedule double that time in advance, so 40ms. When you have a condition on the timeline it is evaluated ahead of time, this is probably the latency you are seeing. To reduce this latency you can change the Studio update rate to 10ms, halving the latency. This latency is called scheduling lookahead.
> 
> If there is a particular EventInstance where you want to override these settings take a look at EventInstance::setProperty with FMOD\_STUDIO\_EVENT\_PROPERTY\_SCHEDULE\_DELAY and FMOD\_STUDIO\_EVENT\_PROPERTY\_SCHEDULE\_LOOKAHEAD. Use these with care though, as I mentioned above setting too small could cause sample inaccuracy.

---

<div class="post-metadata">

### Author: ![daisyowl](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/daisyowl/32/3663_2.png) [@daisyowl](https://qa.fmod.com/u/daisyowl)
#### Post date: [June 22, 2022, 11:15am UTC](https://qa.fmod.com/t/magnet-region-is-slow-to-trigger/18877/9 "2022-06-22T11:15:52Z")

</div>

The latency demoed in the video i posted seems a lot higher than 40ms, right? I can’t bring it into a video editor at the moment to get a precise number but its almost a whole quarter note at 138bpm, which would be in the ballpark of ~500ms. And the magnet region for “Silence,” which I’m switching to, has no quantization.

---

<div class="post-metadata">

### Author: ![joseph](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joseph/32/264_2.png) [@joseph](https://qa.fmod.com/u/joseph)
#### Post date: [June 24, 2022, 1:48am UTC](https://qa.fmod.com/t/magnet-region-is-slow-to-trigger/18877/10 "2022-06-24T01:48:46Z")

</div>

Are you able to send us a copy of a project containing an event that exhibits the behavior, so that we can investigate the cause? You can upload packaged projects in the uploads tab of your profile page, provided you’ve registered a game project you’re working on with us.

---

<div class="post-metadata">

### Author: ![daisyowl](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/daisyowl/32/3663_2.png) [@daisyowl](https://qa.fmod.com/u/daisyowl)
#### Post date: [June 24, 2022, 7:26am UTC](https://qa.fmod.com/t/magnet-region-is-slow-to-trigger/18877/11 "2022-06-24T07:26:19Z")

</div>

how do i register a game?

---

<div class="post-metadata">

### Author: ![joseph](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joseph/32/264_2.png) [@joseph](https://qa.fmod.com/u/joseph)
#### Post date: [June 24, 2022, 7:59am UTC](https://qa.fmod.com/t/magnet-region-is-slow-to-trigger/18877/12 "2022-06-24T07:59:01Z")

</div>

You can register a game by going to [https://www.fmod.com/profile#projects](https://www.fmod.com/profile#projects) and clicking the “Register new project” button. Registering is free, but gives us a better idea of what kinds of games people are making with FMOD.

---

<div class="post-metadata">

### Author: ![daisyowl](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/daisyowl/32/3663_2.png) [@daisyowl](https://qa.fmod.com/u/daisyowl)
#### Post date: [June 24, 2022, 11:25pm UTC](https://qa.fmod.com/t/magnet-region-is-slow-to-trigger/18877/13 "2022-06-24T23:25:26Z")

</div>

ok, that’s pending approval now

---

<div class="post-metadata">

### Author: ![daisyowl](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/daisyowl/32/3663_2.png) [@daisyowl](https://qa.fmod.com/u/daisyowl)
#### Post date: [June 25, 2022, 4:27am UTC](https://qa.fmod.com/t/magnet-region-is-slow-to-trigger/18877/14 "2022-06-25T04:27:10Z")

</div>

okay, this is uploaded to my profile now

---

<div class="post-metadata">

### Author: ![daisyowl](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/daisyowl/32/3663_2.png) [@daisyowl](https://qa.fmod.com/u/daisyowl)
#### Post date: [July 6, 2022, 6:31pm UTC](https://qa.fmod.com/t/magnet-region-is-slow-to-trigger/18877/15 "2022-07-06T18:31:19Z")

</div>

Just pinging this thread to make sure there aren’t any more steps I need to take

---

<div class="post-metadata">

### Author: ![joseph](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joseph/32/264_2.png) [@joseph](https://qa.fmod.com/u/joseph)
#### Post date: [July 18, 2022, 6:49am UTC](https://qa.fmod.com/t/magnet-region-is-slow-to-trigger/18877/16 "2022-07-18T06:49:07Z")

</div>

Having investigated the project you uploaded, it looks like the latency you describe is happening when you switch from playing sound to playing silence.

The latency of the transition itself is only affected by the ~40 ms delay that I mentioned earlier - but there’s ~400 ms fadeout being applied to the instrument that’s stopping, meaning that it remains audible for a few moments after the transition is complete. This fadeout exists to prevent the instrument from stopping playback too abruptly, which would likely result in an audible and undesireable pop, as there’s no way to guarantee the transition will occur on a zero crossing.

---

<div class="post-metadata">

### Author: ![daisyowl](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/daisyowl/32/3663_2.png) [@daisyowl](https://qa.fmod.com/u/daisyowl)
#### Post date: [July 18, 2022, 7:10am UTC](https://qa.fmod.com/t/magnet-region-is-slow-to-trigger/18877/17 "2022-07-18T07:10:59Z")

</div>

I recorded this clip by holding headphones up to the microphone. The click you hear is the mouse up event as i change the value of “Scene” from Epoch to Silence, and it’s takes a full ~550ms for the audio to stop. Also as you can see from the waveform, that time is definitely not spent on any kind of fade out.

Also, 400ms would be a REALLY long time for a stopped event to fade out over, are you sure that’s right? It’s definitely not happening in this clip, to be sure.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/5/511ee052e851e71087834044529f891a9cbc06a1.png)  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/1/11071537f18b4da584049fea4a1a10f10a9b0ae5.png)

(also, after posting i realized the selection i made to hilight the time between mouse up event and sound stopping might be obscuring the “click”, so here’s that waveform without the selection on it in ableton.)

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/e/e605cd622d65e6dada3efdb7fa825a555a645a57.png)

Oh, and here’s the audio itself.  
`https://www.dropbox.com/s/2xi9ueo7hlqf779/latency.wav?dl=0`

---

<div class="post-metadata">

### Author: ![joseph](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joseph/32/264_2.png) [@joseph](https://qa.fmod.com/u/joseph)
#### Post date: [July 19, 2022, 12:53am UTC](https://qa.fmod.com/t/magnet-region-is-slow-to-trigger/18877/18 "2022-07-19T00:53:43Z")

</div>

Upon further examination of your project, we’ve discovered that some of its assets actually are set to stream. You can find a list of all streaming assets in your project by typing “#streaming” into the assets browser search bar, or by clicking the assets browser search bar’s magnifying glass icon and selecting “Filter by Streaming Assets” from the menu.

This is relevant because having any streaming assets in an event increases whole event’s schedule delay so as to allow streams sufficient time to buffer when a parameter value is changed. One of your project’s streaming assets, “god.wav,” is present in the event used in your video; if you set this asset to not stream, you should see a reduction in latency.

---

<div class="post-metadata">

### Author: ![daisyowl](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/daisyowl/32/3663_2.png) [@daisyowl](https://qa.fmod.com/u/daisyowl)
#### Post date: [July 19, 2022, 4:38am UTC](https://qa.fmod.com/t/magnet-region-is-slow-to-trigger/18877/19 "2022-07-19T04:38:07Z")

</div>

Ah, interesting. I thought I had removed all the streaming assets because none showed the blue “stream” tag in the browser, but i guess those were just being covered up by other tags like “#modifed”. Seems like multiple of these should be able to render at once, yeah?

After making it so no assets anywhere in the project were streaming, for good measure, it seems like the latency from mouse click to transition is ~315 ms in the editor, and ~200 ms in the game.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/d/d59b5d1500f3cc9b860c795ac67b7e6726db2bc4.png)  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/8/88a5dedc619e633c06db4acb2e62296c4dc59fa7.png)

This is a good improvement, but 200ms still seems like a long round trip from player input to sound, no? While I was testing the game was running at 144fps, and sending the signal to change the song on the same frame as the mouse input (i verified). So that couldn’t contribute more than 7ms to the timing.

This is the code I’m initializing FMOD with, if it matters

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/4/4819bef74a8ad8ec89806b1fa3fd830ee8afef0e.png)

These docs say that the default is 1024x4 ~= 80ms latency. So the track switching is still another 120ms behind where it could be, right?  
[https://fmod.com/docs/2.00/api/core-api-system.html#system\_setdspbuffersize](https://fmod.com/docs/2.00/api/core-api-system.html#system_setdspbuffersize)

---

<div class="post-metadata">

### Author: ![daisyowl](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/daisyowl/32/3663_2.png) [@daisyowl](https://qa.fmod.com/u/daisyowl)
#### Post date: [July 19, 2022, 4:50am UTC](https://qa.fmod.com/t/magnet-region-is-slow-to-trigger/18877/20 "2022-07-19T04:50:38Z")

</div>

Also, is there any guidance on what buffer size+count settings are appropriate for what platforms?

---

<div class="post-metadata">

### Author: ![magomusica](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/magomusica/32/420_2.png) [@magomusica](https://qa.fmod.com/u/magomusica)
#### Post date: [July 19, 2022, 7:22pm UTC](https://qa.fmod.com/t/magnet-region-is-slow-to-trigger/18877/21 "2022-07-19T19:22:06Z")

</div>

To echo what Joseph has said, I have had projects where an instrument fade or an AHDSR caused transition latency like you’re experiencing. Sometimes I just couldn’t figure it out and just recreated the event from scratch so that I could catch exactly where I went wrong.

[Next page](https://qa.fmod.com/t/magnet-region-is-slow-to-trigger/18877.md?page=2)
