# Triplet Timeline Callbacks

**URL:** <https://qa.fmod.com/t/triplet-timeline-callbacks/21164>\
**Category:** Unity\
**Tags:** unity, csharp\
**Created:** [January 29, 2024, 10:10am UTC](https://qa.fmod.com/t/triplet-timeline-callbacks/21164 "2024-01-29T10:10:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kiru176](https://avatars.discourse-cdn.com/v4/letter/k/ba8739/32.png) [@Kiru176](https://qa.fmod.com/u/Kiru176)\
**Post date:** [January 29, 2024, 10:10am UTC](https://qa.fmod.com/t/triplet-timeline-callbacks/21164/1 "2024-01-29T10:10:30Z")

</div>

I have a woring Timeline Callback script triggering events on beats, but I need subbeats to trigger certain events as well. I tried altering the signature and managed to get the quarter notes, but I might need things like triplets to also be assigned to events, which seems hard to do.

```auto
        accurateTime = dspclock / 48800;
        halfTime = dspclock / 48800 * 0.5f;
        tripletTime = dspclock / 48800 * GetIntervalLength(_bpm, 0.3f);
        quarterTime = dspclock / 48800 * 0.25f;
      
        public float GetIntervalLength(float bpm, float noteLength)
        {
            return 60f / (bpm * noteLength);
        }

```

This is what I’m trying as of now, but for some reason it keeps being triggered with every frame in a condition like this.

```auto
        if (lastTripletTime != Mathf.FloorToInt(tripletTime))
        {
            lastTripletTime = Mathf.FloorToInt(tripletTime);
            //TripletEventUpdated();
            Debug.Log("Triplet");
        }

```

Any help would be much appreciated!

---

<div class="post-metadata">

**Author:** ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)\
**Post date:** [January 31, 2024, 4:54am UTC](https://qa.fmod.com/t/triplet-timeline-callbacks/21164/2 "2024-01-31T04:54:31Z")

</div>

Just to clarify, you’re wanting to receive callbacks for both quarter notes and triplet for the same timeline? Is it a compound meter, or a polyrhythm?

---

<div class="post-metadata">

**Author:** ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)\
**Post date:** [January 31, 2024, 5:15am UTC](https://qa.fmod.com/t/triplet-timeline-callbacks/21164/3 "2024-01-31T05:15:22Z")

</div>

I see you’ve already posted in a separate thread, which I will link here for posterity: [Is it possible to subscribe to sub-beat callbacks? - #7 by Kiru176](https://qa.fmod.com/t/is-it-possible-to-subscribe-to-sub-beat-callbacks/19403/7)

xanhulme’s response in the thread was pretty much exactly what I was going to suggest - if that doesn’t suit your use case, please reply in that thread.

---

<div class="post-metadata">

**Author:** ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)\
**Post date:** [January 31, 2024, 5:15am UTC](https://qa.fmod.com/t/triplet-timeline-callbacks/21164/4 "2024-01-31T05:15:28Z")

</div>


