When exporting audio, do not use oversize buffer; make OGG match piece duration#31679
Merged
RomanPudashkin merged 2 commits intomusescore:masterfrom Jan 13, 2026
Merged
Conversation
Contributor
|
Rebase needed to fix the arm build |
9beaa7a to
f366362
Compare
f366362 to
62d811a
Compare
8 tasks
RomanPudashkin
approved these changes
Jan 12, 2026
Contributor
|
Tested on MacOS 15, Windows 11, Ubuntu 22.04.3. Approved |
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.
Resolves: not a numbered issue, but it can be observed that OGG files come out shorter than the WAVs and MP3s for the same piece. (And I should point out, it's a step towards a fix for #16496 )
In the file
soundtrackwriter.cpp, avector<float>was resized such that the number of elements was a multiple of the size of a float, which was peculiar. Experimentation suggested it was not necessary; the vector in question, the buffer of audio samples needed only contain the number of samples per channel times the number of channels. This shortened the allocated but unused memory by half, but revealed another issue:It became too short for the expectations of the oggencoder (and only the oggencoder), which expected a few more samples (to address a time-estimation issue). Exploring this revealed that an important function in the LibOpusEnc API was not called; the second commit resolves this time-estimation issue in a cleaner way.
Confirmed that it was able to export flac, mp3, ogg, and wav of two different pieces on both Windows 11 and Ubuntu 22; ogg duration and sound now matches that of the others.