how to get the length of a rest with plug-in script?
hi,
i find the possibility to write plug-ins great! :)
i wrote now a little plug-in that guesses the chords for a measure that fit the notes in that measure. the only thing i would need is the length of the measures...
could you tell me how to get this? or if it is not in, could you put this into the next release?
here is a piece of code to demonstrate, what i wloud need:
function run() { var cursor = new Cursor(curScore); cursor.staff = 0; cursor.voice = 0; cursor.rewind(); var a =0; var len = 0; while (!cursor.eos()) { if (cursor.isChord()) a++; // just to do someting else len += 1; // i would need here the tickLen of the rest cursor.next(); } }
by the way: the cursor.chord()
is also an [object Rest]
when cursor.isChord()
is true
according to the script debugger.
Comments
Using tickLen causes a crash. I filed a bug report about it: http://www.musescore.org/en/node/2314
i thought that if
cursor.isChord()
isfalse
, thancursor.chord()
can not be called, because is not a chord, but a rest. butcursor.rest()
did not work.it also would be useful to know how many ticks are in a measure.
Rev. 2295 extends scripting with two new functions cursor.isRest() and cursor.rest()
function run()
{
var cursor = new Cursor(curScore);
cursor.staff = 0;
cursor.voice = 0;
cursor.rewind();
var len = 0;
while (!cursor.eos()) {
if (cursor.isRest()) {
var rest = cursor.rest();
len += rest.tickLen;
}
cursor.next();
}
print("==========len ", len);
}
And the number of ticks?
Regards.
Plugins? Where's the documentation?
#4: Number of ticks works for me
The only available Documentation so far is at http://mscore.svn.sourceforge.net/viewvc/mscore/trunk/mscore/README.scr…
Found it. 480 = 1/4 note.
Automatically closed -- issue fixed for 2 weeks with no activity.