Skip to content

MusicXML import: ignore sound elements without a tempo - #2570

Merged
stakira merged 1 commit into
openutau:masterfrom
ybai08:musicxml-sound-without-tempo
Oct 30, 2026
Merged

stakira merged 1 commit into
openutau:masterfrom
ybai08:musicxml-sound-without-tempo

Conversation

@ybai08

@ybai08 ybai08 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

MusicXML.MeasureBPM returns the tempo of the first <sound> it finds in a measure's directions, whether or not that <sound> has a tempo attribute. MuseScore writes <sound dynamics="..."/> for every dynamic marking, so:

  • every measure with a dynamic (and no tempo marking) gets a 0 bpm tempo marker in the imported project;
  • if a measure has a dynamic before a tempo change, the tempo change is dropped and 0 bpm is used instead.

The TimeAxis guard against zero bpm now stops these markers from producing NaN times, but they stay in the project's tempo list and the real tempo changes are still lost. This may be where the zero/NaN tempo in #2391 came from (MusicXML exported from MuseScore 4). I could not check that, because the reporter's file isn't attached.

Change: only use a <sound> whose tempo attribute is set and greater than 0. The MusicXML spec says a tempo of 0 means "prompt the user", so it is not a usable tempo either.

Test: MusicXMLTest.SoundWithoutTempoTest loads a small new fixture, sound-dynamics-without-tempo.musicxml. It has 100 bpm in measure 1, dynamics-only <sound> elements in measures 1 to 3, and a dynamic followed by 80 bpm in measure 3. Expected tempos: 100@0, 80@3840. Before the change they were 100@0, 0@1920, 0@3840. The fixture was written by hand, which is noted in Files/MusicXML/README.md because the other files there come from the MusicXML test suite.

Ran dotnet run --project OpenUtau.Test/OpenUtau.Test.csproj on macOS (arm64, .NET 10.0.12), rebased on b7c35b9: 709 total, 701 passed, 5 failed, 3 skipped. The 5 failures are timing tests (RenderViewTest x4, WaveformRefreshTest.CoalescesBurstsAndPostsPromptly) that time out the same way on unmodified master b7c35b9 in this environment, so they are not caused by this change. The 3 skips are live tests that need OPENUTAU_TEST_SINGERS, ENUNU_TEST_VOICE or OPENUTAU_BRIDGE_DISCOVERY. OpenUtau.UiTest was not run, and the change was not tried in the app UI.

MeasureBPM returned the tempo of the first <sound> in a measure's
directions, even when that <sound> had no tempo attribute. MuseScore
writes <sound dynamics="..."/> for every dynamic marking, so each
measure with a dynamic got a 0 bpm tempo marker, and a real tempo change
written after a dynamic in the same measure was dropped.
@stakira
stakira merged commit e26be81 into openutau:master Oct 30, 2026
3 checks passed
emeraldsingers added a commit to emeraldsingers/UtauV that referenced this pull request Oct 30, 2026
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

Successfully merging this pull request may close these issues.

2 participants