-1

私は18000個のアイテムの配列を書き込もうとしています(その配列は変換wav>arrayからのものです)、ファイルにアイテムを書き込む\nと、それを書きたくないときに表示されます。コードは次のとおりです。

f = info.frames;
sr = info.samplerate;
c = info.channels;
num_items = f*c;
int arrayPrueba [num_items];

/* Allocate space for the data to be read, then read it. */
buf = (int *) malloc(num_items*sizeof(int));
num = sf_read_int(sf,buf,num_items);
sf_close(sf);
printf("Read %d items\n",num);

/* Write the data to filedata.out. */
out = fopen("filedata.data","a+");
fprintf(out,"13 18000 1\n");
int cont =0;

for (i = 0; i < num; i += c)
{
   for (j = 0; j < c; ++j)
        fprintf(out,"%d ",buf[i+j]);}
}
fprintf(out,"\n%d\n",pasos);
fclose(out);

filedata.data線の飛びが見える箇所の一部です

    104333312 103415808 104202240 105250816 104595456 104202240 103022592 103415808 102367232 102236160 104202240 104071168 104464384 103677952 103284736 103809024 102760448 103415808 105644032 102629376 102629376 103940096 103022592 103284736 102891520 104726528 103677952 103284736 102891520 104071168 104202240 102498304 102760448 102367232 100007936 102498304 104071168 104202240 103153664 103940096 103153664 103022592 103284736 103940096 103677952 103546880 102629376 103546880 101974016 102498304 104071168 103546880 103677952 103940096 103284736 102105088 105119744 104071168 103677952 103415808 104071168 104726528 103546880
 103415808 103677952 103940096 105512960 104857600 103940096 103809024 102760448 103022592 103284736 103022592 103153664 104333312 102891520 103940096 104464384 103677952 103940096 102105088 103022592 102629376 104595456 103940096 102236160 102760448 102629376 103940096 102236160 104726528 102760448 102629376 102760448

103546880 と 103415808 の間でジャンプします。

\nFANNトレーニング用のfile.dataでジャンプできないため、分割なしで必要です。

4

3 に答える 3

0

問題の原因は次のとおりです。

info.samplerate;

そのデータがどこから収集されたとしても、何かが埋め込まれた改行を引き起こしている可能性があります。おそらく、サンプリングに癖があるか、バッファがオーバーランして、新しいバッファ/行のデータが書き込まれるように促されている可能性があります。改行の前にいくつのデータ エントリを取得しますか?

于 2014-08-11T10:14:28.127 に答える
-2

行を置き換えますout = fopen("filedata.data","a+"); 下の行で。例: out = fopen("filedata.data","a+b");

そのため、ファイルには改行文字 (\n) が含まれません。

于 2014-08-11T10:32:47.833 に答える