1 /************************************************************************
2 ************************************************************************
3 FAUST Architecture File
4 Copyright (C) 2003-2011 GRAME, Centre National de Creation Musicale
5 ---------------------------------------------------------------------
7 This is sample code. This file is provided as an example of minimal
8 FAUST architecture file. Redistribution and use in source and binary
9 forms, with or without modification, in part or in full are permitted.
10 In particular you can create a derived work of this FAUST architecture
11 and distribute that work under terms of your choice.
13 This sample code is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 ************************************************************************
17 ************************************************************************/
19 #import "iPhoneAppDelegate.h"
20 #import "iPhoneViewController.h"
21 #include "iphone-faust.h"
24 @implementation iPhoneAppDelegate
27 @synthesize viewController;
29 TiPhoneCoreAudioRenderer* audio_device = NULL;
34 - (void)applicationDidFinishLaunching:(UIApplication *)application
36 DSP.metadata(&metadata);
38 interface = new CocoaUI(window, viewController, &metadata);
39 audio_device = new TiPhoneCoreAudioRenderer(DSP.getNumInputs(), DSP.getNumOutputs());
44 DSP.init(long(srate));
45 DSP.buildUserInterface(interface);
47 const char* home = getenv ("HOME");
48 const char* name = (*metadata.find("name")).second;
51 snprintf(rcfilename, 256, "%s/Library/Caches/%s", home, name);
52 interface->recallState(rcfilename);
54 if (audio_device->Open(fpb, srate) < 0) {
55 printf("Cannot open CoreAudio device\n");
59 if (audio_device->Start() < 0) {
60 printf("Cannot start CoreAudio device\n");
71 - (void)applicationWillTerminate:(UIApplication *)application
73 interface->saveState(rcfilename);
79 audio_device->Close();