replace note with rest

• Nov 8, 2014 - 22:12

Hello,

I made all the note i don't want invisible, but when i export in musicxml format or midi format they are still here;

I'd like to replace a lot of notes from a partition with a rest in a plugin.

Can someone point me in the right direction or post a solution ?

regards,

I wrote that that don't work :

function run()

{
if (typeof curScore === 'undefined')
return;
var cursor = new Cursor(curScore);
for (var staff = 0; staff < curScore.staves; ++staff) {
cursor.staff = staff;
for (var v = 0; v < 4; v++) {
cursor.voice = v;
cursor.rewind(); // set cursor to first chord/rest

while (!cursor.eos()) {
if (cursor.isChord()) {
var chord = cursor.chord();
var n = chord.notes;
for (var i = 0; i < n-1; i++)
if (chord.note(i).visible == false) {
chord.removeNote(i);
}
}
cursor.next();
}
}
}
}


Comments

Why don't you just remove those notes from you score? Why marking them invisible anfd then try to remove them thru a plugin rather than not creating them or removing them from the score via 'normal' means, like select, Del?

In reply to by Jojo-Schmitz

I'll try that. Thanks. EDIT : but no sugar, it didn't work :-)

For the moment I resolved it with replacing the note with rest - but it won't work for some cases (when there are more than one note in the same place ie two or three note and there is only some i don't want in the chord) :

if (typeof curScore === 'undefined')
return;
var cursor = new Cursor(curScore);
for (var staff = 0; staff < curScore.staves; ++staff) {
cursor.staff = staff;
for (var v = 0; v < 4; v++) {
cursor.voice = v;
cursor.rewind(); // set cursor to first chord/rest

while (!cursor.eos()) {
if (cursor.isChord()) {
var chord = cursor.chord();
var n = chord.notes;
if (chord.note(0).visible == false) {
var lng = chord.tickLen;
var rest = new Rest();
rest.tickLen = lng;
cursor.add(rest);
}
}
cursor.next();
}
}
}

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