Skip to content

When exporting audio, do not use oversize buffer; make OGG match piece duration#31679

Merged
RomanPudashkin merged 2 commits intomusescore:masterfrom
RMRattray:reduce-unused-export-audio-buffer
Jan 13, 2026
Merged

When exporting audio, do not use oversize buffer; make OGG match piece duration#31679
RomanPudashkin merged 2 commits intomusescore:masterfrom
RMRattray:reduce-unused-export-audio-buffer

Conversation

@RMRattray
Copy link
Contributor

@RMRattray RMRattray commented Jan 7, 2026

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, a vector<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.

  • I signed the CLA
  • The title of the PR describes the problem it addresses
  • Each commit's message describes its purpose and effects, and references the issue it resolves
  • If changes are extensive, there is a sequence of easily reviewable commits
  • The code in the PR follows the coding rules
  • There are no unnecessary changes
  • The code compiles and runs on my machine, preferably after each commit individually
  • I created a unit test or vtest to verify the changes I made (if applicable)

@Jojo-Schmitz
Copy link
Contributor

Rebase needed to fix the arm build

@RMRattray RMRattray force-pushed the reduce-unused-export-audio-buffer branch from 9beaa7a to f366362 Compare January 7, 2026 11:56
@RMRattray RMRattray force-pushed the reduce-unused-export-audio-buffer branch from f366362 to 62d811a Compare January 10, 2026 23:51
@zacjansheski
Copy link
Contributor

Tested on MacOS 15, Windows 11, Ubuntu 22.04.3. Approved

@RomanPudashkin RomanPudashkin merged commit 3b8819e into musescore:master Jan 13, 2026
12 checks passed
@github-project-automation github-project-automation bot moved this from Done to Needs porting in MuseScore Studio 4.7 Jan 13, 2026
@RomanPudashkin RomanPudashkin moved this from Needs porting to Done in MuseScore Studio 4.7 Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants