Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix importing WAV files with odd chunk sizes #85556

Merged
merged 1 commit into from
Dec 4, 2023

Conversation

bs-mwoerner
Copy link
Contributor

Fixes #85466.

The RIFF specification requires a padding byte to be written when a chunk size is not even. The current WAV importer did not include that byte when moving to the next chunk, so the import would fail (read a zero-length file) when the file contained a chunk with an odd size before the actual data chunk.

@akien-mga
Copy link
Member

CC @lawnjelly if you want to review and take inspiration to fix your own WAV importer :P

@akien-mga akien-mga modified the milestones: 4.x, 4.3 Nov 30, 2023
@akien-mga akien-mga added the cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release label Nov 30, 2023
Copy link
Member

@lawnjelly lawnjelly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm no expert in RIFF files but it does seem like chunks should be padded like this:
https://www.daubnet.com/en/file-format-riff

unused 1 byte present, if size is odd

@bs-mwoerner
Copy link
Contributor Author

Ah, yes, I could have quoted a source. I got my info from Wikpedia: https://en.wikipedia.org/wiki/Resource_Interchange_File_Format

All chunks have the following format:

  • 4 bytes: an ASCII identifier for this chunk (examples are "fmt " and "data"; note the space in "fmt ").
  • 4 bytes: an unsigned, little-endian 32-bit integer with the length of this chunk (except this field itself and the chunk identifier).
  • variable-sized field: the chunk data itself, of the size given in the previous field.
  • a pad byte, if the chunk's length is not even.

@akien-mga
Copy link
Member

Same email/account attribution issue on this PR :)

These require a padding byte not included in the chunk size.
@bs-mwoerner
Copy link
Contributor Author

Merci. :)

@akien-mga akien-mga merged commit 6cfb3f6 into godotengine:master Dec 4, 2023
15 checks passed
@YuriSizov
Copy link
Contributor

Cherry-picked for 4.2.1.

@YuriSizov YuriSizov removed the cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release label Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WAV file that works everywhere else is silent in Godot
5 participants