Getting number of strokes in tremolo?
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
Maybe try viewing in mscx or musicxml format.
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 Neither the element in… by ILPEPITO
I guess that the tremolo symbol is therefore just indicative and it's up to the player to provide the interpretation.
What do you it need if for?
In reply to What do you it need if for? 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 I am a professor of… 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 As you have already… 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 I have found that MusicXML… by yonah_ag
What slur details were you unable to access? I've managed to get most of them.
In reply to What slur details were you… by michaelnorris
When processing a score element by element to build a map the slurs are not found in tick sequence so getting the start and end tick of a slur is not so easy. This is simple in the MusicXML file.
In reply to When processing a score… by yonah_ag
Yes it is — you get the spannerTicks property which will give you the beginning and end tick of the slur.
In reply to Yes it is — you get the… by michaelnorris
Thanks, I'll have to check that out. I was looking only for the tick property but clearly should've looked a bit harder. I should be able to engineer out the MusicXML processing.
In reply to Thanks, I'll have to check… by yonah_ag
Yup — here's a quick snippet of how I do it:
In reply to Yup — here's a quick snippet… by michaelnorris
👌
In reply to As you have already… 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 I have a workaround for now,… by michaelnorris
If the data is available in the MusicXML then you can integrate this with your current plugin. Plugin code can write the MusicXML file and then read it into a variable for processing.
In reply to I have a workaround for now,… 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 Musescore4 seems to be going… by ILPEPITO
No, bbox does not change when the size of the score changes. Strange...but great news for you.
In reply to No, bbox does not change… 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 For two-note tremolos, I don… by ILPEPITO
Yes, I think there would be some kind of hack if I could be bothered!!!
In reply to Yes, I think there would be… by michaelnorris
Is this an ironic response? I apologize, but you are the one looking for unorthodox solutions when what yonah_ag suggests would seem much more logical.
In reply to Is this an ironic response?… by ILPEPITO
Sorry — what I meant was a) that the two-note tremolos are not super important for my plugin (the one-note tremolos were more important) and b) the algorithm for detecting two-note tremolos sounds complicated, and I just wish the API could save me 20 lines of code!
In reply to Sorry — what I meant was a)… by michaelnorris
It is certainly complex to develop, and it is not even sure that it can give appreciable results. I fully understand your point of view and apologize if I misunderstood the meaning of your answer.
In reply to I have a workaround for now,… by michaelnorris
Hang on!
If you can detect 3, 4, 5, ... note tremolos then can't you default to 2 note when it's none of the above? (or is there such a thing as a 1 note tremolo?)
In reply to Hang on! If you can detect 3… by yonah_ag
I'm talking about two-note or two-chord tremolo (https://musescore.org/en/handbook/3/tremolo) with the symbol placed between two notes (or two groups of notes). In fact the name 'tremolo' for this symbol is a bit reductive, I don't know in English but in Italian musical orthography books are more specific. In any case, I didn't understand your question.
In reply to I'm talking about two-note… by ILPEPITO
My question was to the OP.
Assumptions:
1) A one note tremolo does not exist.
2) The OP can already detect 3, 4, 5+ note tremolo by the box data.
Therefore any tremolo which is not 3, 4, 5+ notes must be a 2 note tremolo.
In reply to My question was to the OP… 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 I take the liberty of… 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 As you have already… by ILPEPITO
Can you please post an example of this? I also have never heard of it.
)
In reply to Can you please post an… by xavierjazz
To xavierjazz: who and what is this request addressed to?
In reply to To xavierjazz: who and what… by ILPEPITO
To you, regarding "abbreviation symbol for repeated chords'.
In reply to To you, regarding … by xavierjazz
Tremolo slashes and the 'repeat' slash symbol are similar, but not the same.
In reply to Tremolo slashes and the … 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.
In reply to To you, regarding … by xavierjazz
To xavierjazz: the first one that came to mind
Villa-Lobos - Etude no 4
In reply to The first one that came to… by ILPEPITO
An example of a two-note tremolo:
Beethoven - piano Sonata op 13
In reply to The first one that came to… by ILPEPITO
So each chord is repeated? I don't understand. :)
In reply to So each chord is repeated? I… by xavierjazz
Take a music theory course...or consult Wikipedia :)
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.
In reply to I too am curious to know… by ILPEPITO
Thanks for the info. I did not know that.
Hey michaelnorris, I think I found something interesting: try selecting a two-note (or even single-note) tremolo, press the button, and then go see what the 'console' shows.
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 To michaelnorris: you haven… by ILPEPITO
Sorry — I've been busy!!! Just checking your code now...
In reply to To michaelnorris: you haven… by ILPEPITO
Oh wow — nice find!!! You're a hero!
In reply to Oh wow — nice find!!! You're… 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 Let's not exaggerate, with… by ILPEPITO
The code below, however, extracts the number and ignores the string, so localization doesn't matter
In reply to To michaelnorris: you haven… by ILPEPITO
Here's some code for converting this into number of strokes:
In reply to Here's some code for… 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 Ingenious... However, I have… by ILPEPITO
Haha, oh that sucks! Just when you thought you had it figured out...
In reply to Haha, oh that sucks! Just… by michaelnorris
Eh eh eh... it is impossible to be able to imagine everything. But is localization so important? I don't think so...
In reply to Eh eh eh... it is impossible… 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 I tried, out of curiosity,… 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 I tried, out of curiosity,… by ILPEPITO
I wonder whether plugins could (temporarily) swicht to another language?
In reply to I wonder whether plugins… by Jojo-Schmitz
To answer you, I should better understand what you are wondering. In this post we discussed a descriptive 'information' (a string) about tremolos, which is subject to change with the change of language. In other situations, you would have to see case by case...
In reply to To answer you, I should… 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)
orputenv("LANG=en")
might doIn reply to If in a plugin you could… by Jojo-Schmitz
This is an interesting consideration, especially (if I need it) for the OP. I write plugins essentially for myself and I'm not directly interested in 'localization' problems: when (and if) this need arises I'll try to experiment. Do you think you'll try?
In reply to This is an interesting… by ILPEPITO
In the case in question (this post) if I had to write an algorithm to interpret the 'information'. I would simply adapt it to my language...
In reply to If in a plugin you could… by Jojo-Schmitz
Ah, I forgot that for you OP is something else, but I think we understood each other...