TypeError: Cannot assign to read-only property "duration"

• Mar 14, 2021 - 15:19

I try to use the "ExpandChordSymbols" plugin. When I choose a rest in the pattern, I got the error, after these lines:
var e = newElement(Element.REST);
e.durationType = cursor.element.durationType;
e.duration = cursor.element.duration;
I don't want to submit an issue, because I didn't write the plugin. May be Mark Shepherd can find a workaround, or submit the issue, at his choice.


I just noticed the same issue when I was trying to make my first plug-in, It seems the API has been changed, who knows :)
The code you mentioned exists in "addRest(cursor)" function (line 98) and it will be called from a loop in "writeChords" function (line 719).
So you can solve this issue by ignoring the "addRest(cursor)" function, just replace the line 719 with:

719: cursor.addRest(); //addRest(cursor);

Backup the "ExpandChordSymbols" plugin first.
Make the above mentioned change.
Reload the plugins.

In general, to add a Rest, you need to set the duration of the rest in the cursor, which is already considered in line 714 of "ExpandChordSymbols" plugin:
714: cursor.setDuration(thisDuration / 60, 32);
then you call cursor.addRest();

Best regards.

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