import QtQuick 1.0 import MuseScore 1.0 MuseScore { menuPath: "Plugins.pluginName" function applyToNotesInSelection(func) { var cursor = curScore.newCursor(); cursor.rewind(1); var startStaff = cursor.staffIdx; cursor.rewind(2); var endStaff = cursor.staffIdx; var endTick = cursor.tick // if no selection, end of score var fullScore = false; if (!cursor.segment) { // no selection fullScore = true; startStaff = 0; // start with 1st staff endStaff = curScore.nstaves; // and end with last } console.log(startStaff + " - " + endStaff + " - " + endTick) for (var staff = startStaff; staff <= endStaff; staff++) { for (var voice = 0; voice < 4; voice++) { cursor.rewind(1); // sets voice to 0 cursor.voice = voice; //voice has to be set after goTo cursor.staffIdx = staff; if (fullScore) cursor.rewind(0) // if no selection, beginning of score while (cursor.segment && (fullScore || cursor.tick < endTick)) { if (cursor.element && cursor.element.type == Element.CHORD) { var notes = cursor.element.notes; for (var i = 0; i < notes.length; i++) { var note = notes[i]; func(note); } } cursor.next(); } } } } function changePitch(note) { note.pitch = 71; } onRun: { console.log("hello colornotes"); if (typeof curScore === 'undefined') Qt.quit(); applyToNotesInSelection(changePitch) Qt.quit(); } }