I’m just cutting and pasting the content of my pull request on Github…
This is my work in progress PR to add a Euclidean rhythms operator to the teletype.
ER f l i
f = fill
l = length
i = index (0-based)
The output is a 1 or 0.
The index is modulo’d against the length.
The data is precomputed using a Haskell script, it only includes lengths up to 32. As far as I can tell, most algorithms to compute a Euclidean rhythm are at best O(n), whereas this is O(1). The code+data adds ~2kb to the ROM size.
Is ER the best name for the operator? Initially I was using EUCLID but it’s a bit too long.
Should the index be modulo’d by length?
What to do about out of bound values (fill > length, length > 32)?
Thank you for your reply.
Yes I am very familiar with Euclidean patterns. Some years ago I have actually built a Max engine for that
I think we should have a proper writeup for this great feature in the Teletype that explains properly all the elements of syntax and implementation.
So… I’ve just been trying to write up something (and checking it all on my Teletype as I’ve been going along), and I’ve noticed that negative indexes aren’t working properly (due to the way that the % operator works in C). I’ll try to get it fixed tomorrow.
There is only one gotcha, the examples with negative numbers, ER 4 16 -1 and ER 4 16 -4, don’t work at the moment. They’ll need a new release of the firmware to fix a bug. @tehn any chance of an updated teletype beta?