| #ifndef _WAV_HEADER_H_ |
| #define _WAV_HEADER_H_ |
| /* |
| * Format of WAVE (.wav) files. This is a minimal definition and |
| * ignores externsions as well as other RIFF variants. |
| * Based upon ccrma.stanford.edu/courses/422/projects/WaveFormat/ |
| * |
| * Copyright (C) 2015 Nest Labs. All rights reserved. |
| * |
| * This program is free software; you can redistribute it and/or modify |
| * it under the terms of the GNU General Public License version 2 as |
| * published by the Free Software Foundation. |
| * |
| * This program is distributed in the hope that it will be useful, |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| * GNU General Public License for more details. |
| * |
| * You should have received a copy of the GNU General Public License |
| * along with this program; if not, write to the Free Software |
| * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| * |
| */ |
| |
| #include <stdint.h> |
| |
| #define RIFF_ID 0x46464952 /* 'RIFF' */ |
| #define WAVE_ID 0x45564157 /* 'WAVE' */ |
| #define FMT_ID 0x20746d66 /* 'fmt ' */ |
| #define DATA_ID 0x61746164 /* 'data' */ |
| |
| #define WAVE_FORMAT_PCM 1 |
| |
| typedef struct wave_header_s { |
| uint32_t chunk_id; |
| uint32_t chunk_size; |
| uint32_t format; |
| |
| /* "fmt " sub-chunk */ |
| uint32_t subchunk1_id; |
| uint32_t subchunk1_size; |
| uint16_t audio_format; |
| uint16_t num_channels; |
| uint32_t sample_rate; |
| uint32_t byte_rate; |
| uint16_t block_align; |
| uint16_t bits_per_sample; |
| |
| /* "data" sub-chunk */ |
| uint32_t subchunk2_id; |
| uint32_t subchunk2_size; |
| int16_t data[0]; /* variable size */ |
| } wave_header_t; |
| |
| #define WAVE_HDR_SIZE sizeof(wave_header_t) |
| |
| #define PCM_CHUNK_SIZE 16 /* XXXehs: redo with offsetof? */ |
| |
| #endif /* _WAV_HEADER_H_ */ |