Inter-app audio compatibility for iOS apps made with libPD

Inter-app audio in iOS apps is a feature that allows compatible apps to either send and/or receive audio to and/or from other compatible apps. So, how can you make your app inter-app audio compatible when you’ve used libPD/pd-for-iOS (Pure Data patch translator for iOS) to build it?

Making an audio app that supports inter-app Audio might be quite troublesome because of the lack of information resources… Especially when it comes to an audio app built with libPD, there seems to be literally no information at all available online! Here’s what I’ve found out while making the inter-app Audio compatible version of Echo Pitch. The most helpful text I’ve found online is the one provided by the www.raywenderlich.com tutorials. Before you start developing, make sure that you have an app able to bridge inter-app audio compatible apps, like garage band or the free app Audreio (which I’m also using for testing).

The steps described below are summarising the aforementioned tutorial pdf, but give additional info on the following:

1) integrating an app built with libPD for iOS (and not with directly using audio units) and

2) making the app both an audio sender and a receiver in the inter-app audio “conversation” between apps.

The steps are the following:

1) Enable inter-app audio int he app capabilities:

app_capabilities.png

2) Tweak the Info.plist file of your app by adding the necessary audio component description addition. You need to right click on the info.plist file and “Open As -> Source Code”. For making the app both a sender (“aurg”) and a receiver (“aurx”) you need to add both descriptions before the last </dict> line:

<key>AudioComponents</key>
    <array>
        <dict>
            <key>manufacturer</key>
            <string>avax</string>
            <key>name</key>
            <string>EchoPitch</string>
            <key>type</key>
            <string>aurx</string>
            <key>subtype</key>
            <string>iasp</string>
            <key>version</key>
            <integer>1</integer>
        </dict>
        <dict>
            <key>manufacturer</key>
            <string>avax</string>
            <key>name</key>
            <string>EchoPitch</string>
            <key>type</key>
            <string>aurg</string>
            <key>subtype</key>
            <string>iasp</string>
            <key>version</key>
            <integer>1</integer>
        </dict>
    </array>

The “avax” is a name/code that describes the company that made the app (avax comes from Avi and Max – designers/developers of Echo Pitch).

3) Add the necessary code in your ViewController.m file. First include this method:

- (void)publishAsNode{
    AudioComponentDescription desc_1 = {
        kAudioUnitType_RemoteEffect, 'iasp',
        'avax',
        0,
        1
    };
AudioOutputUnitPublish(&desc_1, CFSTR("EchoPitch"), 0, _pd.audioUnit.audioUnit);
    
    AudioComponentDescription desc_2 = {
        kAudioUnitType_Generator, 'iasp',
        'avax',
        0,
        1
    };
    AudioOutputUnitPublish(&desc_2, CFSTR("EchoPitch"), 0, _pd.audioUnit.audioUnit);
}

which as you see refers to the audioUnit “hidden” within the _pd instantiation of the PDAudioController. Then, at the end of the viewDidLoad method, make sure that you call the new method you’ve added as follows:

[self publishAsNode];

Voilà, Your libPD-built iOS app is inter-app audio compatible!

Advertisements

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