所以自从我用 C 编码以来已经有一段时间了,但是发生了一些奇怪的事情。也许有人可以运行我的代码,看看输出是否相同。它似乎没有打印零,并且“数据输出”似乎没有打印。
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <io.h>
#include <conio.h>
void main(void)
{
int i;
long n;
FILE *wavFile;
printf("The data output \n\n\r");
wavFile = fopen("bigbrain.wav","rb");
while(feof(wavFile)==0)
{
i = getw(wavFile);
if(ferror(wavFile)!=0)
{
printf("\n an error has occured");
n = ftell(wavFile);
printf("\nThe value of n is %ld",n);
getch();
}
printf("%x",i);
}
n = ftell(wavFile);
printf("\n\The value of n is %ld",n);
fclose(wavFile);
printf("\n\nEnd of File");
getch();
}
我从中得到的结果是。因为它是一个波形文件,所以我认为那里应该有一些占位的零。有人看到有什么不对吗?
4646495212c524556415720746d6610100012b112b118
这就是我通过交叉引用我知道应该存在的内容来手动分解数据的方式。
//Winamp says Unsigned 8-bit PCM; 1 channel; 11025Hz
46464952 //"RIFF"
12c52 //size: actuall size 76890, says 76882. My doc says correct because minus 8 bits for fields not included
45564157 //format "WAVE"
20746d66 //subchunkID 0x666d7420 but in big endian
10100012 //subchunk 1 size, expecting 16
b1 //audio format
1 //number of channels
2b11 //sample rate: file should be 11025 (ox2b11)
8000 //byte rate
//block align
1 //bits per sample... i think it cut off zero so 0x10 for 16
61746164 //start of data it's "data" 0x64617461 in big endian