musescore / musescore/MuseScore

Plugin API: expose playback order (RepeatList) for iteration

Open
#33,161 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

community plugins
Dominant language
C++
Stars
15.1k
Forks
3.3k
Avg merge
2d 2h
Merged PRs (30d)
91

Description

Your idea

Expose the playback order (RepeatList) to the Plugin API so that plugins can iterate through the score in the same order as the audio player.

Currently plugins can only iterate linearly:

var measure = curScore.firstMeasure;
while (measure) {
    // linear: 1, 2, 3, 4, 5
    // repeated sections visited only once
    measure = measure.nextMeasure;
}

With the proposed API, plugins could iterate in playback order:

var playback = curScore.repeatList();
for (var i = 0; i < playback.length; i++) {
    var measures = playback[i].measures;
    for (var m = 0; m < measures.length; m++) {
        // playback order: 1, 2, 3, 4, 1, 2, 3, 4, 5
        // handles repeats, voltas, DC, DS, Coda, Fine
    }
}

MuseScore already has a RepeatList class that does this expansion for the audio engine. The proposal is to expose it to plugins.

Problem to be solved

Plugins that need to process the score in playback order (lyrics extraction, chord sheet generation) must currently reimplement the entire repeat/jump/volta unwinding logic in JS. This logic covers:

  • Simple repeats with configurable repeat count (2x, 3x, etc.)
  • Volta brackets (1st, 2nd, 3rd endings and combined like "1-2", "3")
  • DC (Da Capo), DS (Dal Segno) with optional playRepeats flag
  • Coda, Fine, To Coda jumps
  • Section breaks with independent repeat structures
  • Nested repeats and jump loop prevention

Reimplementing this correctly in a plugin is error prone and would diverge from the actual playback behavior.

Prior art
Additional context

A concrete use case is a lyrics + chords export plugin that generates guitar songbook text. It needs playback order to correctly select verse lyrics during repeats and to expand DC/DS sections with the right lyrics and chord symbols.

Checklist
  • This request follows the guidelines for reporting issues
  • I have verified that this feature request has not been logged before, by searching the issue tracker for similar requests

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the existing RepeatList class used by the audio engine and the Plugin API entry points for score iteration. Compare the proposed repeatList() shape with current playback expansion, including repeats, voltas, jumps, codas, and section boundaries; the work is done when plugins can iterate the same playback order as the audio player.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, javascript
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.