AudioBufferList to float ** conversion EZAudio EZMicrophone for Visual Plotting

658 Views Asked by At

I'm using EZAudio in my project to read audio data from the microphone. EZAudio has 2 microphone methods:

- (void)microphone:(EZMicrophone *)microphone hasBufferList:(AudioBufferList *)bufferList withBufferSize:(UInt32)bufferSize withNumberOfChannels:(UInt32)numberOfChannels {

-(void)microphone:(EZMicrophone *)microphone hasAudioReceived:(float **)buffer withBufferSize:(UInt32)bufferSize withNumberOfChannels:(UInt32)numberOfChannels {

I'm using the first method with AudioBufferList to get the audio data and send them over the wifi. It works well. But when I want to plot them, as far as i can tell EZAudio only accepts the output from the second method which uses float ** for plotting. I seem to be stuck here. I can't get the EZOutput to play float ** so i can use the second microphone method for both plotting and playback. And I can't pass in the AudioBufferList from the first method for plotting.

It seems if i can manage to convert one to another (AudioBufferList <--> float **), it may solve my problem, but i don't know how to do it.

Any help is appreciated.

1

There are 1 best solutions below

0
On

Try this:

float *buffer = (float*)bufferList->mBuffers[0].mData;