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
Welcome to this forum. You are creating an native MuseScore app for SailfishOS?
With no definition of the type “MuseScore” and the code using “MuseScore” it is hard for me to understand this artificial code. So have a look to the error message:
Sure you have see this first: the property “action” (of type “Action”) is set mulitple times. You can rename this properties with personalised names. No idea what this mean for the other code in your project.
Yeah, that’s the thing, someone’s using a nail to hit a hammer, gibberish-generator (muh AI) can produce more plausible looking code-snippets than there are people in the world, so asking a biologically limited resource (humans) to debug its hallucinations is just… absurd, and it’s only going to get worse as the hype is still in full swing and zoomers literally use it instead of searching for real things