# DAW Clock Sync?

**URL:** <https://forum.cabbageaudio.com/t/daw-clock-sync/2848>\
**Category:** Cabbage Stew\
**Created:** [9 September 2021 16:24 UTC](https://forum.cabbageaudio.com/t/daw-clock-sync/2848 "2021-09-09T16:24:37Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![chronopolis](https://forum.cabbageaudio.com/letter_avatar_proxy/v4/letter/c/c37758/32.png) [@chronopolis](https://forum.cabbageaudio.com/u/chronopolis)\
**Post date:** [9 September 2021 16:24 UTC](https://forum.cabbageaudio.com/t/daw-clock-sync/2848/1 "2021-09-09T16:24:37Z")

</div>

Is there a way to trigger something to be in sync with the host? Possible with `TIME_IN_SECONDS `? For instance - I have a rhythmic sequence that automatically triggers at the HOST\_BPM tempo. But how can I get it to start on a downbeat w/o user intervention?

---

<div class="post-metadata">

**Author:** ![chronopolis](https://forum.cabbageaudio.com/letter_avatar_proxy/v4/letter/c/c37758/32.png) [@chronopolis](https://forum.cabbageaudio.com/u/chronopolis)\
**Post date:** [9 September 2021 16:38 UTC](https://forum.cabbageaudio.com/t/daw-clock-sync/2848/2 "2021-09-09T16:38:12Z")

</div>

OK, maybe i answered my own question… I guess this has to be triggered at k rate by listing to “IS\_PLAYING”?

---

<div class="post-metadata">

**Author:** ![rorywalsh](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/rorywalsh/32/165_2.png) [@rorywalsh](https://forum.cabbageaudio.com/u/rorywalsh)\
**Post date:** [9 September 2021 18:08 UTC](https://forum.cabbageaudio.com/t/daw-clock-sync/2848/3 "2021-09-09T18:08:30Z")

</div>

Yes, `IS_PLAYING` will let you know when the session has started playback, after that you should query `HOST_PPQ_POS`. That should get you sorted.

---

<div class="post-metadata">

**Author:** ![chronopolis](https://forum.cabbageaudio.com/letter_avatar_proxy/v4/letter/c/c37758/32.png) [@chronopolis](https://forum.cabbageaudio.com/u/chronopolis)\
**Post date:** [9 September 2021 22:29 UTC](https://forum.cabbageaudio.com/t/daw-clock-sync/2848/5 "2021-09-09T22:29:09Z")

</div>

So you can just get a trigger from `HOST_PPQ_POS` but there’s no actual time value like with metro so you cannot operate on it - like change it to 8th notes.

Basically I need metro to trigger on the quarter note. Or maybe there’s a different opcode?

---

<div class="post-metadata">

**Author:** ![chronopolis](https://forum.cabbageaudio.com/letter_avatar_proxy/v4/letter/c/c37758/32.png) [@chronopolis](https://forum.cabbageaudio.com/u/chronopolis)\
**Post date:** [9 September 2021 23:34 UTC](https://forum.cabbageaudio.com/t/daw-clock-sync/2848/6 "2021-09-09T23:34:56Z")

</div>

Right - I think I got this sorted simply by triggering the instrument with `metro` in it with another instrument that listens for IS\_PLAYING. Seems to stay in sync like that 🙃

---

<div class="post-metadata">

**Author:** ![rorywalsh](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/rorywalsh/32/165_2.png) [@rorywalsh](https://forum.cabbageaudio.com/u/rorywalsh)\
**Post date:** [10 September 2021 08:46 UTC](https://forum.cabbageaudio.com/t/daw-clock-sync/2848/7 "2021-09-10T08:46:41Z")

</div>

So as soon as IS\_PLAYING is triggers, you simple sequence notes using a metro, according to the current BPM? Just keep in mind there might be some timing issues. If your `kr` is set to 16, it gives you have an max error margin of `16/SR`. So it could take 16/SR seconds for your plugin to react. In reality it will rarely ever be this much. It is pretty small, but enough to annoy the sample-accurate timing mob 🤣

---

<div class="post-metadata">

**Author:** ![chronopolis](https://forum.cabbageaudio.com/letter_avatar_proxy/v4/letter/c/c37758/32.png) [@chronopolis](https://forum.cabbageaudio.com/u/chronopolis)\
**Post date:** [10 September 2021 16:09 UTC](https://forum.cabbageaudio.com/t/daw-clock-sync/2848/8 "2021-09-10T16:09:12Z")

</div>

> [@rorywalsh](#):
>
> So as soon as IS\_PLAYING is triggers, you simple sequence notes using a metro, according to the current BPM?

Exactly. Sample accuracy - ha… this is a plugin for making ambient music 😆

---

<div class="post-metadata">

**Author:** ![rorywalsh](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/rorywalsh/32/165_2.png) [@rorywalsh](https://forum.cabbageaudio.com/u/rorywalsh)\
**Post date:** [10 September 2021 16:12 UTC](https://forum.cabbageaudio.com/t/daw-clock-sync/2848/9 "2021-09-10T16:12:31Z")

</div>

🤣

---

<div class="post-metadata">

**Author:** ![circuitdust](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/circuitdust/32/5283_2.png) [@circuitdust](https://forum.cabbageaudio.com/u/circuitdust)\
**Post date:** [6 November 2023 00:18 UTC](https://forum.cabbageaudio.com/t/daw-clock-sync/2848/10 "2023-11-06T00:18:26Z")

</div>

Apologies for the necro, but I’m having this problem as well.  
How do I link `HOST_PPQ_POS`, is it a direct parameter into `metro`? From what I understood, the init phase has to be between 0 and 1, so would it be `metro(1, (kvarForHostPPQPos % 4) / 4)` for whole notes? BPM in this case would be 60.

I attached my current plugin and I made a silent recording of my plugin sync issue below. It is towards the end at 1:44. Maybe there is a better way to sync my sequencer metronome (line 144)?  
[BadHumors.csd](https://forum.cabbageaudio.com/uploads/short-url/fvAGuNaOxu008rTEV4ggb87s6Nn.csd) (8.3 KB)  
[https://cdn.discordapp.com/attachments/791873614046953483/1170874552637718598/BadHumor\_devtest.mp4](https://cdn.discordapp.com/attachments/791873614046953483/1170874552637718598/BadHumor_devtest.mp4)

---

<div class="post-metadata">

**Author:** ![rorywalsh](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/rorywalsh/32/165_2.png) [@rorywalsh](https://forum.cabbageaudio.com/u/rorywalsh)\
**Post date:** [6 November 2023 10:20 UTC](https://forum.cabbageaudio.com/t/daw-clock-sync/2848/11 "2023-11-06T10:20:23Z")

</div>

Can you not just get HOST\_BPM and use that? So it would be like `metro(chnget:k("HOST_BPM")/60)`?

The use can use `IS_PLAYING` to start and stop the instrument depending on the host.

---

<div class="post-metadata">

**Author:** ![circuitdust](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/circuitdust/32/5283_2.png) [@circuitdust](https://forum.cabbageaudio.com/u/circuitdust)\
**Post date:** [6 November 2023 20:45 UTC](https://forum.cabbageaudio.com/t/daw-clock-sync/2848/12 "2023-11-06T20:45:16Z")

</div>

Yeah, I am now using HOST\_BPM and using it to change the rate of the metro. I was under the impression that I could reinitialize metro by passing an initial phase for each time IS\_PLAYING changes to 1 to fix my lag, but metro does not like having k-rate variables passed into the initial phase and gives an error, because it is only used once at the beginning.

What I now think my issue with the starting lag is that 1) my code does not check if IS\_PLAYING changes, and just assumes that at some point it will become 1, and 2) the instrument is perpetually running, instead of being triggered. Haven’t fixed it yet, but in the case it’s still a problem, I will simply make a new topic with better detail.

To anyone in the future trying to sync a sequencer or something similar, change your code to trigger the sequencer with an event, just like what @chronopolis mentions in the fifth post. In the code examples, there are great TR-808 and TB-303 sequencers made by Iain that can be referenced.

I will edit this post and clean it up once I confirm my changes fixed the issue!

---

<div class="post-metadata">

**Author:** ![circuitdust](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/circuitdust/32/5283_2.png) [@circuitdust](https://forum.cabbageaudio.com/u/circuitdust)\
**Post date:** [8 November 2023 05:29 UTC](https://forum.cabbageaudio.com/t/daw-clock-sync/2848/13 "2023-11-08T05:29:29Z")

</div>

Forgot that I can’t edit posts after 24 hours, woops.

Yes, my issue was that the instrument was perpetually running. Changing it to that trigger of whenever “IS\_PLAYING” changes to 1 properly synced it.
