Getting number of strokes in tremolo?

• Nov 21, 2024 - 19:38

Does anyone know of a way of getting the number of strokes in a Tremolo element?

I've experimented with the following properties:
1) userName — returns 'Tremolos' (irrespective of number of strokes)
2) symbol — returns undefined
3) name — returns 'Tremolo'
4) subtype — returns undefined

The only thing that I can see that changes depending on the number of strokes is the bbox.height value, but that seems like a very hacky way to work out the number of strokes!


Comments

Neither the element in question, nor its 'parent' 'chord', nor even the 'stem' element, appear to have any properties associated with strokes. So, most likely, like many other things, the plugin developer cannot access it.

In reply to by yonah_ag

I am a professor of composition at a university in NZ — I am writing a Musescore plug-in that flags the most common music notation errors that my students make. One error they often make is writing a tremolo with the incorrect number of strokes for their particular situation.

In reply to by michaelnorris

As you have already discovered, the parameter you are interested in is 'subtype', but it is not accessible. I think the only way is to follow yonah_ag's advice and rewrite the plugin in the form of text analysis of an mscx file, in which all the parameters are accessible.

In reply to by ILPEPITO

I have found that MusicXML is easier to process than MSCX even though both are similar xml files. An alternative is to write a hybrid plugin. I have done this before after getting to 80% completion only to find that the MuseScore plugun api didn't supply what I needed to for the last 20%. (Example: access to slur details whilst stepping through segments to build a score map).

When you only need specific elements from MusicXML to complete a score map you don't have to do a full parse but can shortcut to what you need by means of some regex.

In reply to by yonah_ag

Yup — here's a quick snippet of how I do it:

property var isSlurred: false
property var nextSlurStart: 0
property var currentSlurNum: 0
property var currentSlur: null
 
var elems = curScore.selection.elements;
for (var i = 0; i<elems.length; i++) {
     var e = elems[i];
     var staffIdx = 0;
     while (!curScore.staves[staffIdx].is(e.staff)) staffIdx++;
     if (e.type == Element.SLUR) slurs[staffIdx].push(e);
}
// .... later in the code ... //
var currentSlurNum = 0;
var readyToGoToNextSlur = false;
if (currentSlurNum < numSlurs) {
     if (currentSlur == null) {
          readyToGoToNextSlur = true;
     } else {
          if (currTick > currentSlurEnd) {
               currentSlur = null;
               isSlurred = false;
               currentSlurNum ++;
               if (currentSlurNum < numSlurs) {
                    nextSlurStart = slurs[currentStaffNum][currentSlurNum].spannerTick.ticks;
                    readyToGoToNextSlur = true;
               }
          }
     }
}
if (readyToGoToNextSlur) {
     if (currTick >= nextSlurStart) {
          isSlurred = true;
          currentSlur = slurs[currentStaffNum][currentSlurNum];
          currentSlurEnd = currentSlur.spannerTick.ticks + currentSlur.spannerTicks.ticks;
          if (currentSlurNum < numSlurs - 1) {
               nextSlurStart = slurs[currentStaffNum][currentSlurNum+1].spannerTick.ticks;
          } else {
               nextSlurStart = 0;
          }
     }
}

In reply to by ILPEPITO

I have a workaround for now, which is to get the height of the bbox, which changes depending on the number of strokes. However, this does not work for two-note tremolos, which can change their height depending on the slope. Still, it's better than nothing, and hopefully a future release will let us get the number of strokes.

In reply to by michaelnorris

Musescore4 seems to be going in the direction of reducing the chances of accessing element properties, so I'm not optimistic about your hope. The idea of ​​using bbox (the coordinates of the virtual space occupied by an element) makes sense, but it doesn't seem very reliable to me: I imagine it is also linked to the size of the score or staves, so you would have a plugin that doesn't work with particular settings of Musescore in this sense. Anyway, whatever you want: you can always tell your students to keep the default program settings.

In reply to by ILPEPITO

For two-note tremolos, I don't know how feasible it is, but (perhaps) you could calculate the distance 'y' between the notes and the difference between the 'bbox.height' of the two stems (if there are any), relate them so as to be able to trace the tremolo symbol used at a single standard independent of its inclination. It's just a working hypothesis.

In reply to by yonah_ag

I take the liberty of answering for the OP, because (perhaps) I understood the meaning of your question; I think you should read the chapter of the manual on tremolo to understand what we are talking about: the problem is not the tremolo with 2 strokes or 2, 3, 4 notes, but the two-note tremolo which is a different thing... I'm not sure I understand your question but I'm sure you're misunderstanding.

In reply to by ILPEPITO

OK, looks like my terminology was off. I have only come across tremolo which happens on a fixed pitch, (i.e. on a single string and fret number), as in Recuerdos de la Alhambra so I really meant "number of plucks". I didn't realise that tremolo across multiple strings was even possible and have trouble imagining how the picking pattern works.

In reply to by michaelnorris

In this post no one has ever talked about 'repeat' slash symbols, which are undoubtedly something else (if you mean the crossbars to repeat portions of measures). Equally undoubtedly, tremolos are also used (as well as indicating, for example, the typical mandolin technique) to save time and space, perhaps even in combination with the previous ones.
As I believe (and hope) you know well.

I too am curious to know what it could be used for. For yonah_ag: what you say is not always true. Tremolos are also used, for example, as an abbreviation symbol for repeated chords, and in that case it is not a matter of subjective interpretation.

To michaelnorris: you haven't seen my comment or are you no longer interested in knowing the 'magic parameter' to distinguish between one type of tremolo and another, contained in the plugin I have attached?

In reply to by michaelnorris

Let's not exaggerate, with more attention I would have noticed it earlier. I'll give you one more detail: the 'string' returned by the function is 'localized': I'm Italian and musescore provides it with the Italian musical lexicon. If your students have an OS with the same localization there is no problem, otherwise you would have a little more problem. Have fun.

In reply to by michaelnorris

Ingenious... However, I have to give you a disappointment. I don't know what can result from English strings, but I can tell you that in Italian strings there are no integers! This is, for example, what you find: 'Semicroma tra due note' or 'Biscroma nota singola'. Life is complicated... However, I do not think, in your case, that this will be a problem.

In reply to by ILPEPITO

I tried, out of curiosity, your code, just to know what I already knew. Changing the language (just 5: I don't have so much time to waste) in the preferences I discovered that: 1) in Italian, French and Spanish IT DOESN'T WORK (for the reasons I've already explained); 2) In addition to English, it also works in German. You can certainly recommend these two languages, or others that someone will want to discover...

In reply to by ILPEPITO

I would also add that, if you wanted to distinguish between the two types of tremolo, it would be very difficult to write a 'universal' routine: for each language you would have to set up (inevitably) a custom 'check'. And with this I close definitively on the subject.

In reply to by ILPEPITO

If in a plugin you could change MuseScore's language setting, you'd see these strings in whatever language you set to (so set to "en" to see the original strings rather than the translated ones).
Soemthing like setenv ("LANG", "en", 1) or putenv("LANG=en") might do

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