maxint-rd / MmlMusic

Arduino library to play multi-track MML music using different sound devices.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multi-channel synchronization

maxint-rd opened this issue · comments

When playing multiple channels, synchronization can get lost due to the way notes are played. When waiting between notes relative timing is used on a per track level, without taking the progress of other tracks into account. Example song: https://archeagemmllibrary.com/star-wars-theme-2/

To implement synchronization MML songs can use the synchronization bar "|" between notes.
Using this bar would mean that subsequent notes are not played unless each track has played until the same bar count (or until the end of the song).

Improved track synchronization quite a bit. The example song mentioned above now ends all three tracks at (about) the same time. Better timing was reached by using previous event time instead of millis() to calculate the next event time. See this commit.

Unfortunately it's not perfect yet and more complex songs such as this one still may need implementation of synchronization bars (although it plays much better now).