| 182 | } |
| 183 | |
| 184 | string WavHeader(int32 samples_per_second, int32 channel_count, |
| 185 | const std::vector<float>& samples) { |
| 186 | string header = "RIFF"; |
| 187 | header += LittleEndianDataInt(36U + samples.size() * sizeof(int16)); |
| 188 | header += "WAVEfmt "; |
| 189 | header += LittleEndianDataInt(16); |
| 190 | header += LittleEndianDataShort(1); |
| 191 | header += LittleEndianDataShort(channel_count); |
| 192 | header += LittleEndianDataInt(samples_per_second); |
| 193 | header += |
| 194 | LittleEndianDataInt(samples_per_second * channel_count * sizeof(int16)); |
| 195 | header += LittleEndianDataShort(channel_count * sizeof(int16)); |
| 196 | header += LittleEndianDataShort(16); |
| 197 | header += "data"; |
| 198 | header += LittleEndianDataInt(samples.size() * sizeof(int16)); |
| 199 | CHECK_EQ(header.size(), 44); |
| 200 | return header; |
| 201 | } |
| 202 | |
| 203 | // Creates the contents of a .wav file using pcm_s16le format (signed 16 bit |
| 204 | // little endian integers). |
no test coverage detected