Created
December 7, 2012 15:39
-
-
Save lasconic/4234030 to your computer and use it in GitHub Desktop.
Extract lyrics from score - MuseScore 2.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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