Skip to content

Expanded multimeasure rests can exceed the exported meter #215

Done

Description

@birchb

I’m Birch Browning. Codex, an AI agent working on my behalf, ran these tests and helped prepare this report. I confirmed that MuseScore opened the real-score output without warnings.

On HOMR main at 33dd138, using checkpoint 509, a normal run on a real oboe part exported an opening 3/2 meter and expanded a multimeasure rest into measures lasting seven quarter notes each. The exported meter calls for six. The printed meter and rest count were also misrecognized; those are separate from the mismatch within the MusicXML. We cannot share the copyrighted part publicly.

A small exporter-level reproduction supplies a timeSignature/2 marker, rest_3m, and a following seven-quarter-note measure. It produces 2/2 with each expanded rest lasting five quarter notes instead of four. The reproduction and an original mixed-meter example are available here: https://gist.github.com/birchb/d351bba623d906635333771e91f0a170.

The existing multirest test checks the expanded measure count and rest elements. Could it also check that each rest duration matches the exported time signature?

Activity

  1. liebharc commented on Nov 17, 2026

    @liebharc
    Owner

    example.ly is a separate, original LilyPond 2.26.0 mixed-meter example. Rendering it and running HOMR exposed missed meter changes but did not reproduce the rest-duration mismatch. It is included as recognition context, not as the reproduction input.

    Let me summarize:

    1. You have an issue with multimeasure rests, but you can't share the image
    2. Instead of sharing the image, you generate another image and then add a note that the image doesn't even reproduce this issue?

    Would you understand if I call this confusing and wonder why I should spent my personal free time to look at this in more detail?

    I can confirm that the image shows an issue with how homr deals with time-signatures. And I suspect that your issue with multi measure rests is real. I still consider to just close this issue for now and wait until the case comes up again in an issue which is better documented.

  2. birchb commented on Nov 18, 2026

    @birchb
    Author

    I’ve attached a full-page scan that reproduces the duration mismatch. It’s the Horn II part from Mozart’s Serenade K.388, printed page 3 (PDF page 11 of IMSLP file #52536, listed as public domain). The image was rendered at 200 dpi without cropping or altering the notation.

    With HOMR commit 83130ba and checkpoint 588 explicitly selected, the output declares 1/4 with eight divisions per quarter note. Each expanded rest in MusicXML measures 105–124 has duration 12, where a full 1/4 measure requires 8. Three fresh runs produced identical MusicXML. I’ve included the unmodified output and the reproduction script. Codex ran and checked the tests on my behalf.

    I’m happy to help if further testing would be useful. I want to respect your time and keep the discussion focused, so please let me know what would be most helpful from here.

  3. liebharc commented on Nov 18, 2026

    @liebharc
    Owner

    Thanks a real scan really helps a lot. You say you attached a scan, but your issue has no attachment? I looked into some examples of IMSLP52536-PMLP40436-Mozart-K388.Horn.pdf and it displays multiple issues:

    • It uses two notations for multi measure rests, homr completely fails with one of them and barely recognizes the other one
    • As seen in the LilyPond example the time signature de-duplication removes time signatures simply on the value/denominator and ignores the number of beats/nominator
    • homr itself is limited to only detect multimeasure rests up to 10 bars

    Still it would be good to know exactly which page you mean so that we talk about the same thing.

    Each expanded rest in MusicXML measures 105–124 has duration 12, where a full 1/4 measure requires 8

    That sounds like you analyze the MusicXML directly and that you don't look at it via MuseScore? Or is this just how Codex processes the files?

  4. birchb commented on Nov 18, 2026

    @birchb
    Author

    Thanks for checking. The exact page is PDF page 11 (printed page 3), Horn II in E-flat. The attached PNG is that full page rendered at 200 dpi. Codex checked the durations directly in the unmodified MusicXML. The expected duration of 8 comes from the exported 1/4 meter and 8 divisions per quarter note. The file records 12 for each of the expanded rests.

    mozart-k388-horn2-p3

    homr215-reproduction.zip

  5. liebharc commented on Nov 18, 2026

    @liebharc
    Owner

    To resolve this issue likely two things need to be done.

    Time Signatures

    The quickest fix is to first build the number of beats / numerator before deduplication. A better fix would be to extend the vocabulary so that the transformer reads the number of beats as well. OCR could help here as well, but it might be beneficial to keep this info in the transformer as it's important for the rhythm.

    Multimeasure rests

    The transformer really seems to struggle there. The example shows two styles of multirests (which illustrates again how important images are). One is likely not even in the training data. The second style is present, but only occurs rarely so that the recognition rate remains poor. I wonder if the best approach would be to define a single token for all multimeasure rests and then use OCR to find the number. That would be a new approach.

    Both aren't easy to do and both need retraining. It could take a while until this issue gets resolved. I'll also add the help wanted tag in case there is someone who can dedicate time right now.

  6. added
    help wanted
    on Nov 18, 2026
  7. birchb commented on Nov 23, 2026

    @birchb
    Author

    Thanks for putting together PR #240. I had Codex compare the branch (9b65603) with its base (13f7a15) on the full Mozart Horn II scan and the first page of the unBroken oboe part. Each comparison used the same checkpoint on both revisions. We tried both 588 and the branch default, 566. PR #240

    • Mozart Horn II. The base run with 588 reproduced the original MusicXML byte for byte. With PR Read time signature numerators and multirest counts with a digit CNN #240, both checkpoints read all six printed multimeasure-rest counts correctly. The two Trio rests, printed as 14 and 15 measures, expand to 29 measures of three quarter notes each, matching the exported 3/4. The duration mismatch from Expanded multimeasure rests can exceed the exported meter #215 is gone on this scan.
    • Oboe. With 588, the branch got all five rest counts right, including the seven-measure rest that the base read as two. With default 566, it got four of five and still missed the three-measure rest at mm. 4–6. Both checkpoints export 2/2 where the score prints 4/2 at m. 25, so the two rest measures there last four quarter notes each instead of eight.

    The exported pitch sequence and pitched-note durations were identical between base and branch for each checkpoint on both pages. The public-domain Mozart scan and original reproduction are attached above. Mozart scan and reproduction

  8. liebharc commented on Nov 24, 2026

    @liebharc
    Owner

    Thanks. Let's focus on runs that are on main. 588 has not been merged, for reasons.

    I would summarize it as follows: the change works well for the Mozart piece you shared, and it also improves the oboe piece. However, two issues remain in the oboe piece. Is that correct?

    Further progress on the oboe piece will likely be hard, as I can only guess at what else goes wrong. I think we have two options:

    • Can you share another piece that shows a similar error to the one in the oboe piece?
    • Or can you try to open a PR yourself that fixes the remaining two errors?

    Just please ask Codex to focus on the important information; it still confuses me a lot :). Thanks.

  9. birchb commented on Nov 25, 2026

    @birchb
    Author

    Here’s a small original example I can share. With checkpoint 617, current main (0d47667) reads the printed 4/2 at measure 3 as 2/2. PR #240 (d8c02be) reads 4/2 correctly on the same PNG. The branch still reads 2/2 at the comparable change in the oboe scan, so this attachment reproduces the error on main only.

    4-2-reproduction
  10. liebharc commented on Nov 25, 2026

    @liebharc
    Owner

    That doesn't help much then as #240 works correctly for this example. So it's similiar to the case which we fixed based on the Mozart scan. What we however would need is something which tells us why even #240 doesn't work in the two cases of your oboe piece.

    Perhaps another angle: What goal do you have with this issue? If it would be just about the oboe piece then you could have for sure fixed these mistakes already yourself in the music xml. Do you have a larger collection of sheet music which you need to get digitized?

  11. birchb commented on Nov 25, 2026

    @birchb
    Author

    My goal is to convert scanned instrumental parts into editable notation with less manual cleanup. Here’s a small excerpt from the oboe part itself. With checkpoint 617, #240 reads the printed 4/2 at m. 25 as 2/2 on the full page and as 4/4 on the attached crop. In both cases it gets the two-measure rest count right, but each rest measure lasts four quarter notes instead of eight.

    short
  12. liebharc commented on Nov 25, 2026

    @liebharc
    Owner

    #240 contains another commit which should fix this

  13. birchb commented on Nov 26, 2026

    @birchb
    Author

    Thanks—the new commit fixes the attached crop. On the full oboe page, the digit reader still gets no candidates at m. 25 after staff-line removal and filtering. I tested a local fallback that removes long horizontal lines when the first pass can’t read both digits. It recovered 4/2 on the full page, gave both rest measures eight quarter notes, and preserved the return to 2/2 at m. 27. I’ve only tested it on a few inputs so far. Would a small PR for that fallback be useful?

  14. liebharc commented on Nov 26, 2026

    @liebharc
    Owner

    #240 has another change which should help. Your idea should work, just that from experience the models can deal better with noise and bad images so I first wanted to see if a model improvement helps (and here the model is the digit reader). Let me know how it goes.

  15. birchb commented on Nov 26, 2026

    @birchb
    Author

    Thanks—the new number reader fixes the full oboe page with checkpoint 617. At m. 25 it now reads 4/2, gives each of the two rest measures eight quarter notes, and returns to 2/2 at m. 27. The posted crop still works, and Mozart still gets all six multimeasure-rest counts right. I didn’t use my local fallback.

  16. liebharc commented on Nov 27, 2026

    @liebharc
    Owner

    Good to hear that, hope that helps you with your oboe project!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions