Uncompressed wave file 에서 정보 추출

압축되지 않은 wave 파일에서 header 정보를 가져오는 소스

[CODE] #include typedef struct { char wavRIFFChunk[4]; long wavSize; char wavWAVEChunk[4]; char wavFMTChunk[4]; long wavFormatSize; short wavPCMFormatFlag; short wavChannel; long wavSampleRate; long wavSampleRatePerSec; short wavPerSecScale; short wavBits; char wavDataChunk[4]; long wavDataSize; }wav_header; int main(int argc, char** argv) { wav_header in_wav; FILE* fp; char pBuffer[5]; if(argc != 2) { printf(“usage : getwavinfo.exe [wav_file]n”); return 1; } if((fp = fopen(argv[1], “rb”)) == NULL) { printf(“file open error : %sn”, argv[1]); return 1; } fread(&in_wav, sizeof(wav_header), 1, fp); fclose(fp); strncpy(pBuffer, in_wav.wavRIFFChunk, 4); pBuffer[4] = 0; printf(“Riff Chunk : %sn”, pBuffer); printf(“Size : %d byte(s)n”, in_wav.wavSize); strncpy(pBuffer, in_wav.wavWAVEChunk, 4); pBuffer[4] = 0; printf(“Wave Chunk : %sn”, pBuffer); strncpy(pBuffer, in_wav.wavFMTChunk, 4); pBuffer[4] = 0; printf(“FMT Chunk : %sn”, pBuffer); printf(“Format Size : %dn”, in_wav.wavFormatSize); printf(“PCM Format Flag : %dn”, in_wav.wavPCMFormatFlag); printf(“Channels : %dn”, in_wav.wavChannel); printf(“Sample Rate : %dn”, in_wav.wavSampleRate); printf(“Sample Rate Per Second : %dn”, in_wav.wavSampleRatePerSec); printf(“Per Second Scale : %dn”, in_wav.wavPerSecScale); printf(“Bits Per Sample : %dn”, in_wav.wavBits); strncpy(pBuffer, in_wav.wavDataChunk, 4); pBuffer[4] = 0; printf(“Data Chunk : %sn”, pBuffer); printf(“Data Size : %dn”, in_wav.wavDataSize); return 0; } [/CODE]

답글 남기기