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 FileSize for saving .wav #144

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

skitaoka
Copy link

@skitaoka skitaoka commented Apr 8, 2022

FileSize must be (file size) - 8 (except the size field itself and the chunk identifier).

cf. https://en.wikipedia.org/wiki/Resource_Interchange_File_Format

@skitaoka skitaoka changed the title Update encode.go Fix FileSize for saving .wav Apr 8, 2022
@MarkKremer
Copy link
Contributor

MarkKremer commented Oct 8, 2023

The change is correct but I think the referenced Wikipedia article is a little ambiguous about if they're referencing the filesize/RIFF chunk or subchunks.

This article from Microsoft is a bit clearer:

The RIFF header has the following form:

'RIFF' fileSize fileType (data)

where 'RIFF' is the literal FOURCC code 'RIFF', fileSize is a 4-byte value giving the size of the data in the file, and fileType is a FOURCC that identifies the specific file type. The value of fileSize includes the size of the fileType FOURCC plus the size of the data that follows, but does not include the size of the 'RIFF' FOURCC or the size of fileSize. The file data consists of chunks and lists, in any order.

So the filesize is the size of the whole file except the "RIFF" (4 bytes) and the fileSize itself (4 bytes). This agrees with what you've changed. :)


As an addition, this the decode function is broken too and should be fixed. I'm wrong :)

I'm bringing the new fork gopxl/beep up-to-date & I'll include these changes. Tnx!

MarkKremer added a commit to MarkKremer/beep that referenced this pull request Apr 6, 2024
Add speaker.Suspend and speaker.Resume
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