Manipulating duration of note
I want to create a plugin where I scan notes of one music sheet and I want to create the second music sheet where the notes have same pitch but different duration as in the first sheet.
I know how to scan notes in the first sheet and get information I need but IDK how to make a new music sheet and put the new notes there. Can anyone help ?
Alternative could be to scan first track(first line) of the sheet and make second track(second line of the sheet) filled with new notes different duration. How do you move cursor based on track(one line of a sheet) so I dont have to do
nextMeasure ()
nextMeasure ()
nextMeasure ()
nextMeasure ()
this thing
Thank you
Comments
Just
Cursor.next()
will take it to the next segment in the current track as long as there is one.To write notes you can use
setDuration
andaddNote
methods (also from cursor). Take a look at the random and random2 example plugins from https://github.com/musescore/MuseScore/tree/10bbe435fa06705c598044af2c0…Also see the Plugin API Docs for Cursor.
Also, though, in case you weren't aware - there is also Edit / Paste Half Duration (and double), also Paste Special, which changes the duration according to whatever note value is selected on the toolbar.
In reply to Also, though, in case you… by Marc Sabatella
I have a for example 2 notes in music sheet as the attached picture shows. When I change duration of the first note from for example quater note to whole note it works but the second note gets deleted and i cannot change its durations anymore.
How to i keep those notes in score so they dont get deleted when the first one changes ?
In reply to I have a for example 2 notes… by kamilio141414
As Marc just pointed out: you can use Paste Special for this.
In reply to As Marc just pointed out:… by jeetee
Thank you but Iam trying to make a plugin for my school witch takes selected notes and changes durations of the notes randomly.
it should scan first note, change its duration and put it as a first segment then scan a second note change randomly duration a put it as a second segment. It should do it with all the notes pre-inserted by user.
I can change the first note duration but then all the subsequent notes get deleted and iam left off just with the single note duration change.
How do I fix it please ?
In reply to Thank you but Iam trying to… by kamilio141414
Take a look at the Duration Editor Plugin and perhaps even start from it.
In reply to Take a look at the Duration… by jeetee
Thank you
But i just want to know if there is a way in code to scan the note change its duration than move cursor to second note scan it change duration.
I can scan the first note but then all the next notes in score get deleted.
In reply to Thank you But i just want to… by kamilio141414
I meant for you to look at the code of that plugin as well, as it does exactly that; change note durations without affecting subsequent notes (it does so by expanding the measure when required and copy-pasting the subsequent stuff before lengthening).
In reply to I meant for you to look at… by jeetee
I have been trying to figure it out but iam lost.
Do you know which line of codes deal with it in that qml file ?
In reply to I have been trying to figure… by kamilio141414
The actual duration changes are done in
setElementDuration
(https://github.com/lgvr123/musescore-durationeditor/blob/master/duratio…).In reply to I have a for example 2 notes… by kamilio141414
It's not clear what you are trying to change it to or how you'd see a plugin helping. But as mentioned, the existing paste half/double durations commands work great for turning a series of quarter notes into eighths or halves or whatever. Or if it's just a single note you wish to change or a few notes here and there, see the existing Duration Editor plugin.