plugins: impossible to set the played duration of a chord
I tried to set the duration of chords from a plug-in. I achieved to modify the displayed duration (correct head type), but not the played duration.
I seems that the displayed duration (head) is set from the property "durationType", while the played duration is set from "duration". The latter is defined by a fraction with properties "numerator" and "denominator". But these properties cannot be written to - I get a read-only error when trying so.
I append the plug-in that I used - the critical lines are commented-out (lines 176ff)
Attachment | Size |
---|---|
chordsToNotes.qml | 13.07 KB |
Comments
I believe the duration property was originally meant to be read-only there and never really made to work.
But you can set the duration of the note/chord to enter if you use the cursor methods for that, see for example the random.qml plugin included with MuseScore which does something like:
In reply to I believe the duration… by jeetee
I tried to use cursor.setDuration, but this only applies to cursor.addNote.
As I use chords and then add the chord to the cursor position with cursor.add, I need to set the duration to the chord. It seems to work with "durationType" (line 175 of my code), but then only the displayed duration is correct, not the played duration which seems to be handled separately with "duration".
Untested: but wouldn't multiple addNote() commands add up to a chord?
Or other workaround, first addNote to get the correct duration, then set chord to that segment?
A workaround (which works only since 3.3 version though) is to make use of the fact that the newly added note gets automatically selected. Not sure how reliable is it but this seems to work: