Skip to content

Instantly share code, notes, and snippets.

@lasconic
Created December 7, 2012 15:39
Show Gist options
  • Save lasconic/4234030 to your computer and use it in GitHub Desktop.
Save lasconic/4234030 to your computer and use it in GitHub Desktop.
Extract lyrics from score - MuseScore 2.0
import QtQuick 1.0
import MuseScore 1.0
MuseScore {
menuPath: "Plugins.pluginName"
onRun: {
var cursor = curScore.newCursor();
var sArray= new Array();
for (var track = 0; track < curScore.ntracks; ++track) {
cursor.track = track;
cursor.rewind(0); // set cursor to first chord/rest
while (cursor.segment) {
if (cursor.element && cursor.element.type == Element.CHORD) {
var lyrics = cursor.element.lyrics;
for (var i = 0; i < lyrics.length; i++) {
var l = lyrics[i];
if(!l)
continue;
if(sArray[i] == undefined)
sArray[i] = "";
if(l.syllabic == Lyrics.SINGLE || l.syllabic == Lyrics.END)
sArray[i] += l.text + " ";
if(l.syllabic == Lyrics.MIDDLE || l.syllabic == Lyrics.BEGIN)
sArray[i] += l.text;
}
}
cursor.next();
}
}
for (var i = 0; i < sArray.length; i++) {
console.log(sArray[i]);
}
Qt.quit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment