How to use aubio framework in iOS?

2.3k views Asked by At

I am trying to detect beat, pitch, onset, and fast Fourier Transform (FFT) of audio file in iOS and I found that aubio provides these features and iOS framework also available.

So far, I am using The Amazing Audio Engine to receive audio data in terms of Core Audio's AudioBufferList like this:

id<AEAudioReceiver> receiver = [AEBlockAudioReceiver audioReceiverWithBlock:
                               ^(void                     *source,
                                 const AudioTimeStamp     *time,
                                 UInt32                    frames,
                                 AudioBufferList          *audio) {
    // I don't know how to use audio library.
}];

Can I detect beat, pitch, onset, and fast Fourier Transform (FFT) using aubio from this AudioBufferList and how? If I am on the wrong track, please give me any suggestion?

4

There are 4 answers

0
Elliot Yap On

Look at the aubio download page, I believe they've compiled it into framework for iOS and you can import to your Xcode directly.

Reference : http://aubio.org/download#ios

2
Michael On

My solution for this was to write the audio buffer into a file and then send the file to aubio. Whenever you get a new buffer of audio you can either append to the file (if you want to analyze the whole thing so far) or just overwrite if you're only interested in the incremental piece.

2
Daniel On

There is a compiled framework to use with iOS in the download page.

One you have drag and dropped the library into your project, make sure you also have followign frameworks:

  • Accelerate.framework
  • AudioToolbox.framework

Now, if you download Aubio's source, you will have an examples folder. There, you will find code for detecting beat, pitch, onset (there is also FFT) written in C, which, since ObjC is a superset of C, will also work in your project.

2
Brian Ogden On

UPDATE So it looks like the Cocoa Pod for Aubio is not the latest, in my Podfile, I use this code to add Aubio to my Xcode Workspace:

pod 'aubio-iOS-SDK', '~> 0.4'

This installs Aubio 0.4.1 and that is not the latest. Finding documentation for Aubio, in general, is a bit of an obscure process where you piecemeal multiple internet search results together into a workings solution.

For iOS it is even more obscure, if you go to the Aubio downloads page you will find version 0.4.2 for iOS, scroll to bottom, that is later version than the Aubio Cocoa Pod. And yet, here, in comments I found a later iOS Aubio module, 0.4.3, here is the direct download to what might be the latest Aubio for iOS:

https://aubio.org/bin/tmp/aubio-0.4.3~const.iosuniversal_framework.zip

You still need a bridging header reference to aubio.h if you are using Swift as I mentioned in my original answer

ORIGINAL ANSWER There is CocoaPod for aubio that really makes it simple to reference aubio libraries in Swift. Here is the Aubio CocoaPod of iOS:

https://cocoapods.org/pods/aubio-iOS-SDK

Once you install, note that, in Swift, you will NOT write:

import aubio 

at the top of your Swift file.

You need to make sure you add an objective C bridging header to expose the aubio C library to Swift, in the that bridging header you write the following:

#import <aubio/aubio.h>

Now Swift will have access to the aubio library/framework.