First, you need to set up your project with The Amazing Audio Engine.
The easiest way to do so is using CocoaPods:
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: Alternatively, if you aren't using CocoaPods, or want to use the very latest code:
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:
TheAmazingAudioEngine.xcodeproj
from that folder into your project's navigation tree in Xcode. It'll be added as a sub-project."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.
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:
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:
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.