QML Plugin - How do I get the tempo
Hi.
Are the TEMPO_TEXT elements accessible through the plugin API for MuseScore 2.0?
I'm writing a plugin to export scores into the Ultrastar format. To do that, I need the tempo of the score.
I understand that there can be multiple tempo markers in a score, but I can't find a single one in the score.
As I understand it, the tempo markers should be in elements of type TEMPO_TEXT, but I haven't been able to find any in the score when using a cursor to step through the score.
I am using a copy of MuseScore that identifies itself as 2.1.0 - I checked out the source code a couple of days ago and built it.
Comments
TempoText is accessible. it offers the properties tempo (beats (1/4) per second) and followText (true/falase)
Try the help in the plugin editor
In reply to TempoText is accessible. it by Jojo-Schmitz
Yep, I see it there in the documentation. Unfortunately, it doesn't say what it is attached to. I've run through all the tracks in the score and searched for an elemement of type TEMPO_TEXT, and didn't find one although I know for sure it is there.
I've checked on various objects in the score (measures, chords, notes, segments) and still couldn't find it.
In reply to Yep, I see it there in the by Joseph Eoff
I don't know if/how it might be exposed in plugins, but I can tell you that tempo text elements, like other text elements, are annotations on segments.
But FWIW, having to search through tempo texts to understand the tempo is not ideal. It would be better if you could access the Score::tempo(int tick) method that returns the tempo for any given tick. But it looks like this is not exposed.
In reply to I don't know if/how it might by Marc Sabatella
For what I'm working on, I don't need the tempo for every tick. Ultrastar assumes one tempo for the whole score.
Since I couldn't find the temp text, I punted and put an entry field on the export form. I'll look into the annotations on the segments the next chance I get and see if I can find it there.
In case anyone is interested, I've attached the the current version of my UltraStar export plugin.
It is functional though ugly, and does some odd things to the exported lyrics.
Duet export is implemented, but not tested.
I work under OpenSuse Linux, so no idea whether this will work under Windows.
This plugin requires MuseScore 2.1.0 or better.
In reply to For what I'm working on, I by Joseph Eoff
Where does that awfully specific number 490.96154 come from?
(I have a user request that is related to the problematic…)
In reply to Where does that awfully… by mirabilos
It was a bug, fixed in https://github.com/JosephEoff/MuseScore_UltraStar_Exporter/pull/8 (and later changed to support high accuracy mode as per https://github.com/JosephEoff/MuseScore_UltraStar_Exporter/issues/9 )
480 was the number of ticks for a quarter note
In reply to It was a bug, fixed in https… by jeetee
Ah okay.
And indeed.
High values are needed and possible.
All Text elements are annotations to a segment and can be retrieved like this:
However, it must be noticed, that the cursor might skip such segments if there's no element in the given track. To make sure one gets all the texts in the score, one might need to loop over segments. This is a restriction of the current cursor.
Regarding Score::tempo(tick): I'd vote for a Cursor.tempo property.
In reply to All Text elements are by heuchi
That might be the explanation. I looped the cursor over the tracks.
I'll try iterating on the segments and see what comes of it.
In reply to All Text elements are by heuchi
+1 for cursor.tempo(tick)
In reply to All Text elements are by heuchi
That got it. Now the tempo is set automatically in the exported file - I took the entry field out of the form.
In reply to All Text elements are by heuchi
Cursor.tempo implemented in master by https://github.com/musescore/MuseScore/pull/2363