Why are wav2sketch converted files substantially larger than the input wav?

Electric Potato

Well-known member
I know it's 2024 but I still have projects that opt for AudioPlayMemory and I was wondering why the cpp file generated by wav2sketch is always bigger than the actual wav that it's encoding. Like if I have a 16bit/44.1kHz sample with a size of 23KB, it produces a cpp file that's 32KB using 8bit ulaw encoding and 64KB using 16bit PCM encoding. I would've assumed that since the wav itself is 16bit PCM encoded, the resulting file would always be smaller if anything, since it discards the wavs header.
 
why the cpp file generated by wav2sketch is always bigger than the actual wav that it's encoding

Each byte of raw data becomes several characters of text in the source code. When you simply view the source, you can read the text and see it's multiple chars per actual raw byte.

When compiled, the .o files have considerable metadata about the original source code, and so does .elf format, so they are also larger than the raw binary data.

The final .hex output is also ascii encoded and also has addresses and checksums (you can open and view with any text editor) so the file size is much larger than the actual raw data it represents.
 
Back
Top