Cabbage Logo
Back to Cabbage Site

DAW Clock Sync?

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?

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

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.

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?

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 :upside_down_face:

1 Like

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 :rofl:

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

:rofl:

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 (8.3 KB)

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.

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!

1 Like

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.

1 Like