1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| int main(){
int init_size=2000;
int buffsize=init_size*sizeof(int16_t); //4 000
int16_t * x=(int16_t*)malloc(init_size*sizeof(int16_t));
int16_t i;
int bytesRead;
char *fi="test.wav";
FILE *fd_waveFile=NULL;
wavfile head_waveFile;
int cpt=0;
wavRead(&fd_waveFile,fi,&head_waveFile);
while ((bytesRead = fread(&i, sizeof(i),1, fd_waveFile)) > 0){
if(cpt==(buffsize)){
//x=(int16_t*)realloc(x,init_size*sizeof(int16_t)); j'ai commenté ça pour tester
buffsize=buffsize+init_size*sizeof(int16_t);
}
x[cpt]=i,
std::cout << "cpt=" << cpt << std::endl;
std::cout << "buffsize=" << buffsize << std::endl;
cpt++;
}
return(0);
} |
Partager