Hi!
I am trying to convert the OpenMusic LISP way to notate rhythm into a typical array of durations in SuperCollider. (I am using an OM LISP old syntax style, not the new one).
In a brief, a 4/4 is written like this (4 (1 1 1 1))
were the 4 is the number of beats and the first parenthesis divide the beat into four 1 duration figures (crotchet).
(4 (1 1 1 1))
For making a subdivision one need to put the corresponding beat into a parenthesis and add another parenthesis for the internal subdivision:
(4 (1 (1 (1 1) ) 1 1) )
Dividing the first two beats (minim - 2 value) into a crotchet triplet, the third beat into a semiquaver and a dotted quaver (1 (1/2 3/2) )
and the last beat into a quaver triplet
( (4 ( (2 (1 1 1) ) (1 (1/2 3/2) ) (1 (1 1 1 ) ) ) ) )
Although I think this (((((((LISP)))))))) style is almost illegible, the rhythm tree structure is really usefull for creating complex nested tuplets with simple numbers, in the style of Brian Ferneyhough:
(4 (6 (1 (2 (3 4) ) 5) ) )
So I would like to have a general procedure that converts [4 [1, 2, [1,1,1], 1] ]
or [1, 2, [1,1,1], 1]
(number of beats can be implicit because I am not converting them score notation) into a duration array like [1, 2/3, 2/3, 2/3, 1]
.
Any ideas about how to do it?
I thought about using .deepCollect
but I could not figure out how to read the previous index/item for calculating the subdivision…
By any chance, is there any Pattern or Quark that help using this kind of structure?