extract.c (380B)
1 /* 2 * Extracts first channel from 16-bit stereo PCM input. 3 * Output is 16-bit mono, naturally. 4 */ 5 6 #include<u.h> 7 #include<libc.h> 8 9 void 10 main(void) 11 { 12 long i, n; 13 s16int buf[4096]; 14 while ((n = read(0, buf, 4096 * sizeof(s16int))) > 0) { 15 for (i = 0; i <= n / sizeof(s16int) / 2; i += 1) { 16 buf[i] = buf[i * 2]; 17 } 18 if (write(1, buf, n / 2) <= 0) exits("can't write"); 19 } 20 }