cursor.addNote()

• Apr 2, 2021 - 20:17

I use cursor.addNote() to create a Cm chord (root position). However, instead of Eb, I get D#. I know, enharmonic and all the theory, but although it sounds nice, it looks bad. Is there a way to fix it?


Comments

This is my solution for this:

if (element.type == Element.REST) {
// 1) Creating a chord by adding a basic note with the right duration ,
// rewinding the cursor and retrieving the chord at that place.
// This is the only way that is working and that doesn't crash MuseScore
//console.log("==ON A REST==");
var cur_time = element.parent.tick; // getting rest's segment's tick
var duration = element.duration;
oCursor.rewindToTick(cur_time);
oCursor.setDuration(duration.numerator, duration.denominator);
oCursor.addNote(newNote.pitch);
oCursor.rewindToTick(cur_time);
var chord = oCursor.element;
note = chord.notes[0];
} else if (element.type == Element.NOTE) {
...
}

console.log("Setting the note");

// 2) Setting all the properties of that note
note.tpc1 = newNote.tpc1;
note.tpc2 = newNote.tpc2;
note.pitch = newNote.pitch;
// etc...

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