Trying to subdivide notes
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
Musescore doesn't support that yet. I beliebte 64th is the shortest duration in 1.x.
In 2.0 there will be 128th, not sure ab out 256th.
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 Actually, there are 128ths by bb94
Not if the documentation is correct: http://musescore.org/en/plugin-development/tick-length-values
In reply to Not if the documentation is by Jojo-Schmitz
What's wrong with it?
Nothing, I think. It supports my claim that 64th is the shortest supported value
In reply to Nothing, I think. It supports 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.
Please note hat 'works' (maybe partly)and "is supprted" are two different things :-)
In reply to Please note hat 'works' and by Jojo-Schmitz
Anyway, could you please help me figure out what makes the code not work? I tried yesterday for hours and it never did what I wanted.
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.
Have you tried to step through your code in the plugin debugger?
Marc: It doesn't work for 8th notes.
Jojo: I tried, but it didn't work so well.
In reply to Marc: It doesn't work for 8th 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 At first glance, my guess is by Marc Sabatella
So you mean that cursor and c2 point to the same object?
In reply to So you mean that cursor and 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 I don't about the same by Marc Sabatella
But wouldn't the line 'c2.add(rest)' advance the position of c2 so that at the end of the loop right after it, cursor and c2 will again point to the same location?
In reply to But wouldn't the line by bb94
As I mentioned, I was just going off a quick look and am still not at my computer, so I wouldn't pay too much attention to anything I say about your code.
In reply to As I mentioned, I was just by Marc Sabatella
Well, when you get to your computer, I'd like to say some things, in case you didn't know:
First, cursor and c2 are supposed to point to the same location at the beginning of each loop.
Second, the variable duration stores the duration of each note.
In reply to Well, when you get to your 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 I don't know plugin 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.