FreeCalypso > hg > gsm-codec-lib
comparison libtest/pcmwrite.c @ 11:a3aa152c4653
libtest: pcmwrite helper function and module
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 20 Nov 2022 00:31:42 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
10:820d88b97924 | 11:a3aa152c4653 |
---|---|
1 /* | |
2 * Here we implement our PCM write helper function. | |
3 */ | |
4 | |
5 #include <stdint.h> | |
6 #include "wavwriter.h" | |
7 #include "pcmwrite.h" | |
8 | |
9 void write_pcm_to_wav(void *wav, const int16_t *pcm) | |
10 { | |
11 uint8_t bytes[320], *dp; | |
12 int16_t samp; | |
13 unsigned n; | |
14 | |
15 dp = bytes; | |
16 for (n = 0; n < 160; n++) { | |
17 samp = pcm[n]; | |
18 *dp++ = samp & 0xFF; | |
19 *dp++ = (samp >> 8) & 0xFF; | |
20 } | |
21 wav_write_data(wav, bytes, 320); | |
22 } |