Fix IndexOutOfBoundsException in MetronomeInter when equalIndex is 0#894
Merged
hbitteur merged 1 commit intoAudiveris:developmentfrom Mar 25, 2026
Merged
Conversation
When OCR reads a tempo marking where the note symbol is in a separate word before "=" (e.g. "♩ = 100"), equalIndex can be 0. The code at line 942 then tries get(equalIndex - 1) = get(-1), which throws IndexOutOfBoundsException: Index -1. Adding a bounds check (equalIndex > 0) lets execution fall through to the existing reporter.alert() handler on line 948, which raises a ParsingException caught at line 985. Fixes Audiveris#812
cc6de93 to
6105048
Compare
Contributor
|
Thanks for your contribution
I'll take care of it when I return next week.
Le sam. 21 févr. 2026, 23:38, Matt Gibson ***@***.***> a
écrit :
… Summary
Fixes #812 <#812> — tempo
text like "♩ = 100" causes IndexOutOfBoundsException: Index -1 during the
TEXTS step when OCR places the note symbol in a separate word before the
"=" sign.
*Root cause:* MetronomeInter.create() at line 942 does line.getWords().get(equalIndex
- 1) without checking that equalIndex > 0. When "=" is the first word (equalIndex
== 0), it tries get(-1).
*Fix:* One-line bounds check:
// Before:if (ctx.charIndex == -1) {// After:if (ctx.charIndex == -1 && equalIndex > 0) {
The existing handler at line 948 (reporter.alert("Note characters not
found...")) already covers the "not found" case — it raises
ParsingException which is caught at line 985. No behavioral change for
the normal case where equalIndex > 0.
Testing
Verified with a hymnal PDF (Amazing Grace) that previously required
OCR-disabled fallback to complete:
- *Before patch:* TEXTS step crashes → no MusicXML output
- *After patch:* Completes on first attempt with OCR enabled, 141
<lyric> elements extracted correctly
------------------------------
You can view, comment on, or merge this pull request online at:
#894
Commit Summary
- 99a31c4
<99a31c4>
flatpak: use --persist instead of --filesystem for ~/.audiveris
- 757c5b0
<757c5b0>
flatpak: re-add "et al." to developer name
- 3676353
<3676353>
flatpak/flathub: Workarounds for flathubbot rejects
- 909ca30
<909ca30>
ScaleBuilder: Better checks on beam height
- a0e64bd
<a0e64bd>
ClustersRetriever: better vertical checks between staff lines
- a25d0cb
<a25d0cb>
Better check for link between rest and augmentation dot
- 60adfb2
<60adfb2>
Chord/Ornament relation accepts larger ordinate range
- da70b23
<da70b23>
First version of workflow publish-winget
- 01e8988
<01e8988>
Merge branch 'development'
- cc6de93
<cc6de93>
Fix IndexOutOfBoundsException in MetronomeInter when equalIndex is 0
File Changes
(4 files <https://github.com/Audiveris/audiveris/pull/894/files>)
- *M* app/src/main/java/org/audiveris/omr/sig/inter/MetronomeInter.java
<https://github.com/Audiveris/audiveris/pull/894/files#diff-a314ef2fcc711518082700855c9504510885368278752caa1608b23981a25e4f>
(2)
- *M* flatpak/dev/org.audiveris.audiveris.template.yml
<https://github.com/Audiveris/audiveris/pull/894/files#diff-1ff7a2ed08f9c1553b6bbd9dfe671dacaa1aa7037426302b5edaecc406159c42>
(2)
- *M* flatpak/flathub
<https://github.com/Audiveris/audiveris/pull/894/files#diff-70c096da61b84f4eb585876686c63ffee378f0a6193609eec7d12ac79dff300c>
(2)
- *M* flatpak/res/org.audiveris.audiveris.metainfo.xml
<https://github.com/Audiveris/audiveris/pull/894/files#diff-cbe456e1d8f54b4b216dacfe7c902577536a102c90f50c5cd894d6a54e5d2cf8>
(2)
Patch Links:
- https://github.com/Audiveris/audiveris/pull/894.patch
- https://github.com/Audiveris/audiveris/pull/894.diff
—
Reply to this email directly, view it on GitHub
<#894>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFIIGASSKLI5PDRIJBI27VT4NDM7RAVCNFSM6AAAAACV3RJIWCVHI2DSMVQWIX3LMV43ASLTON2WKOZTHE3TEOJXGYYDKMA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Contributor
|
@mgibson91 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #812 — tempo text like "♩ = 100" causes
IndexOutOfBoundsException: Index -1during the TEXTS step when OCR places the note symbol in a separate word before the "=" sign.Root cause:
MetronomeInter.create()at line 942 doesline.getWords().get(equalIndex - 1)without checking thatequalIndex > 0. When "=" is the first word (equalIndex == 0), it triesget(-1).Fix: One-line bounds check:
The existing handler at line 948 (
reporter.alert("Note characters not found...")) already covers the "not found" case — it raisesParsingExceptionwhich is caught at line 985. No behavioral change for the normal case whereequalIndex > 0.Testing
Verified with a hymnal PDF (Amazing Grace) that previously required OCR-disabled fallback to complete:
<lyric>elements extracted correctly