Sync Points
alphaTex support specifying sync points for the synchronization with external media.
The related sync points are specified as flat list at the end of the song contents separated by a dot .
.
As we consider it unlikely that authors write this information manually, we separated the sync points from the other song.
This way tools like our Media Sync Editor on the Playground can be used to synchronize songs and
the sync info can be copy-pasted after the main song.
The supported formats of sync points are:
\sync BarIndex Occurence MillisecondOffset
\sync BarIndex Occurence MillisecondOffset RatioPosition
Where:
BarIndex
is the numeric (0-based) index of the bar for which the sync point applies.Occurence
is the numeric (0-based) index of bar repetitions. e.g. on Repeats or Jumps bars might be played multiple times. This value allows specifying points on subsequent plays of a bar.MillisecondOffset
is the numeric timestamp in milliseconds in the external audio.RatioPosition
is the relative offset within the bar at which the sync point is placed (0 if not provided).
The BarIndex
, Occurence
, RatioPosition
values define the absolute position within the music sheet.
The MillisecondOffset
defines the absolute position within the external media.
With this information known, alphaTab can synchronize the external media with the music sheet.
The sample below uses an audio backing track with inconsistent tempos. The sync points correct the tempo differences and the cursor is placed correctly.
\title "Prelude in D Minor"
\artist "J.S. Bach (1685-1750)"
\copyright "Public Domain"
\tempo 80
.
\ts 3 4
0.4.16 (3.2 -.4) (1.1 -.4) (5.1 -.4) 1.1 3.2 1.1 3.2 2.3.8 (3.2 3.4) |
(3.2 0.4).16 (3.2 -.4) (1.1 -.4) (5.1 -.4) 1.1 3.2 1.1 3.2 2.3.8 (3.2 3.4) |
(3.2 0.4).16 (3.2 -.4) (3.1 -.4) (6.1 -.4) 3.1 3.2 3.1 3.2 3.3.8 (3.2 0.3) |
(3.2 0.4).16 (3.2 -.4) (3.1 -.4) (6.1 -.4) 3.1 3.2 3.1 3.2 3.3.8 (3.2 0.3) |
.
\sync 0 0 0
\sync 0 0 1500 0.666
\sync 1 0 4075 0.666
\sync 2 0 6475 0.333
\sync 3 0 10223 1