newElement(Element.NOTE) crashes Musescore 3.2.3 on Ubuntu
Hi,
I'm writing a plugin creates a Score with all forms of a PitchClass Seqeunce (Row, etc.).
It works if I create notes using cursor.addNote(pitch), but if I try to create a Note Element, MuseScore crashes.
I've been able to isolate the crash to the statement which creates the Element:
var newNote = newElement(Element.NOTE)
I'm running MuseScore 3.2.3 on Ubuntu. I could also try it on a Mac and post an update.
Here's the functions which generates the score, which otherwise works when calliong addNote(pitch).
Any ideas would be much appreciated.
function generateTTOScore() {
var myScore = newScore("TTOs", "Paul M", 24)
myScore.startCmd()
myScore.addText("title", "TTOs")
var pcMod = 12
var multipliers = [ 1, 11, 7, 5]
//var row = [ 0, 11, 1, 2, 10, 8, 5, 3, 9, 4, 7, 6 ]
var row = getSequenceFromText( pcSeqTextArea.text )
var baseTimeSig = newElement(Element.TIMESIG)
baseTimeSig.timesig = fraction( row.length, 4 )
baseTimeSig.visible = false
var oCursor = myScore.newCursor()
oCursor.rewind(Cursor.SCORE_START)
//oCursor.rewindToTick(0)
oCursor.add(baseTimeSig)
//myScore.appendMeasures(20)
oCursor.setDuration(1, 4)
oCursor.rewind(Cursor.SCORE_START)
//var index = 0
for (var multIndex = 0; multIndex < multipliers.length; multIndex++) {
for (var transIndex = 0; transIndex < pcMod; transIndex++) {
var elText = newElement(Element.STAFF_TEXT);
var transformationString = "T" + transIndex
var multString = ""
if (multIndex == 5 || multIndex == 7) {
multString = "M" + multIndex
}
if (multIndex == 11) {
multString = "I"
}
transformationString = transformationString + multString
elText.text = transformationString
//oCursor.add(elText)
for (var rowIndex = 0; rowIndex < row.length; rowIndex++) {
var pitch = ((row[rowIndex] + transIndex) * multipliers[multIndex]) % pcMod
if ( pitch < 3 ) {
pitch += 12
}
if ( rowIndex == 0) {
elText.placement = Placement.ABOVE;
elText.autoplace = false;
oCursor.add(elText)
}
/* creating a new Note with newElement crashes Musescore /
/
var newNote = newElement(Element.NOTE)
newNote.pitch = pitch + 60
newNote.noteType = NoteType.NORMAL
newNote.tpc1 = lookupTpc(pitch)
newNote.tpc2 = lookupTpc(pitch)
if ( newNote.accidental == null) {
newNote.accidentalType = Accidental.NATURAL
}
oCursor.add(newNote)
*/
oCursor.addNote(pitch + 60, true)
}
myScore.appendMeasures(1)
}
}
myScore.endCmd()
}
Comments
Update to 3.6.2 first.
In reply to Update to 3.6.2 first. by Jojo-Schmitz
Thank you-- I'm trying that in an AppImage right now. Im the 3.6.2 version, I'm seeing this error:
"TypeError: Property 'parseInt' of object function() { [code] } is not a function" on this line:
const pc = Number.parseInt(pcArray[index]) % 12
It's baffling me, since it seems to be a simple Javascript function: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Globa…
I tried adding the radix as per the documentation:
const pc = Number.parseInt(pcArray[index], 10) % 12
I'll continue to hunt that down, as the same line worked in 3.2.3. I'd prefer not to write my own parseInt, but might have to.
Thanks,
Paul
In reply to Thank you-- I'm trying that… by marqrdt
That is probably due to the AppImages using Qt 5.9, whereas the distribution packages are often using a newer Qt version (check Help > About Qt), which support ECMA 6 as Qt 5.12
In reply to Thank you-- I'm trying that… by marqrdt
Cannot You use
const pc = parseInt(pcArray[index], 10) % 12
instead?.
I am not sure, You can add note that way.
If I am not wrong, you can add(note) to chords
chord.add(note)
, but you need to have chord element first.I will check source code.