Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Waveform of a audioFile (but not RMS) #332

Open
noetits opened this issue Jun 28, 2016 · 0 comments
Open

Waveform of a audioFile (but not RMS) #332

noetits opened this issue Jun 28, 2016 · 0 comments

Comments

@noetits
Copy link

noetits commented Jun 28, 2016

Hello,

I would like do plot the data of a sound file. Not the RMS value of the signal but the signal itself. It would probably not be possible to draw the entire sound file on the screen and have something understandable but if we zoom a lot we could see the signal.

But I don't know how to do this in EZaudio. In the WaveformFromFile example I can see the code:

//-------------------------------------------------------------------------------------
[self.audioFile getWaveformDataWithNumberOfPoints:1024
completion:^(float **waveformData,
int length)
{
[weakSelf.audioPlot updateBuffer:waveformData[0]
withBufferSize:length];
}];
//-------------------------------------------------------------------------------------

So I should probably put the raw data of the file for updateBuffer instead of waveFormData.
I tried using an AudioBufferList to get the data (here only the 512 frames) of the audioFile like this :

//-------------------------------------------------------------------------------------
// Allocate a buffer list to hold the file's data
UInt32 frames = 512;
AudioBufferList *bufferList = [EZAudioUtilities audioBufferListWithNumberOfFrames:512 numberOfChannels:1 interleaved:YES];
UInt32 bufferSize=0; // Read function will populate this value
BOOL eof; // Read function will populate this value
// Reads 512 frames from the audio file
[self.audioFile readFrames:frames
audioBufferList:bufferList
bufferSize:&bufferSize
eof:&eof];
[weakSelf.audioPlot updateBuffer:(float *)bufferList->mBuffers[0].mData
withBufferSize:bufferSize];
//-------------------------------------------------------------------------------------

But I have this error : "Error: Failed to read audio data from file (-50)" . But I think I don't understand well how the AudioBufferList works.

I read in the issue of @nick-thompson : #323

Every time you call readFrames, it will read a certain number of frames and call through to the delegate method with the data for those frames.
One approach you can take is to loop and read until eof while you process the data in the delegate.

answered by @dxclancy

Maybe this is what I should do too?
I'm new to objective-c, therefore I don't understand well the working of a delegate method...

Thank you in advance !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant