我一直在尝试将数组传递给 DiracLE 音频库中的方法。
数组在调试器中看起来像这样
- (OSStatus) readFloatsConsecutive:(SInt64)numFrames intoArray:(float**)audio withOffset:(long)offset
像这样填满数组
if (audio) {
for (long c = 0; c < mExtAFNumChannels; c++) {
if (!audio[c]) continue; // this executes for both channels
// but doesnt proceed into next for loop
for (long v = 0; v < numFrames; v++) {
if (v < loadedPackets) audio[c][v+offset] = (float)data[v*mExtAFNumChannels+c] / 32768.f;
else audio[c][v+offset] = 0.f;
}
}
}
我这样称呼它
[reader readFloatsConsecutive:frameCount intoArray:arrayToFill];
arrayToFill 是当前函数范围的参数
[self readAudioDataForFile:temp withArray:tempArray];
数组最初是这样传递给函数的
// this array was passed into the function as tempArray which is float **tempArray = NULL;
arrayToFill = (float **) malloc ( (frameCount * channelCount) * sizeof( float ));
因为我需要在我的方法中从文件中提取音频数据,所以我必须在那里 malloc 数组并将其传递给 dirac 函数进行填充。我像这样 malloc arrayToFill = (float **) malloc ( (frameCount * channelCount) * sizeof( float ));
,然后将它传递给前面提到的 dirac 函数。
该数组可以是二维或一维数组,具体取决于通道数