Skip to content

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
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