Hi,
I need to create a plugin for MuseScore that can expand/shrink a set of selected notes
according to a chosen percentage
Chat GPT provided me with a qml script which has some errors
import QtQuick 2.0
import MuseScore 3.0
MuseScore {
menuPath: "Plugins.ExamplePlugin"
description: "Elargir/Rétrécir les durées des notes sélectionnées en pourcentage"
function applyDurationPercentage(score, percentage) {
var selectedElements = score.selectedNotes
for (var i = 0; i < selectedElements.length; ++i) {
var element = selectedElements[i]
if (element.isChord()) {
var chord = element.toChord()
for (var j = 0; j < chord.notes.length; ++j) {
var note = chord.notes[j]
note.duration *= percentage / 100
}
} else {
var note = element.toNote()
note.duration *= percentage / 100
}
}
}
action: Action {
text: "Elargir Durées"
onTriggered: {
var percentage = parseFloat(prompt("Entrez le pourcentage d'élargissement des durées (par exemple, 200 pour doubler)"))
if (!isNaN(percentage)) {
applyDurationPercentage(score, percentage)
}
}
}
action: Action {
text: "Rétrécir Durées"
onTriggered: {
var percentage = parseFloat(prompt("Entrez le pourcentage de rétrécissement des durées (par exemple, 50 pour réduire de moitié)"))
if (!isNaN(percentage)) {
applyDurationPercentage(score, 100 / percentage)
}
}
}
}
MuseScore’s qml script creator console says:
Component creation failed
line 35: Property value set multiple times
Could you correct this qml script?
thanks