lenmus / lomse

A C++ library for rendering, editing and playing back music scores.
MIT License
117 stars 28 forks source link

Beginning/end number of the measures in a system #382

Closed cecilios closed 1 year ago

cecilios commented 1 year ago

@npiegdon In discussion #377 it was requested information about how to get the beginning/end number of the measures in a system

This request is difficult to answer without referring to an instrument. Take into account that in polymetric music (music in which not all instruments have the same time signature) the measure number is not a common value for all instruments and, thus measure numbers in a system will depend on which instrument you refer to. For instance, in the typical example from Mozart's opera Don Giovanni, how many measures are in this system? two or three?

image

Thus, it is necessary to specify not only the system number but also an instrument. But assuming that your app will only display the piano part, and the remaining parts, if any, will be hidden, in your app iInstr will be always 0.

GmoBoxSystem* pSystem =  ...
int iFirstMeasure = pSystem->get_first_measure(iInstr);    //0..n-1, referred to current layout
int numMeasures = pSystem->get_num_measures(iInstr);

Important. Method get_num_measures() is not currently defined. But is is just to lines of code so I will add it in a coming PR.

Let me know if this solves your needs.

npiegdon commented 1 year ago

Well, that's terrifying. 😅

Having to specify an instrument is a good strategy and should work for my purposes. Thanks!

cecilios commented 1 year ago

PR #385 adds the get_num_measures() method.

cecilios commented 1 year ago

I am closing this issue as it appears to be resolved. If you believe things are still unresolved please let me know and I can reopen if needed.