有时候需要把pcm数据转成int16做一些定性分析;
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
int main() {
FILE *fin;
FILE *fout;
int16_t *tmp = (int16_t *)malloc(sizeof(int16_t));
fin = fopen("record_fpga.raw", "rb");
if (fin == NULL) {
/* code */
printf("file in error!\n");
exit(0);
}
fout = fopen("data.txt", "w+");
if (fout == NULL) {
printf("file out error!\n");
exit(0);
}
while (!feof(fin)) {
fread(tmp, sizeof(int16_t), 1, fin);
printf("%d,", *tmp);
// fwrite(tmp, sizeof(int16_t), 1, fout);
}
printf("\n end ... ..\n");
fclose(fin);
fclose(fout);
}