digego / extempore

A cyber-physical programming environment
1.41k stars 127 forks source link

Pattern language synchronisation #382

Open bradrn opened 4 years ago

bradrn commented 4 years ago

Currently, the pattern language is hardcoded to start patterns every four beats:

https://github.com/digego/extempore/blob/f86098457f013813ca1f9236982fef4ae09a9de7/libs/core/pattern-language.xtm#L141

This is fine for patterns which are multiples of four beats long (which I expect is most of them). But for patterns which aren’t, it’s nearly impossible to get any sort of synchronisation between patterns. It would be nice to fix this; I’m thinking that the best solution would be to add another parameter to :> and :| to specify on which beat it should be synchronised, although as a breaking change I’m wary of sending this in as a PR without any prior discussion.

For a concrete example:

(:> pat-1 4 0 (play syn1 @1 85 dur) '(60 62 64 65))
(:> pat-2 4 0 (play syn2 @1 85 dur) '(72 74 76 77))

(:> pat-1 3 0 (play syn1 @1 85 dur) '(60 62 64))
(:> pat-2 3 0 (play syn2 @1 85 dur) '(72 74 76))

The first pair of patterns will always start on the same beat, even when run at different times, while the second pair of patterns will almost never start on the same beat (although they will be synchronised with any other 4-beat-long pattern which is being played).

digego commented 4 years ago

yeah, this one isn't ideal, but there also isn't really a "right answer" to this problem. As you note, the 4-beat-long-pattern is a synchronisation "default". The problem of course is that you can have patterns of different lengths - and how you might want to synchronize those will be different under different conditions. We have thought about adding a global pattern-sync variable that would at least give the composer a little more control than the default 4 at the moment. Still thinking about this one.