Odin SolutionsOdin Solutions

🎵

It's in the Sound

Week 17, 2026

All Solutions

Simple WAV Header struct | greenya | Odin Solutions

package main import "core:fmt" import "core:strings" WAV_BYTES := #load("sound-message.wav") WAV_Head :: struct #packed { _: [24] u8, sample_rate: u32, _: [12] u8, data_size: u32, } main :: proc () { head: ^WAV_Head = cast (^WAV_Head) raw_data(WAV_BYTES) fmt.printfln("File size\t: %v", len(WAV_BYTES)) fmt.printfln("Data size\t: %v", head.data_size) fmt.printfln("Sample Rate\t: %v", head.sample_rate) sb := strings.builder_make() step := int(head.sample_rate) / 10 for i := size_of(head^); i < int(head.data_size); i += step { strings.write_byte(&sb, WAV_BYTES[i]) } fmt.println("----[ MESSAGE ]----") fmt.println(strings.to_string(sb)) fmt.println("-------------------") }