Enhance TimeSig object to have methods to return numerator and denominator

• Oct 9, 2011 - 23:58

I am writing a plug in and want to export the Time Signature.

Unfortunately the TimeSig object only provides a method to return type - "an internal value describing the time signature. The only usage of this property is to copy the time signature from one TimeSig object to another"

There is a method to change the time signature:
change(int numerator, int denominator)

Could you add two methods, numerator and denominator to return the
numberator and denominator of a time signature? For example, 6 and 8 for the 6/8 time signature.

As a workaround, can you explain how to convert the internal method to a numerator/denominator time signature?

Documentation
http://musescore.org/en/plugin-development/timesig-object

Many thanks
Charles


Comments

In reply to by Marc Sabatella

Cool!

In the mean time, it looks like I can test the value of 'type' and then do a case/switch on that. For example, I am finding that 3/4 time is type = 196, 4/4 is 260 but 'common time' is 1073742084 ...

Any chance that those values will be stable until V2.0 comes out?

In reply to by pablocito

By looking in MuseScore 1.3 code, time signatures subtype has the following comment:
subtype() is coded as:
bit 0-5 denominator (n)
bit 6-11 nominator1 (z1)
bit 12-17 nominator2
bit 18-23 nominator3
bit 24-29 nominator4
bit 30 variation (alla breve etc.)

Plus these definitions:
TSIG_FOUR_FOUR = 0x40000104
TSIG_ALLA_BREVE = 0x40002084
and the method to retrieve the fraction is coded as:

Fraction getSig() const { return getSig(subtype()); }
static Fraction getSig(int st) {
return Fraction(
((st>>24)& 0x3f)
+ ((st>>18)& 0x3f)
+ ((st>>12)& 0x3f)
+ ((st>>6) & 0x3f), st & 0x3f);
}

Hope this helps.

Ciao,
ABL

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