-
-
Save AlexKalinin/f696fe69315f82560aac62b2673b27e0 to your computer and use it in GitHub Desktop.
C Wav Header Struct
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// WAV header spec information: | |
//https://web.archive.org/web/20140327141505/https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ | |
//http://www.topherlee.com/software/pcm-tut-wavformat.html | |
typedef struct wav_header { | |
// RIFF Header | |
char riff_header[4]; // Contains "RIFF" | |
int wav_size; // Size of the wav portion of the file, which follows the first 8 bytes. File size - 8 | |
char wave_header[4]; // Contains "WAVE" | |
// Format Header | |
char fmt_header[4]; // Contains "fmt " (includes trailing space) | |
int fmt_chunk_size; // Should be 16 for PCM | |
short audio_format; // Should be 1 for PCM. 3 for IEEE Float | |
short num_channels; | |
int sample_rate; | |
int byte_rate; // Number of bytes per second. sample_rate * num_channels * Bytes Per Sample | |
short sample_alignment; // num_channels * Bytes Per Sample | |
short bit_depth; // Number of bits per sample | |
// Data | |
char data_header[4]; // Contains "data" | |
int data_bytes; // Number of bytes in data. Number of samples * num_channels * sample byte size | |
// uint8_t bytes[]; // Remainder of wave file is bytes | |
} wav_header; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment