.
Unsigned long subchunk2size;//wave data length (bytes)
Short * data; (the data is a sample point two bytes)
}
Int main {
.
Fp=fopen (" C:/Users/Administrator/Desktop/011 c020a. Wav ", "rb");//open a wave file (8 k_16bits)
Fp2=fopen (" C:/Users/Administrator/Desktop/aa. TXT ", "w");
Fseek (fp, 40 l, SEEK_SET);
Fread (& amp; Wave subchunk2size, sizeof (wave. Subchunk2size), 1, fp);//a wave file header 41-44 l is the length of the wave data
Wave. The data=(short * https://bbs.csdn.net/topics/malloc (sizeof (short) * wave. Subchunk2size/2);//open space
Fseek (fp, 44 l, SEEK_SET);//start from 45th bytes read data
i=0;
while (! The feof (fp)) {
Fread (& amp; Wave. The data [I], sizeof (short), 1, fp);
//fprintf (fp2, "% d \ n", wave. The data [I]);
i++;
Printf (" % x \ n ", c);
C=fgetc (fp);
//printf (" % x \ n ", c);
}
Question: whether the print to aa. TXT (fp2), or output to the DOS Windows in a bizarre situation: the output is normal, but read files in the middle, the abnormal, fp interrupted,
Pictured above, read the 2208th sample point (short) or right (matlab verified), but then seemed to encounter feof (fp), I'm sorry, expression is not clear,
I have used multiple wavefile validation, in such a situation,
Seek help from a great god!
CodePudding user response:
I'm sorry, picture