Type error? (Musescore 2.0 plugin))

• Mar 23, 2015 - 15:20

Hi, I'm not too familiar with the new plugin syntax in Musescore 2, so pardon me if I'm asking something really dumb here..
I seem to have type errors within the first four lines of


var tempChord = new Chord();
var tempNote = new Note();
tempNote.pitch = startNote.ppitch + ((i + 1) / realNotesInBetweenGliss) * (pitchDiff - 1); tempChord.add(tempNote);
tempChord.duration = tickLengthDiff / realNotesInBetweenGliss;
tempChord.visible = false;
cursor.add(tempChord);
cursor.next();

The error is usually on the third line, so I'm guessing I can't treat the Note.pitch as is? It could also be the division causing the error as realNotesInBetweenGliss is an integer and somehow i + 1 is a double?
C++/C# type declarations like
Chord tempChord = new Chord();
and Javascript ones (random stuff I see on the internet and Unity game engine scripting)
var tempChord : Chord = new Chord();
gives syntax errors like 'unknown symbol " ," or " :" ' for some reason.

Someone enlighten me please, thanks!


Comments

The new syntax you use is not the correct one indeed. For MuseScore objects, i.e. for almost anything you may want to put into a score, the correct syntax is:

var tempChord = newElement(Element.CHORD);
var tempNote = newElement(Element.NOTE);

The division should not be a problem in itself, but you may want to convert the result to an integer with the required rounding (up or down) yourself, rather than relying on the truncation applied by the assignment. However, this would only affect the pitch of the resulting note (potentially off by one semitone) and it should not generate run errors.

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