Getting Started

Setup

First, you need to set up your project with The Amazing Audio Engine.

The easiest way to do so is using CocoaPods:

  1. Add pod 'TheAmazingAudioEngine' to your Podfile, or, if you don't have one: at the top level of your project folder, create a file called "Podfile" with the following content:
    pod 'TheAmazingAudioEngine'
  2. Then, in the terminal and in the same folder, type:
    pod install

Alternatively, if you aren't using CocoaPods, or want to use the very latest code:

  1. Clone The Amazing Audio Engine's git repository (or just download it) into a folder within your project, such as Library/The Amazing Audio Engine.

    Note: If you are cloning the repository, you may wish to grab only the latest version, with the following command:

    git clone --depth=1 https://github.com/TheAmazingAudioEngine/TheAmazingAudioEngine.git
  2. Drag TheAmazingAudioEngine.xcodeproj from that folder into your project's navigation tree in Xcode. It'll be added as a sub-project.
  3. In the "Build Phases" tab of your main target, open up the "Target Dependencies" section, press the "+" button, and select "TheAmazingAudioEngine".
  4. In the "Link Binary with Libraries" section, press the "+" button, and select "libTheAmazingAudioEngine.a".
  5. If "AudioToolbox.framework", "AVFoundation.framework" and "Accelerate.framework" aren't already in the "Link Binary with Libraries" section, press the "+" button again, and add them all.
  6. In the "Build Settings" tab, find the "Header Search Paths" item and add the path to the "TheAmazingAudioEngine" folder. For example, if you put the distribution into "Library/The Amazing Audio Engine", you might enter "Library/The Amazing Audio Engine/TheAmazingAudioEngine".

Finally, if you intend to use some of the modules provided with The Amazing Audio Engine, drag the source files of the modules you want to use from the "Modules" folder straight into your project.

Take a look at "TheEngineSample.xcodeproj" for an example configuration.

Note that TAAE now uses ARC, so if you're including source files directly within your non-ARC project, you'll need to add the -fobjc-arc flag to the build parameters for each source file, which you can do by opening the "Build Phases" tab of your app target, opening the "Compile Sources" section, and double-clicking in the "Compiler Flags" column of the relevant source files.

Meet AEAudioController

The main hub of The Amazing Audio Engine is AEAudioController. This class contains the main audio engine, and manages your audio session for you.

To begin, create a new instance of AEAudioController in an appropriate location, such as within your app delegate:

@property (nonatomic, strong) AEAudioController *audioController;
...
self.audioController = [[AEAudioController alloc]
inputEnabled:YES]; // don't forget to autorelease if you don't use ARC!

Here, you pass in the audio format you wish to use within your app. AEAudioController offers some easy-to-use predefined formats, but you can use anything that the underlying Core Audio system supports.

You can also enable audio input, if you choose.

Now start the audio engine running. You can pass in an NSError pointer if you like, which will be filled in if an error occurs:

NSError *error = NULL;
BOOL result = [_audioController start:&error];
if ( !result ) {
// Report error
}

Take a look at the documentation for AEAudioController to see the available properties that can be set to modify behaviour, such as preferred buffer duration, audio input mode, audio category session to use. You can set these at any time.

Now that you've got a running audio engine, it's time to create some audio.