Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about measure duration not matching time signature #425

Open
Yikai-Liao opened this issue Feb 1, 2025 · 4 comments
Open

Question about measure duration not matching time signature #425

Yikai-Liao opened this issue Feb 1, 2025 · 4 comments
Assignees

Comments

@Yikai-Liao
Copy link

Yikai-Liao commented Feb 1, 2025

Hi Partitura team,

First off, thank you for creating and maintaining this library — it’s been very helpful!

I’m currently implementing my own MusicXML parser for symusic and noticed that Partitura determines each measure’s duration purely based on the actual note/rest durations (including <forward> and <backup>), rather than enforcing the nominal length implied by the time signature. As a result, measures in Partitura’s parsed output can end up shorter or longer than the “theoretical” bar length indicated by the <time> element.

Could you please share the design rationale behind this approach? Is the goal simply to preserve the literal MusicXML data (where some measures might intentionally or unintentionally underflow or overflow the expected time signature), rather than forcing them to match a strict bar length?

In my own parser, I’m running into scenarios where a measure’s cumulative note durations don’t match the stated time signature. I’m not sure whether I should:

  1. Force each measure to match the time signature by padding with rests or splitting up notes,
  2. Or follow Partitura’s lead and let measures have any duration that the input file dictates (including partial or overfilled bars).

I’d love to hear your insights or best practices on how to handle these “irregular” measures. Do you foresee any drawbacks to strictly enforcing the time signature length, or any edge cases that Partitura tries to accommodate with this design?

Thanks again for all your work on this project, and any guidance you can provide would be greatly appreciated.

Best regards,
Yikai Liao

@CarlosCancino-Chacon
Copy link
Member

Hi @Yikai-Liao,

Thanks for the question! As you say, the rationale behind this approach was to preserve the literal MusicXML data rather than forcing a strict duration. Actually, MEI also uses this way of representing the duration of a measure implicitly.

Our decision for computing the duration of a measure based on the notes rather than fixing a specific duration comes mostly from dealing with classical music, where these kind of measures are common. Besides incorrectly formatted MusicXML files, there are a few cases where that was the desired behavior (and in here, we need to remember that MusicXML was designed to display music in a visually correct way for musicians, rather than represent elements in a "musically" correct way 😅). A few of these cases are:

  1. "Cadenza" measures, where there are more notes than would fit in the measure given the time signature. In our case, we work a lot with classical music, particularly 19th century Romantic music, where there are "cadenza" measures with more notes (see example in Measure 77 in the attached score)

Piano_Concerto_No.3_in_D_Minor_Op.30-Рояль.musicxml.zip

  1. Split measures due to repeat signs. These cases are probably the easiest ones to handle systematically. Still, MusicXML counts split measures resulting from a repetition as different measures, This is a more general issue regarding the numbering of the measures. See e.g., the measure map proposed by Gotham et al.

Hope this helps!

BTW, we have also been discussing whether to add symusic/minimidi as a separate backend (in addition to our original Mido backend) to parse MIDI files more quickly in Partitura, so we might also ask you some questions in the future 😉

@CarlosCancino-Chacon CarlosCancino-Chacon self-assigned this Feb 3, 2025
@lzqlzzq
Copy link

lzqlzzq commented Feb 3, 2025

I observed these situations most:

  1. ad libitum: Where time signature technically has no effect, such as cadenza (as in your example) and some ornament (some ornaments tagged senze tempo as Nocturne). But there is no such marker in MIDI even MEI (I see MEI has explicit measure boundary instead of using time signature) to indicate this.
  2. anacrusi: This is a very common in classical music at the start (also at the end to fulfill the bar with the start), but also the absolute time for notes in incomplete measure is weird. Musescore will insert a time signature equals to the actual duration, for example the first bar is a quarter, then Musescore will insert a 1/4 time signature.
  3. notation workaround: At measure 2, 4/4 but bar duration is 4.5 quarters. I guess maybe the grace note have some problem for layout or playback, so they use normal notes. overflow.zip Musescore also inserts a time signature of actual duration, 9/8 for this example.

For the repatition problem, I think that is not important for musical meaning, it just simplify notation. Expand should be enough.

@gregchapman-dev
Copy link

I also see older (maybe originally mensural?) music with each vocal part having different time signatures (3/1, 6/1, 2/1, etc), and all the measures in all the parts have the same (short) duration, but some of the parts have many hidden barlines to make things look like they match the timesig. So the actual MusicXML measures in the parts with longer timesigs are consistently shorter than the timesig would have it.

I tried in many different projects (converter21, musicdiff, etc) to either force things to match the timesig, or assume things matched the timesig (for simplicity’s sake), and every time I had to stop doing that and properly handle things not matching, because scores often don’t work that way.

@lzqlzzq
Copy link

lzqlzzq commented Feb 4, 2025

I also see older (maybe originally mensural?) music with each vocal part having different time signatures (3/1, 6/1, 2/1, etc), and all the measures in all the parts have the same (short) duration, but some of the parts have many hidden barlines to make things look like they match the timesig. So the actual MusicXML measures in the parts with longer timesigs are consistently shorter than the timesig would have it.

I tried in many different projects (converter21, musicdiff, etc) to either force things to match the timesig, or assume things matched the timesig (for simplicity’s sake), and every time I had to stop doing that and properly handle things not matching, because scores often don’t work that way.

@gregchapman-dev Yes, that' s common in Medieval and Renaissance music, something like Mensural canons. But as far as I know, even in musicxml, we can acheive different time signature in different part only by adjusting layout information, like hiding barlines or so. And that doesn' t alter core musical information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants