Center horizontally on notehead

• Jan 30, 2022 - 19:48

I'm working on a very basic musica ficta plugin. I'm still learning the API, but my efforts so far are attached. It does not parse more than one accidental yet and does not have any error detection.

I need help figuring out how to get a precise Xoffset to center the accidental horizontally every time. I posted on the support forum (https://musescore.org/en/node/328913) looking for a way to center an accidental, but I think it's more appropriate here. What's the best way to calculate the width of a notehead and then convert that to staff spaces? I also need to account for the original spacing between the notehead and the accidental. Would I use the horizontal dimensions of the bbox?

Thanks for any help!

Attachment Size
musicaFicta.qml 764 bytes

Comments

This gets pretty close, but not quite exact in all cases (see the sharp over the C in the screenshot). It doesn't look good on whole notes though.

var accidentalWidth = ficta.bbox.width;
var noteWidth = ficta.parent.bbox.width;
targetOffsetX = (noteWidth/2)+(accidentalWidth);

Attachment Size
xOffsetTest.png 12.36 KB

In reply to by jonarnold

I think I figured it out after I found the posX property:
var positionX = ficta.posX;
var noteWidth = ficta.parent.bbox.width;
var accidentalWidth = ficta.bbox.width;
ficta.offsetX = (noteWidth-accidentalWidth)/2-positionX;

This works great except that when I make the accidental small, all of these numbers are no longer accurate. Can I retrieve the small note percentage from the style properties, or is it possible to calculate the widths and positions after the small property change has been set?

In reply to by Jojo-Schmitz

I've just started using Musescore and I do a lot of work with renaissance music and would find this plug in very useful. However, I do not understand what I need to do and would appreciate a talk through of how to add it so that I can use it. Many thanks.

In reply to by lindabarlow181

Hi. I'm no expert, but I successfully got this to work and use it a lot.
The best place to start is here https://musescore.org/en/handbook/4/plugins which shows how plugins work and how you install them.
Once it's installed into your MuseScore you can, as mentioned below, assign a keyboard shortcut to the plugin so that you can just tap your chosen key and the ficta accidental repositions to above the note. https://musescore.org/en/handbook/4/keyboard-shortcuts

If you're still stuck, let me know!
All the best
Ned

In reply to by lindabarlow181

I'm glad it will be useful to you! As another user said, see instructions at https://musescore.org/en/handbook/4/plugins. I wanted to comment here to make sure you see the latest version at the plugin page: https://musescore.org/en/project/musicaficta . This forum post has some old versions from when I was still figuring out how to make it work.

If you do a lot of renaissance music, you may also find my ligature bracket plugin helpful, although that is more easily accomplished in Musescore 4 by default: https://musescore.org/en/project/ligaturebracket

In reply to by jonarnold

Many thanks to all. This works very nicely!
I'm guessing there's a way of creating shortcut to use it - at the moment I'm going Plugins-Composing/Arranging tools - MusicFicta each time I make a change. Can I add it to a palette or right-click?

My method on editorial accidentals, for what it's worth, is:
(#) = it's obviously a sharp, but wasn't in the manuscript for clear reason (implied by lack of barline in original etc). Performer: trust me
[#] = my opinion is that it should be a sharp, as it's a sharp in another part, or intuitively needs to be a sharp to make musical sense of the phrase/harmony, or it's a typo/error in the part. Performer: trust me, but I may be wrong, and I'm signalling I've made a choice here
ficta # = an editorial decision based on the somewhat conflicting rules of ficta. Performer: take it or leave it, according to your own interpretation of ficta!

Enjoying using MS4 enormously, after many years of Sibelius.
Ned

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