Ios AudioKit使用AkaAudioFile缓冲区更新绘图并显示完整波形

Ios AudioKit使用AkaAudioFile缓冲区更新绘图并显示完整波形,ios,audiokit,ezaudio,Ios,Audiokit,Ezaudio,我有一个阴谋 self.plot = EZAudioPlot() self.plot?.frame = CGRect(x:0, y:0, width:Int(self.plotWidth!), height:Int(self.plotOutlet!.bounds.height)) self.plot?.plotType = EZPlotType.buffer self.plot?.shouldFill = true self.plot?.shouldMirror = true self.plot

我有一个阴谋

self.plot = EZAudioPlot()
self.plot?.frame = CGRect(x:0, y:0, width:Int(self.plotWidth!), height:Int(self.plotOutlet!.bounds.height))
self.plot?.plotType = EZPlotType.buffer
self.plot?.shouldFill = true
self.plot?.shouldMirror = true
self.plot?.shouldOptimizeForRealtimePlot = true
self.plot?.color = UIColor.white
self.plot?.backgroundColor = UIColor(red:0,green:0,blue:0,alpha:0)
self.plot?.gain = 1
self.plotOutlet?.addSubview(self.plot!)
我想通过从AKAudioFile复制的缓冲区进行更新:

self.plot?.updateBuffer(file.pcmBuffer.floatChannelData![0], withBufferSize: file.pcmBuffer.frameLength)
这一条写着:pcmBuffer:265:error cannot readIntBuffer

我尝试了另一种方法,首先将缓冲区转换为EZAudioFloatData,但无法正确进行类型转换:

let data = EZAudioFloatData(numberOfChannels: 2, buffers: file.pcmBuffer.floatChannelData, bufferSize: file.pcmBuffer.frameLength)
检查器说:无法将类型为“UnsafePointer>?”的值转换为预期的参数类型“UnsafeMutablePointer?>!”

我做错了什么? 顺便说一句:我知道我可以使用EZAudioFile()加载wav文件,然后使用.getWaveformData()获取缓冲区,但出于几个原因,我想知道是否有办法使用AkaAudioFile来实现同样的效果

---更新:

我能够将波形功能添加到AKWaveTableDSPKernel.hpp:文件中:

EZAudioFloatData* getWaveformData(UInt32 numberOfPoints){

if (numCh == 0 || current_size < numberOfPoints){
    // prevent division by zero
    return nil;
}

EZAudioFloatData *waveformData;

float **data = (float **)malloc( sizeof(float*) * numCh );
for (int i = 0; i < numCh; i++)
{
    data[i] = (float *)malloc( sizeof(float) * numberOfPoints );
}

// calculate the required number of frames per buffer
SInt64 framesPerBuffer = ((SInt64) current_size / numberOfPoints);

// read through file and calculate rms at each point
for (SInt64 i = 0; i < numberOfPoints; i++){

    for (int channel = 0; channel < numCh; channel++){

        float channelData[framesPerBuffer];
        for (int frame = 0; frame < framesPerBuffer; frame++)
        {
            if(channel == 0){
                channelData[frame] = ftbl1->tbl[i * framesPerBuffer + frame];
            }else{
                channelData[frame] = ftbl2->tbl[i * framesPerBuffer + frame];
            }
        }
        float rms = [EZAudioUtilities RMS:channelData length:(UInt32)framesPerBuffer];
        data[channel][i] = rms;

    }

}

waveformData = [EZAudioFloatData dataWithNumberOfChannels:numCh buffers:(float **)data bufferSize:(UInt32)numberOfPoints];

// cleanup
for (int i = 0; i < numCh; i++){
    free(data[i]);
}

free(data);

return waveformData;

}
EZAudioFloatData*getWaveformData(UInt32 numberOfPoints){
如果(numCh==0 | |当前| U大小tbl[i*framesPerBuffer+frame];
}否则{
channelData[frame]=ftbl2->tbl[i*framesPerBuffer+frame];
}
}
浮点rms=[EZRMS:channelData长度:(UInt32)framesPerBuffer];
数据[通道][i]=rms;
}
}
waveformData=[EZAudioFloatData dataWithNumberOfChannels:numCh缓冲区:(浮点**)数据缓冲区大小:(UInt32)numberOfPoints];
//清理
对于(int i=0;i

它只需要公共头绑定。我将很快尝试使用此功能执行拉取请求。

您是否为此执行过拉取请求?我也对这种能力感兴趣@justinkaufman我以前从未做过拉车请求