Apple’s Audio Unit examples in OSX 10.9 and XCode 5

success

(NOTE: There is a download link to my modified version of the filter demo project at the bottom of the page if you want an example rather than a how-to guide.  I may put it up on github if I am feeling spunky.)

 

This post is for updating the example projects from Apple.  If you are looking for a “new project” audio unit template, see this post: audio unit new file template

 

The recent updated audio unit examples that Apple put out don’t show up in many DAWs/hosts. It was quite an effort to get them working in 10.9/XCode5. Apple seem to be in the process of changing both their Audio Unit standards and the SDK, and they didn’t bother including legacy support in the new sample code, which has pissed a lot of people off since that is all AU programmers have to go on since they didn’t include Audio Unit templates in the newer versions of XCode.

Here are the templates from Apple: https://developer.apple.com/library/mac/samplecode/sc2195/Introduction/Intro.html

Here is their guide to updating them (they mde these changes to their new samples (but they left out many important things… like saying “should be left in place for backwards compatibility” and then not including that *.r file AND taking the old sample code off their developer site… sigh. They also left off the change to the *.exp file in the sample code because it won’t build right without changes in XCode… which they did not make in the project file. They also used a syntax in the plist file that DAWs, like Logic, can’t read right — so they won’t load the plugin): https://developer.apple.com/library/mac/technotes/tn2276/_index.html

ALSO this all assumes that you installed the “Audio Tools for Xcode” CoreAudio folder and SDKs inside your XCode.app using the folder hierarchy that was used in previous versions (/Developer/Extras/CoreAudio…) You can change them to refer to root if you have it installed there like it was before (I put it in both places just to be safe). You can get it at: https://developer.apple.com/library/mac/samplecode/CoreAudioUtilityClasses/Introduction/Intro.html

I could not find a guide that was recent enough to reflect the newest changes in XCode/OSX/CoreAudioSDK, so I put down everything I could remember here. These are the changes that I made to the most recent Apple sample projects in order to get it them compile on 10.9 with XCode 5 with the most recent CoreAudio files (1.0.4), while having the plugin compile without any errors (64-bit, 32-bit AND universal binary), pass evaluation, and show up in DAWs with legacy component registering and bundle identification methods, as well as DAWs that follow the new guidelines.

These may not all be necessary, but I changed everything that I thought looked suspect:

ADDITIONAL FILES:
1))))) In your AUSource folder/group, create a resource file named after your project. This is what the contents of mine look like for the filter demo… you’ll have to change the details to match both your project and your plist file:

#include <AudioUnit/AudioUnit.r>
#include "FilterVersion.h"
// Note that resource IDs must be spaced 2 apart for the 'STR ' name and description
#define kAudioUnitResID_Filter 1000
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Filter~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#define RES_ID kAudioUnitResID_Filter
#define COMP_TYPE kAudioUnitType_Effect
#define COMP_SUBTYPE Filter_COMP_SUBTYPE
#define COMP_MANUF Filter_COMP_MANF
#define VERSION kFilterVersion
#define NAME "DEMO: Filter"
#define DESCRIPTION "Filter AU"
#define ENTRY_POINT "FilterEntry"
#include "AUResources.r"

SYNC that all up by hand with the info in the plist file or some DAWs won’t load it if they read both the old and the new versions of the bundle info.

project resource fileplist

2))))) Add a blank file called “PkgInfo” containing the word BNDL with no whitespace (not sure if the whitespace matters)

pkginfo

CHANGES TO EXISTING FILES:

3))))) Add the following entry in your “<project name>.exp exports file: _<your project name>” Entry and MAKE SURE you go to that you go to Target->Linking->Exported Symbols File and add in the name of this file there. AND that it did not automagically appear in your build phases (if it did, take it out).

exported symbols

exp symbols

4))))) Change the name in the plist file to this format: “Manufacturer: Name” because some DAWs will read everything before the colon as the manufacturer

5))))) Change the bundle identifier string in the plist file to this format: com.<manufacturer>.audiounit.<plugin name>

plist

6))))) I changed all the source files in the project to the most recent version (1.0.4). This may or may not be necessary, but I did it out of completeness

7))))) Add AUResources.r to your source (it is under AUBase), AND make sure it is not auto-added to your target’s build phasees (it will try to put it in your ‘build carbon resources’ section)

add resource file

PROJECT SETTING CHANGES: Project->Build Settings->Search Paths->Header Search Paths:

 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include /Applications/Xcode.app/Contents/Developer/Extras

(some of the headers were moved from their respective frameworks into /usr/include, so I put a path there to prevent the ‘Rez is an idiot and can’t find this header file… blah blah blah… I suppose you could probably put a link there or copy the files into the frameworks too, but I try to avoid that in case the files get overwritten with an update)

project header search paths

TARGET SETTING CHANGES Target->Build Settings->Rez – Language->Other Rez Flags:

 
-d i386_$i386 -d x86_64_$x86_64 -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/Headers -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Extras/CoreAudio/AudioUnits/AUPublic/AUBase

(I added the 32 and 64 bit flags there and directed the paths to my SDK frameworks, but you can link them to your system frameworks if you want.. or to a different SDK if you are building against a previous version)

target other rez flags

NOTES:

–MAKE SURE that after the 2 lines in your *.exp file there is a line of blank space at the bottom.  Otherwise you will get an error message and it won’t build.

–MAKE SURE that in your *.r file that there is NO line of blank space at the end!!  Otherwise REZ will complain and it won’t build.

–MAKE SURE that when you make the changes above, that where it says “project” that you change the project and when it says “target” that you change the target!!!!

–Make sure your created prefix header (*.pch) shows up in Target->build settings->Apple LLVM 5.0 – Language->Prefix Header, and make sure that above it you select “Precompile Prefix Header” YES

prefix settings

–Make sure that your created resource file shows up in Targets->Build Phases->build Carbon Resources , and make sure that no other *.r files appear there

build phase carbon

–Make sure that in Targets->Build Phases->Copy Bundle Resources, your Plist file is there

–I did not change the Rez search paths like I read to do in some other places

–I have built products set to show up in your local user folder in /Users/<user name>/Library/Developer/Xcode/DerivedData/<project name – (lots of hash)/Build/Products… your location may vary, or you can change it to install to your components directory or whatever suits your workflow.

So there. You should have a working project that will show up in your favorite plugin host. Here is a download of my modified and working copy of the project FILTER project. It’s small (287 KB) Happy coding!

-Alex Kenis

Here is a screenshot of the source code groups that contain added/modified files:

code

Here are some similar guides for previous versions of Xcode and OSX.  These methods did not work for me in Xcode5 + OSX.9, but if you are running XCode4, they will likely work for you:

http://www.squishycat.com/category/audio-unit-development

http://www.mojolama.com/restore-apples-audio-unit-templates

http://sample-hold.com/2011/11/23/getting-started-with-audio-units-on-os-x-lion-and-xcode-4-2-1/

And again, if you are simply looking for an Audiounit ‘new file’ template, please refer to this post for the one that I have made for myself: audio unit new file template post

Advertisements

About alexkenis

Guitarist, philosopher, tinkerer

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: