LibPD and externals

From CCRMA Wiki
Revision as of 12:21, 3 December 2014 by Rob (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
"When dynamic loading is not available, clients can have externals compiled into them and initialize them by calling the setup function after calling the libpd_init function."
"All Pd assets (patches, audio files, text files, externals) must be placed in Assets > StreamingAssets > PdAssets. libpd will not be able to find any of the resources in a build if the assets are placed in another folder."

Using compiled C-language Externals on iOS

Because iOS does not support dynamic libraries it is necessary to compile and statically link any C-language Pd externals in with your iOS app. It is also necessary to explicitly initialize any such external before it can be used from a Pd patch. This registers the external objects as available to Libpd.

For example, to use the C-language external lrshift~ with an iOS app. Add lrshift~.c to your project (it is located in the extra folder along with the Libpd source). Then call the lrshift_tilde_setup() function after initializing Libpd.

extern void lrshift_tilde_setup(void);

- (BOOL)application:(UIApplication *)application 
   didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   pdAudioController = [[PdAudioController alloc] init];
   [pdAudioController configurePlaybackWithSampleRate:44100
        numberChannels:2 inputEnabled:YES mixingEnabled:NO];