Create note with tie back
Pretty straightforward: How to create a note and (depending on some rules) add a tie back to it? It does not seem possible to mess around with the tieBack
property of the Note
element, as it is read only.
Pretty straightforward: How to create a note and (depending on some rules) add a tie back to it? It does not seem possible to mess around with the tieBack
property of the Note
element, as it is read only.
Do you still have an unanswered question? Please log in first to post your question.
Comments
Rather than working backwards, go to the previous note and use the tie command on that.
In reply to Rather than working… by jeetee
wow... there is a tie command? didn't find it in the docs...
In reply to wow... there is a tie… by sotniarchos1
cmd("tie");
https://github.com/musescore/MuseScore/blob/7b2b7af7adf6faf45318eb9cf4b…Or depending on the situation perhaps
cmd("chord-tie");
I haven't looked up what the difference between them is.
In reply to cmd("tie"); https://github… by jeetee
I am not quite sure how to use these from the plugin. I am using a
cursor
object to iterate over the score. Let's say my cursor is currently pointing at aNote
element which I want to tie with the previous one. Do you have any simple example in mind?In reply to cmd("tie"); https://github… by jeetee
I just realized than running
cmd('tie')
in my plugin does add a tie from a note to the next, but only to the note previously selected (clicked) in the GUI. If no note is selected, it does not do anything. Is there a way to explicitly instruct which note should thecmd
affect?In reply to I just realized than running… by sotniarchos1
By selecting it from your plugin?
This might be possible using the new selection options in the 3.3 plugin API.
In reply to By selecting it from your… by jeetee
Yeah, I am trying to figure out how to select something from the plugin (specifically to select the previous element from what the cursor is currently pointing to) but no luck so far.
FYI, if anyone else is trying to get this to work; I did manage to do so. Code snip below. Full qml which did it attached. Code snip was run against a measure with three D notes on it, starting with the whole measure selected.
oCursor.rewind(Cursor.SELECTION_START);
if(oCursor.element.type === Element.CHORD) {
iTk = oCursor.tick;
console.log("\n------------------------------ | CHORD at Tick ", iTk," | ------------------------------");
console.log("---- Chord Contains <", oCursor.element.notes.length,"> Note\n");
// Try adding a tie
// select a single note - NOTE: will clear the range selection.
var oNote2Tie = oCursor.element.notes[0];
var bNoteSelectionOk = false;
bNoteSelectionOk = curScore.selection.select(oCursor.element.notes[0], false);
if (!bNoteSelectionOk) {
console.log(" ***** ERROR **** SELECTION RETURNED FALSE");
}
else {
console.log("We should have now selected a single note, so now add a tie");
cmd("tie");
}
}
// Re-establish the selection range and go look for the tie we added
oSelection.setSelectionRange(oCursor);
oCursor.rewind(Cursor.SELECTION_START);
if(oCursor.element.type === Element.CHORD) {
if(oCursor.element.notes[0].tieForward != null) {
var oTieStartNote = oCursor.element.notes[0].tieForward.startNote;
var oTieEndNote = oCursor.element.notes[0].tieForward.endNote;
console.log("---- ---- Note [", 0, "] has a Tie Forward: startNote Pitch <", oTieStartNote.pitch, "> endPitch <", oTieEndNote.pitch, ">");
}
}
Not being able to tie backwards weakens the rhythm input mode
since you can't create ties to notes of different values during input, which means,
you have to add the ties afterwards.