Sync function for synchronizing beat patterns across tracks
kylestetz opened this issue · comments
@enedrio tossed out this idea to sync multiple tracks:
// t1 plays something, t2 playing something else
t1 = new track()
t2 = new track()
var g = new group(t1, t2)
g.beats([2, 3, 4], [4,5,6]).sync()
where sync
sets the currentStep
and untilNextBeat
to 0, effectively matching the beginning of each track's beat pattern.
I think adding this to the group
API is a no-brainer, but could this also be available globally? Perhaps as sync(tracks)
?
I opened issue #11 as an idea about consolidating global variables into a Lissajous
object so that the global namespace doesn't get overpopulated. If this was the case you could call Lissajous.sync(tracks)
.
Thoughts?
Just realized: rather than being a global function, this should be a method of individual tracks as well.
var t1 = new track()
var t2 = new track()
t1.beat(4,3)
// some time later...
t2.beat(3,2,1,1).sync(t1)
sync
could accept multiple tracks as arguments!
that seems to be an intuitive solution. it fits nicely into the logic of the framework. I like it. :)
I've added both of these based on your original implementation. Cheers 🍻
Great! Thank you. :)