Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running Separate Tracks at Different Speeds #3

Closed
AuzFox opened this issue Jul 23, 2023 · 3 comments
Closed

Running Separate Tracks at Different Speeds #3

AuzFox opened this issue Jul 23, 2023 · 3 comments

Comments

@AuzFox
Copy link

AuzFox commented Jul 23, 2023

Hello! Had a quick question regarding attaching multiple clocks to a context. I hope it's not too much trouble!
I'm trying to write a tracker similar to LSDJ in that each track can set its own play speed based on the tempo of the song. (For example, track A might run at 4 rows per beat while track B runs at 5 rows per beat)
I don't believe this is possible when only using the master clock, but I see that it's possible to attach multiple clocks to a context, so my thinking is to create one clock per track and use that to drive the divider callbacks.
Would this be the correct approach? If so, how would I set this up? If not, what would be the preferred method to accomplish this?

@AuzFox AuzFox changed the title Using Multiple Clocks For Different Tracks Running Separate Tracks at Different Speeds Jul 23, 2023
@detomon
Copy link
Owner

detomon commented Jul 26, 2023

Hello @AuzFox

I think using multiple clocks for this situation is the right approach. You can use the clocks's callback directly without attaching dividers (it's still possible if needed with BKDividerAttachToClock). I made a new example which shows this: https://github.com/detomon/BlipKit/blob/master/examples/clocks.c (I hope it's clear). This uses three clocks running with different periods which sync up every second. Technically, there is a drift between the clocks because of rounding errors, but it's minuscule and shouldn't be relevant.

@AuzFox
Copy link
Author

AuzFox commented Jul 26, 2023

Ah, this is just what I was looking for, and the example seems pretty clear to me on how it's working. Thanks a bunch! :)
By the way, sorry for not responding in the last issue I opened, but I appreciate the help for both issues!

@detomon
Copy link
Owner

detomon commented Jul 26, 2023

No problem at all. Glad it helped!

@detomon detomon closed this as completed Sep 7, 2023
Repository owner deleted a comment from zyrup Mar 5, 2024
Repository owner deleted a comment from zyrup Mar 5, 2024
Repository owner deleted a comment from zyrup Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants