Erh.. erh.. Well.. It is a pretty long piece of code, so a quick reply in that one is pretty hard!
To put it short; Rhythm (opposite to notes) is very thankful and giving to work with: A few rules, some basic categories, some marks of what can be altered while staying within style.. and then just mixing it with inputs to generate new beats..
You know; If you count to 4, and then focus on 1 & 3 in one basic pattern, and then allow 1/16 resolution, and then make patterns of 3 repetitions, and one variation etc.. already at an early stage in the programming your robot will amaze you with new beats it has made. Rhythm is very giving, most things goes.
Then there is shuffle, but that is just a parameter set for a value.
Crap answer, I know, sorry - I could show you if you where here.. But try to make a robot make rhythm, and see that it is very easy! (that part of it) More tricky is to make it hit in sync as the sticks do not move at the same speed, so you have to do backwards engineering in time.. And finaly coding it so that a Microcontroller (without any external timing clock) plays stady. THAT takes some strange coding