http://people.msoe.edu/~taylor/examples/wav.htm
我是看上面網頁來學習wav的格式(在板上爬文找到的)
有個地方不是很瞭解
wav檔案的header裡面有一個東西,叫做chunk:
37 // header of wav file
38 typedef struct{
39 char dId[4]; // 'data' or 'fact'
40 long int dLen;
41 // unsigned char *data;
42 } CHUNK_HDR;
43
然後他在讀取檔案的時候,連續讀了這個chunk很多次,只留最後一個。
145 // read chunks until a 'data' chunk is found
146 sflag = 1;
147 while(sflag!=0){
148
149 // check attempts
150 if(sflag>10){ printf("too many chunks\n"); exit(-1); }
151
152 // read chunk header
153 wstat = fread((void *)chk,sizeof(CHUNK_HDR),(size_t)1,fw);
154 if(wstat!=1){ printf("cant read chunk\n"); exit(-1); }
155
156 // check chunk type
157 for(i=0;i<4;i++) obuff[i] = chk->dId[i];
158 obuff[4] = 0;
159 if(strcmp(obuff,"data")==0) break;
160
161 // skip over chunk
162 sflag++;
163 wstat = fseek(fw,chk->dLen,SEEK_CUR);
164 if(wstat!=0){ printf("cant seek\n"); exit(-1); }
165 }
想請教的是,這個chunk中的'data' 'fact'有何差別,為何只需要留最後一個?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.168.23.209