# Safely querying tempo/signature/position from the audio thread(s)

**URL:** <https://forum.juce.com/t/safely-querying-tempo-signature-position-from-the-audio-thread-s/57899>\
**Category:** Tracktion Engine\
**Created:** [September 15, 2023, 4:10pm UTC](https://forum.juce.com/t/safely-querying-tempo-signature-position-from-the-audio-thread-s/57899 "2023-09-15T16:10:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![eggnog](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/eggnog/32/12211_2.png) [@eggnog](https://forum.juce.com/u/eggnog)\
**Post date:** [September 15, 2023, 4:10pm UTC](https://forum.juce.com/t/safely-querying-tempo-signature-position-from-the-audio-thread-s/57899/1 "2023-09-15T16:10:50Z")

</div>

Hi,

One of my custom plugin requires to be fed with tempo/signature/position, but it seems I can’t just use the `TempoSequence` (from the `Edit`) since this code could trigger an async update :

```c++
tempo::BarsAndBeats TempoSequence::toBarsAndBeats (TimePosition t) const
{
    updateTempoDataIfNeeded();
    return internalSequence.toBarsAndBeats (t);
}

```

and :

```c++
void TempoSequence::updateTempoDataIfNeeded() const
{
    // The check on isUpdatePending is to avoid triggering a message thread assert
    // if this is called on a background thread when no update is needed
    if (tempos->isUpdatePending())
        tempos->handleUpdateNowIfNeeded();

    if (timeSigs->isUpdatePending())
        timeSigs->handleUpdateNowIfNeeded();
}

```

I can’t call the `isUpdatePending()` methods myself since `tempos` and `timeSigs` aren’t public.

So… How I can retrieve tempo/signature/positions safely from the audio context ?

Thank you !

E.

---

<div class="post-metadata">

**Author:** ![dave96](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/dave96/32/8487_2.png) [@dave96](https://forum.juce.com/u/dave96)\
**Post date:** [September 18, 2023, 9:55am UTC](https://forum.juce.com/t/safely-querying-tempo-signature-position-from-the-audio-thread-s/57899/2 "2023-09-18T09:55:02Z")

</div>

You can use create a `tempo::Sequence::Position` and then use that from the audio thread.  
It directly uses the internal tempo data so doesn’t do the updating and is thread safe.

---

<div class="post-metadata">

**Author:** ![eggnog](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/eggnog/32/12211_2.png) [@eggnog](https://forum.juce.com/u/eggnog)\
**Post date:** [September 18, 2023, 10:48am UTC](https://forum.juce.com/t/safely-querying-tempo-signature-position-from-the-audio-thread-s/57899/3 "2023-09-18T10:48:04Z")

</div>

Perfect, thank you @dave96 !
