Copying from one score to another in a Musescore 2.0 plugin

• Sep 16, 2014 - 12:05

Hi,

I'm a little confused by the new plugin architecture of Musescore 2.0 (it doesn't help that I don't have any experience with QML, sorry I'm working on that...).

I would like to copy a selection of a score to a new one and I've managed to copy the notes (i.e., the pitches) by looking at the "notenames" plugin and using two cursors in parallel in the two scores. However, I cannot figure out where I should get/set the duration of each note and how to copy rests as well.

Here's an excerpt of the part of my code where I need some hints to solve my problem:

var scoreCopy = newScore("copy.mscz", "Piano", 8);
var cursor2 = scoreCopy.newCursor();
cursor2.rewind(0);

while (cursor.segment && (fullScore || cursor.tick < endTick)) {
if (cursor.element){
if(cursor.element.type == Element.CHORD){
var notes = cursor.element.notes;
for (var i = 0; i < notes.length; i++) {
cursor2.setDuration(1, cursor.element.duration); //???
cursor2.addNote(notes[i].pitch);
} // end for note
}
if(cursor.element.type == Element.REST){
//???
}
} // end if ELEMENT
cursor.next();
cursor2.next();
} // end while segment

Could somebody please provide me or point me to an example showing how this is supposed to work in a plugin for Musescore 2.0?

Generally speaking, where should I look for a reference of the available objects/properties/methods? The Musescore Debugger or the manual in the Musescore Plugin Creator (the latter seems rather incomplete to me)?

Thanks
Francesco


Comments

Do you still have an unanswered question? Please log in first to post your question.