我正在尝试将鼓序列的每个细分分成二维数组内的单独数组(细分的行,每个细分中的数据列)。我根据用户对速度和所需细分的规范,在代码的前面确定每个细分有多少样本。我觉得我有一种比较合理的方法来计算样本中输入文件的大小(显示的第一部分)。我的问题是:按原样,sf_read_double while 循环不会运行。只有当我将“buflen”乘以 2(可能是通道数)时,循环才会运行。当它运行时,循环会超过计算的样本总数并导致 sug 错误。我在这段代码中做错了什么?
double framesArray[sfinfo.frames];
int numframes = (sizeof(framesArray)/sizeof(double));
int totalSamps = numframes * sfinfo.channels;
int totalSubdivisions = totalSamps / sampsPerSubdivision;
int buflen = sampsPerSubdivision;
int i;
double** choppeddata = (double**) malloc(totalSubdivisions * sizeof(double**));
for (i = 0; i < totalSubdivisions; i++)
choppeddata[i] = (double*) malloc(buflen * sizeof(double*));
double* buffereddata = (double*) malloc(buflen * sizeof(double*));
double* outdata = (double*) malloc(totalSamps * sizeof(double*));
int j = 0, k = 0, sampnum = 0;
while ((readcount = sf_read_double (infile, buffereddata, buflen)))
{
for (k = 0; k < buflen; k++)
{
choppeddata[j][k] = buffereddata[k];
sampnum++;
}
j++;
}