Subchunk2ID in the header of the wav file on the iPhone
Hello wonderful people of the audio computing world!
Allright, so I've managed to successfully parse the header of a wav file and spit out the samples into an array. This I did on my Mac using code found at the bottom of this post.
Now I've integrated the C code onto my iPhone device, but i开发者_如何学Got EXITS FAILURE when it hits this piece of code:
/* Subchunk2ID */
fread(buf, 1, 4, stdin);
buf[4] = '\0';
if (strcmp((char*)buf, "data")) exit(EXIT_FAILURE);
The file is in wav format recorded using the SpeakHere example project. I just changed the format from the original .caf to a .wav.
Is there something particular about how core-audio creates a wav file that would make it different to parse from a regular wav file?
How could I solve this problem?
Thanks!
You can use AudioFile to do this, assuming you don't need to convert the file's data to a different format. Your code will flow like this:
AudioFileOpenURL()
AudioFileReadPackets()
AudioFileClose()
精彩评论