Merge branch 'master' of https://scm.cri.ensmp.fr/git/Faustine
[Faustine.git] / interpretor / faust-0.9.47mr3 / architecture / pa-gtk.cpp
1 /************************************************************************
2
3 IMPORTANT NOTE : this file contains two clearly delimited sections :
4 the ARCHITECTURE section (in two parts) and the USER section. Each section
5 is governed by its own copyright and license. Please check individually
6 each section for license and copyright information.
7 *************************************************************************/
8
9 /*******************BEGIN ARCHITECTURE SECTION (part 1/2)****************/
10
11 /************************************************************************
12 FAUST Architecture File
13 Copyright (C) 2003-2011 GRAME, Centre National de Creation Musicale
14 ---------------------------------------------------------------------
15 This Architecture section is free software; you can redistribute it
16 and/or modify it under the terms of the GNU General Public License
17 as published by the Free Software Foundation; either version 3 of
18 the License, or (at your option) any later version.
19
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with this program; If not, see <http://www.gnu.org/licenses/>.
27
28 EXCEPTION : As a special exception, you may create a larger work
29 that contains this FAUST architecture section and distribute
30 that work under terms of your choice, so long as this FAUST
31 architecture section is not modified.
32
33
34 ************************************************************************
35 ************************************************************************/
36
37 #include <libgen.h>
38 #include <iostream>
39
40 #include "gui/FUI.h"
41 #include "misc.h"
42 #include "audio/portaudio-dsp.h"
43 #include "gui/faustgtk.h"
44
45 #ifdef OSCCTRL
46 #include "gui/OSCUI.h"
47 #endif
48
49 /**************************BEGIN USER SECTION **************************/
50 /******************************************************************************
51 *******************************************************************************
52
53 VECTOR INTRINSICS
54
55 *******************************************************************************
56 *******************************************************************************/
57
58 <<includeIntrinsic>>
59
60
61 <<includeclass>>
62
63 /***************************END USER SECTION ***************************/
64
65 /*******************BEGIN ARCHITECTURE SECTION (part 2/2)***************/
66
67 mydsp DSP;
68 list<GUI*> GUI::fGuiList;
69
70 //-------------------------------------------------------------------------
71 // MAIN
72 //-------------------------------------------------------------------------
73 #if 0
74 int main(int argc, char *argv[] )
75 {
76 gtk_init (&argc, &argv);
77 const char* name = basename(argv[0]);
78
79 char rcfilename[256];
80 char* home = getenv("HOME");
81 snprintf(rcfilename, 255, "%s/.%src", home, basename(argv[0]));
82
83 GUI* interface = new GTKUI (name, &argc, &argv);
84 DSP.buildUserInterface(interface);
85
86 #ifdef OSCCTRL
87 GUI* oscinterface = new OSCUI(jname, argc, argv);
88 DSP.buildUserInterface(oscinterface);
89 #endif
90
91 long srate = (long)lopt(argv, "--frequency", 44100);
92 int fpb = lopt(argv, "--buffer", 128);
93 portaudio audio (srate, fpb);
94
95 audio.init(name, &DSP);
96 //interface->recallState(rcfilename);
97 audio.start();
98
99 #ifdef OSCCTRL
100 oscinterface->run();
101 #endif
102 interface->run();
103
104 audio.stop();
105 //interface->saveState(rcfilename);
106 return 0;
107 }
108 #endif
109
110 long lopt(char *argv[], const char *name, long def)
111 {
112 int i;
113 for (i=0; argv[i]; i++) if (!strcmp(argv[i], name)) return atoi(argv[i+1]);
114 return def;
115 }
116
117 int main(int argc, char *argv[])
118 {
119 char appname[256];
120 char rcfilename[256];
121 char* home = getenv("HOME");
122
123 snprintf(appname, 255, "%s", basename(argv[0]));
124 snprintf(rcfilename, 255, "%s/.%src", home, appname);
125
126 GUI* interface = new GTKUI (appname, &argc, &argv);
127 FUI* finterface = new FUI();
128 DSP.buildUserInterface(interface);
129 DSP.buildUserInterface(finterface);
130
131 #ifdef OSCCTRL
132 GUI* oscinterface = new OSCUI(appname, argc, argv);
133 DSP.buildUserInterface(oscinterface);
134 #endif
135
136 long srate = (long)lopt(argv, "--frequency", 44100);
137 int fpb = lopt(argv, "--buffer", 128);
138
139 portaudio audio (srate, fpb);
140 audio.init(appname, &DSP);
141 finterface->recallState(rcfilename);
142 audio.start();
143
144 #ifdef OSCCTRL
145 oscinterface->run();
146 #endif
147 interface->run();
148
149 audio.stop();
150 finterface->saveState(rcfilename);
151 return 0;
152 }
153
154
155 /********************END ARCHITECTURE SECTION (part 2/2)****************/
156