Beat/Grid division with triplets

Nick's icon

Hey all.

I'm working on some tempo-sync effects and looking for a nice way to include triplets in my beat division multiplier.

For example, if I want to sync to 1/4 note, 1/8 note, 1/16 note, 1/32, etc, it's really easy to just follow the power-of-two scale: 1/pow(2, i) where i is perhaps a number input on the user interface with a range [0, 5], and the result of the computation is fed into `rate~` to adjust the output of `sync~`. Wiring that up in Max is obviously very straight forward.

My question is, do any of you have any clever trick or clean abstraction for including 1/3, 1/6, 1/12th notes in that scale? So far, the best I've come up with is manually placing all of the divisions in a list and banging the `nth` item out of the list.

Apologies if there's another post detailing this, I couldn't find a great way to formulate that search. Thanks!

Christopher Dobrian's icon

Does 3*(2^(n-1)) satisfy?

Max Patch
Copy patch and select New From Clipboard in Max.

Nick's icon

Thanks Christopher! That does indeed give me the triplet divisions I'm looking for, but the last piece is interleaving the two so that a single knob turn could cover all of the available divisions: 1/1, 1/2, 1/3, 1/4, 1/6, 1/8, 1/12, etc. That's where I'm stuck currently

Christopher Dobrian's icon

You can do various arithmetic shenanigans, but really a simple lookup is probably easier. The umenu object works well for that.

Max Patch
Copy patch and select New From Clipboard in Max.