How do I get staffIdx and tick information for Articulation, Arpeggio, Dynamics, etc?

• May 18, 2023 - 16:10

In order to get their mearsure and beat. And staffIdx

da.png


Comments

In reply to by davil123

For dynamics you can use segment.annotations:

var segment //the segment to view
for (var i in segment.annotations) {
  if (segment.annotations[i].type == Element.DYNAMIC) {
    console.log(segment.tick)
    //do code
  }
}

unfortunately i havent yet found an easy way to access articulation or arpeggios, without selection. here is my workaround:

cmd('select-all')
for (var i in curScore.selection.elements) {
  if (curScore.selection.elements[i].type == Element.ARTICULATION) { // or other element
    console.log(curScore.selection.elements[i].parent.tick) //parent of articulation is an Element.CHORD
    //do code
  }
}
curScore.selection.clear() //optional, revert selection

In reply to by davil123

Actually one shorter way I have, to reduce the number of checks:

for (var i = 0; i < curScore.nstaves; i++) {
  cursor.rewind(Cursor.SCORE_START)
  cursor.staffIdx = i
  while (! cursor.element) {
   cursor.next()
  }
  var staff = cursor.element.staff //the staff element type
}

like this you can quickly check the staff element type of the cursor, and then you can compare it to the staff of any other elements.

In reply to by XiaoMigros

But for plugins alone, Jianpu has already been completed, and the remaining work is designed by Deakon because I am not aware of the specific requirements of Jianpu in China. It is worth mentioning that since Deakon does not have a Mac computer, the Mac version of the plugin will be indefinitely delayed

In reply to by davil123

That could be very useful. It is using the same Qt that I am but without all the issues. The main difference is that it uses the RowLayout container control. I'm inclined to throw away my UI and start again. I did originally use GridLayout but removed it for more control. Little did I know the hassle that this would cause me.

In reply to by XiaoMigros

We have discussed before that if a plugin is completed, it will definitely not be used for commercial purposes. However, if the plugin is sold by someone else after completion, it will be very uncomfortable. Deakon once told me that a Sibelius notation plugin sold for over 700 RMB! I don't know if it's true.

In reply to by XiaoMigros

Re: XiaoMigros • May 18, 2023 - 16:28
"unfortunately i havent yet found an easy way to access articulation or arpeggios, without selection. here is my workaround:

cmd('select-all')
for (var i in curScore.selection.elements) {
if (curScore.selection.elements[i].type == Element.ARTICULATION) { // or other element
console.log(curScore.selection.elements[i].parent.tick) //parent of articulation is an Element.CHORD
//do code
}
}"

I don't seem to be able to use the curScore.selection.selectRange method instead of cmd('select all') to set a selection range for this type of processing. Any idea why not?

It appears from the plugin API documentation that articulation elements are not directly exposed for use in plugin code. This is an inconvenience in my current development. The only place that I have been able to process them, (e.g. to detect staccato dots), is via the MSCX file format but this leads to a plugout rather than a plugin. (A plugout has full access to absolutely everything in the score.) So I think that we are limited to working out an articulation's tick as explained above.

In reply to by davil123

That's a very interesting plugin since it has no pluginType. It also uses an older version of Qt, which I had to move away from because of the issue regarding dock type and dropdown boxes, so it appears that the issue doesn't happen for plugins with no type.

Does that plugin have all the elements that you need? You could reverse engineer them for your design, using Qt's online documentation for clarification where needed.

The plugin section of the Musescore forum unfortunately doesn't always show a screenshot for each plugin so it's a case of "download-install-safetycheck-try".

In reply to by XiaoMigros

Unfortunately, even with the newer version of Qt, this UI misbehaves when it's a docked plugin.
You can see that the dropdown list is rendered outside of the dock area and on the Windows desktop!

Dropdown.png

If it runs as a dialog plugin then it's fine but dialogs do not stay on top of the score! I'll have to decide on the best compromise.

In reply to by yonah_ag

yes, for example:

cmd('select-all')
for (var i in curScore.selection.elements) {
  var element = curScore.selection.elements[i]
  if (element.type == Element.ARTICULATION && element.symbol.includes("articStaccato")) {
    //do code
  }
}

note that the symid enum is accessible but not exposed in mu4, meaning that it wont work as expected there

In reply to by davil123

This should be possible in Qt / MS3 so I would expect no less with the Qt shipped with MS4. You will need to detect which option is selected in order to set a specific colour. Alternatively draw a filled circle in the required colours but only make it visible when the option is selected, (but this starts to get quite complex.)
https://doc.qt.io/qt-6/qml-qtquick-controls2-buttongroup.html#checkedBu…

You could also use predefined images for the indicator.
See https://doc.qt.io/archives/qt-4.8/stylesheet-examples.html#customizing-…

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