#include
#define BUFFER_LENGTH 10
#define FILE_LENGTH 1000/BUFFER_LENGTH
void main()
{
FILE *fp_r, *fp_w;
const char *read_name = "pcm.wav";
const char *wright_name = "haha.wav";
unsigned char read_byte[BUFFER_LENGTH];
unsigned char wright_byte[BUFFER_LENGTH * 4];
fp_r = fopen(read_name, "r");
if (fp_r == NULL)
{
printf("open file pcm.wav err");
}
fp_w = fopen(wright_name, "wb");
if (fp_w == NULL)
{
printf("open file haha.wav err");
}
for (int i = 0; i < FILE_LENGTH ; i++)
{
fread(read_byte, BUFFER_LENGTH, 1, fp_r);
for (int j = 0 ; j < BUFFER_LENGTH; j++)
{
wright_byte[j*4] = read_byte[j];
wright_byte[j*4 + 1] = read_byte[j];
wright_byte[j*4 + 2] = read_byte[j];
wright_byte[j*4 + 3] = read_byte[j];
}
fwrite(wright_byte, BUFFER_LENGTH*4, 1, fp_w);
}
fclose(fp_r);
fclose(fp_w);
}
阅读(1856) | 评论(0) | 转发(0) |