How to specify the loop playback of sections in Alphtab #1126
-
How to specify the loop playback of sections in Alphtab, such as setting the loop playback of the first section to the second section |
Beta Was this translation helpful? Give feedback.
Answered by
Danielku15
Mar 26, 2023
Replies: 1 comment 1 reply
-
First find the MasterBars from the Song which indicate the start and end of the range you want to repeat (https://alphatab.net/docs/reference/score). With the masterBars known you can do something like this: function setRepeat(api, startMasterBarIndex, endMasterBarIndex) {
// 1. get master bars from indices
// https://alphatab.net/docs/reference/score
const startMasterBar = api.score.masterBars[startMasterBarIndex];
const endMasterBar = api.score.masterBars[endMasterBarIndex];
// 2. get real playback positions of the masterbars
// https://alphatab.net/docs/reference/api/tickcache
const tickCache = api.tickCache;
const startMasterBarTick = tickCache.getMasterBar(startMasterBar).start;
const endMasterBarTick = tickCache.getMasterBar(endMasterBar).end;
// 3. set playback range and activate loop
// https://alphatab.net/docs/reference/api/playbackrange/
// https://alphatab.net/docs/reference/api/islooping/
api.playbackRange = { startTick: startMasterBarTick, endTick: endMasterBarTick };
api.isLooping = true;
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Danielku15
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First find the MasterBars from the Song which indicate the start and end of the range you want to repeat (https://alphatab.net/docs/reference/score).
With the masterBars known you can do something like this: