cursor.addNote()
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?
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?
Do you still have an unanswered question? Please log in first to post your question.
Comments
Try setting the TPC for the note as well as just the pitch: https://musescore.github.io/MuseScore_PluginAPI_Docs/plugins/html/tpc.h…
In reply to Try setting the TPC for the… by jeetee
It's a good idea, but addNote() does not support the tpc value, and does not return a pointer to the note created either. The workaround is a long way, especially when the need is only for rare occasions.
In reply to It's a good idea, but… by gideonrv
I think you can use Chord.add(note) for a newly created note element; which will allow you to set the TPC.
In reply to It's a good idea, but… by gideonrv
Hi, I'm interested in your solution. My goal is to add notes with the right pitch/tpc/accidental (because E#<>F, C#<>Db, ...)
Can you describe how you did ?
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...