Table
of Contents
- Introduction
- Wave RIFF Chunk
- Wave Format Chunk
- Wave Sound Data Chunk
- Example
1. Introduction
Wave files are an excessively flexible format for recording
sound. There are literally dozens of varients, some with
compressed sound, others without. However, this document
only describes
those flavors supported by AIBO.
Specifically:
- 8 bit data, 8KHz sample rate, PCM,
Monaural (single channel).
- 16 bit data, 16KHz sample rate, PCM,
Monaural (single channel).
Skitter can convert other PCM
(pulse-code-modulated) wave
files with different sample rates and/or stereo sound to be compatible.
2. Wave RIFF
Chunk
Wave files are composed of a RIFF header chunk, followed by format
& sound data chunks -- one of each.
struct riff_chunk_type { char signature[4]; // "RIFF" int chunklen; // length of format/sound chunks char rifftype[4]; // "WAVE" };
|
The RIFF header specifies the size of the format & sound data
chunks, and is useful for testing file validity. The length
field is not inclusive of the header itself.
3. Wave Format
Chunk
The format chunk specifies the data encoding, number of channels,
sample rate, bits-per-sample, and other information. There
can be exactly one format chunk per wave fule.
struct format_chunk_type { char signature[4]; // "fmt " int chunklen; // 16 bytes short format_tag; // 1 (PCM format, no compression) unsigned short channels; // 1 (monaural) unsigned long samples_per_sec; // 8192 or 16384 unsigned long average_bytes_per_sec; // 8192 or 16384 unsigned short block_alignment; // 1 (8 bit) or 2 (16 bit) unsigned short bits_per_sample; // 8 or 16 };
|
For PCM audio:
- format_tag must be 1
- channels should be 1 (for monaural) or 2 (for stereo)
- samples_per_sec is variable. Typically 8000,
11025, 16000, 22050, or 44100
- average_bytes_per_sec = (samples_per_sec * block_alignment)
- block_alignment = (channels * bits_per_sample)/8)
- bits_per_sample should be 8 or 16
For AIBO compatible 8 bit 8KHz PCM sound:
- format_tag = 1
- channels = 1
- samples_per_sec = 8000
- average_bytes_per_sec = 8000
- block_alignment = 1
- bits_per_sample = 8
For AIBO compatible 16 bit 16KHz PCM sound:
- format_tag = 1
- channels = 1
- samples_per_sec = 16000
- average_bytes_per_sec = 16000
- block_alignment = 2
- bits_per_sample = 16
4. Wave Sound
Data Chunk
The data chunk contains the actual sound data bytes.
There can be exactly one data chunk per PCM wave file.
struct data_chunk_type { char signature[4]; // "data" int chunklen; };
|
Following the chunk header, is the contiguous array of bytes (8 bit,
unsigned) or short integers (16 bit, signed).
5.
Example
RIFF
Chunk Header
Format
Chunk Header
Data
Chunk Header
000000: 52 49 46 46 85 01 00 00 57 41 56 45 66 6d 74 20 |RIFF....WAVEfmt | 000010: 10 00 00 00 01 00 01 00 40 1f 00 00 40 1f 00 00 |........@...@...| 000020: 01 00 08 00 64 61 74 61 61 01 00 00 77 83 6d 5f |....dataa...w.m_| 000030: 8b 8c 94 98 57 82 77 51 7d 48 a9 7c 71 ec 57 58 |....W.wQ}H.|q.WX| 000040: 6d 27 96 e4 b8 6b 66 52 5e ad 2a 68 a4 46 df b3 |m'...kfR^.*h.F..| 000050: 17 a8 6a 5f ff 83 1a 8d 65 47 d1 77 7c cb 85 97 |..j_....eG.w|...| 000060: 86 4e 60 75 a9 83 86 a1 61 a7 77 4a 96 72 9c 98 |.N`u....a.wJ.r..| 000070: 76 84 65 a9 61 84 9d 64 b1 75 9f a6 57 8e 4e 78 |v.e.a..d.u..W.Nx| 000080: a2 b2 ae 56 55 30 4c b0 ab a5 9c 68 95 81 75 6d |...VU0L....h..um| 000090: 5b 76 ad 9e 75 7e 40 51 c3 74 74 91 48 98 91 76 |[v..u~@Q.tt.H..v| 0000a0: 78 76 64 7b 99 8f 65 8a 73 50 9f 65 94 b0 60 72 |xvd{..e.sP.e..`r| 0000b0: 6c 64 8d 89 84 88 88 6e 75 50 69 7e 84 98 71 a5 |ld.....nuPi~..q.| 0000c0: 8c 7c 7c 43 8d 8a 6f 95 7d 7e 8c 86 7d 7e 6a 6f |.||C..o.}~..}~jo| 0000d0: 7e 82 8b 8d 6a 6f 91 77 8f 91 79 86 7d 81 89 76 |~...jo.w..y.}..v| 0000e0: 5e 82 86 96 99 60 72 67 7e a3 96 94 7f 69 5a 68 |^....`rg~....iZh| 0000f0: 6b 95 93 8d 8f 6f 7f 6e 70 9c 7d 9a 86 71 83 6b |k....o.np.}..q.k| 000100: 77 72 7f 85 82 98 82 76 88 71 7c 81 69 85 84 7f |wr.....v.q|.i...| 000110: a4 79 70 74 71 8c 86 88 7d 72 7d 73 7d 86 7c 85 |.yptq...}r}s}.|.| 000120: 7c 83 8d 7c 80 6c 7f 8d 7f 88 74 66 77 7e 83 8d ||..|.l....tfw~..| 000130: 8d 87 82 81 75 75 85 7c 7f 81 79 7e 7a 83 8a 7e |....uu.|..y~z..~| 000140: 83 79 7c 87 7d 7c 81 7b 7f 81 7b 83 7c 7e 83 83 |.y|.}|.{..{.|~..| 000150: 7e 7f 7a 80 83 87 7b 7b 7d 81 8c 80 80 85 78 81 |~.z...{{}.....x.| 000160: 84 7d 87 82 7d 80 87 86 7f 7f 7e 82 86 87 82 7f |.}..}.....~.....| 000170: 7d 80 80 81 7e 7c 84 85 82 81 7a 80 82 80 86 80 |}...~|....z.....| 000180: 7f 7d 81 7e 7e 82 7b 84 82 80 82 7e 80 |.}.~~.{....~. |
Download Example
|