pcm.c (686B)
1 #include <sys/select.h> 2 3 #include <limits.h> 4 #include <stdio.h> 5 6 #include "sad.h" 7 8 void s16monotostereo(short *in, short *out, size_t nsamples) { 9 size_t i; 10 11 for (i = 0; i < nsamples; i++) { 12 out[i * 2] = in[i]; 13 out[i * 2 + 1] = in[i]; 14 } 15 } 16 17 void s16stereotomono(short *in, short *out, size_t nsamples) { 18 size_t i; 19 20 for (i = 0; i < nsamples; i++) 21 out[i] = in[i * 2] / 2 + in[i * 2 + 1] / 2; 22 } 23 24 void s16tofloat(short *in, float *out, size_t nsamples) { 25 size_t i; 26 27 for (i = 0; i < nsamples; i++) 28 out[i] = in[i] / 32768.f; 29 } 30 31 void floattos16(float *in, short *out, size_t nsamples) { 32 size_t i; 33 34 for (i = 0; i < nsamples; i++) 35 out[i] = in[i] * 32768.f; 36 }