Trying to subdivide notes

• Sep 15, 2013 - 14:03

I am trying to create a plugin that subdivides notes into 256ths (in fact, any duration you want), but whenever I test it, I get glitchy results. I've spent 3 hours trying to solve the problem. Could anyone please help me?
http://pastebin.com/ih1pv5wj


Comments

Actually, there are 128ths and 256ths; they just don't show up left to the 64th note.
Also, I tried the same thing with 8ths, but it gave similar results.

In reply to by Jojo-Schmitz

Try this:

Go to note input mode
Select 64th on the top
Select one dot (or two if you want proof that 256th notes are supported)
Put in a note
Exit note input mode (You should see a 128th or 256th rest; either way, it will look like a 128th)
Select the 128th or 256th rest
Re-enter note input mode
Insert a note
It may look like a 64th, but if you count the amount of beats the two notes take, you should realize that you just put a shorter note.

Does it work for *supported* note values? If so, then I think you've discovered that not only are 256th notes not supported, but they don't in fact work either.

In reply to by bb94

Your plugin code gets my MuseScore into a tight loop on a large score.
On a small 4/4 1-measure score with 4 quarter notes, it produces a quarter rest, 8th note, quarter rest and another 8th note, effectivly corrupting the score, that measure is now a quarter too short. Undo doesn't revert it properly, it ends up with 8th, quarter, 8th and quarter note. No idea why it does this, but you may want to look at the code of other plugins that add notes and rests to a score like any of the following:

As the plugin framework is going to changing drastically für 2.0, I'm not sure this is worth the effort?

At first glance, my guess is that that as you add notes using one cursor, that's affecting the loop you set up with the other. I doubt they are maintained separately - they are both just views onto the same score.

In reply to by bb94

I don't about the same "object", but the same underlying data. So if cursor and c2 are both point to a whole note at the beginning of measure 3, and you use c2 to replace that whole note with four notes, then I'd expect cursor will now also be point to those four quarter notes, or else to be invalid. But I wouldn't expect it to still be point to the old whole note, and I wouldn't expect moving it to the next chordrest to somehow take you all the way to the next measure (which is what the next chordrest would have been had you not changed the content of the measure).

Said more succintly: if you change the score using c2, then cursor will see thise changes too. Cursor won't point at some sort of copy of the original unmodified data.

At least, that's my understanding. I'm not at my computer today to check this. But you code sure looks like it expects cursor to still be looking at the original unmodified score even after mucking around with the score using c2

In reply to by bb94

I don't know plugin programming, so what I say may be wrong, but the following line has no ending ";"

var endTick = cursor.tick() // if no selection, end of score

and the variable "duration" is hard-coded to 240 (an eighth note duration) and never changes. So I don't know how you can say "Second, the variable duration stores the duration of each note."

In reply to by schepers

I meant that if I wanted another plugin with, for example, a 16th note duration, then I can change the value of duration.

As for forgetting semicolons, thank you for pointing it out, but I will have to wait until tomorrow or later to try it out.

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