1
2\documentclass[a4paper]{article}
3\usepackage{pslatex}
4\usepackage[T1]{fontenc}
5\usepackage[utf8x]{inputenc}
6\setlength\parskip{\medskipamount}
7\setlength\parindent{0pt}
8\usepackage{graphicx}
9\usepackage{amssymb}
10%\usepackage{hyperref}
11
12\usepackage{multicol}
13
14\makeatletter
15
16\providecommand{\boldsymbol}[1]{\mbox{\boldmath $#1$}}
17\newcommand{\ASL}			{ASL}
18\newcommand{\OSC}[1]		{\texttt{#1}}
19\newcommand{\lra}			{$\leftrightarrow$}
20\newcommand{\seg}[1]		{Seg(#1)}
21
22\setlength{\parskip}{1mm}
23
24\makeatother
25
26\begin{document}
27
28\title{FaustLive - Implementation \\ v.1.3}
29
30\author{Grame, Centre National de Création Musicale\\
31{\small <research@grame.fr>} \\
32\vspace{2mm}
33[ANR-12-CORD- 0009] and [ANR-13-BS02-0008]
34}
35
36\maketitle
37
38\topskip0pt
39
40\newpage
41\tableofcontents
42
43\newpage
44\section{General Considerations}
45
46\subsection{FaustLive}
47FaustLive is an advanced self-contained prototyping environment for the Faust programming language with an ultra-short edit-compile-run cycle. Thanks to its fully embedded compilation chain, FaustLive is simple to install and doesn't require any external compiler, development toolchain or SDK to run. FaustLive is the ideal tool for fast prototyping. Faust programs can be compiled and run on the fly by simple drag and drop. They can even be edited and recompiled while running without sound interruption or Jack disconnection. \\
48\\
49FaustLive is based on QT. Most classes are a reimplementation of QObjects.
50To know more about these base-objects, see QT documentation : http://qt-project.org/doc/qt-5/classes.html
51
52\subsection{Code Structure}
53
54FaustLive is based on three main classes : FLApp, FLWindow and FLSessionManager.
55
56\begin{itemize}
57\item FLApp is a reimplementation of QApplication. Its role is to be a communication center between the menus, dialogs, windows, etc.
58
59\item FLWindow reimplements QMainWindow. Its role is to contain the DSP, its interface(s) and react to the window's menus/actions/...
60
61\item FLSessionManager is a simple QObject. Its role is to be the compilation center and maintain the hierarchy of the current session.
62
63\end{itemize}
64
65Many of the dialogs and internal structure classes are singletons to share their information with one shared access point.
66
67%%%%%%%%%%%%%%%%%FAUSTLIVE APP%%%%%%%%%%%%%%%%%%%
68\section{FLApp}
69
70FLApp reimplements QApplication. For that matter, it contains the main event loop, where all events from the window system and other sources are processed and dispatched. It also handles the application's initialization (some singletons have to be initialized by FLApp) and finalization.
71
72\subsection{Menus}
73
74\subsubsection{Menu Creation}
75
76The menus are handled differently, depending on the platform. \\
77On OSX, the menu of the application appears in the system external menu-bar. Depending on the front window, the specific menu will show. \\
78On Windows and Linux, each window of the application has its own menu-bar. There is no general menu-bar. That is why, when the last window is closed, the application quits. \\
79
80While some actions are specific to the windows (edit, export, ...), others have to be treated by the application (new, open, ...). The application-related menus and actions have to be created by the application to be connected to its SLOTs.
81
82So, FLApp contains the following functions, for menu creation :
83\begin{itemize}
84\item create\_FileMenu() : QMenu*
85\item create\_ExampleMenu() : QMenu*
86\item create\_RecentFileMenu() : QMenu*
87\item create\_NavigateMenu() : QMenu*
88\item create\_HelpMenu() : QMenu*
89\end{itemize}
90
91Because a QMenu cannot be shared between multiple windows, a new one has to be created with each window creation. A list of menus is therefore passed to the window's constructor.
92
93\subsubsection{Menu Reactions}
94
95To react to the menu's actions, FLApp implements a number of SLOTs. These slots are connected to a particular action and contain the reaction. Therefore, most functions in FLApp are direct answers to the menus, handling, for example, the recent sessions and files, the navigation menu, etc.
96
97\subsection{Create a FLWindow}
98
99To create a FLWindow, the FLApp has to choose its settings. There are three different ways to get them  :
100
101\begin{itemize}
102\item Create new settings
103\item Recall existing settings
104\item Copy existing settings
105\end{itemize}
106
107In case the settings are new, some parameters have to be initialized like the index of the window (smallest not currently used), the position of the window on screen, ...
108
109Once the FLWindow is created, it is initialized with the Faust source.
110
111%%%%%%%%%%%%%%%%%WINDOW%%%%%%%%%%%%%%%%%
112\section{FLWindow}
113
114FLWindow reimplements QMainwindow. Its role is to create the environment of the DSP. It manages its graphical interface(s), its audio interface, etc. Moreover, FLWindow manages the menus, tool bar and status bar, wrapping the DSP's QTInterface.
115
116\subsection{Interface-s}
117
118One FLWindow contains multiple types of interface, some of which are optional.
119
120\begin{itemize}
121\item QTGUI : interface displayed in FLWindow
122\item FUI : interface saving the graphical parameters
123\item HTTPUI : interface handling the HTTP protocol for remote control
124\item OSCUI : interface handling the OSC protocol for remote control
125\item MIDIUI : interface handling the MIDI protocol
126\end{itemize}
127
128For each type of interface, FLWindow has a set of functions : allocate, buildUserInterface, run, delete. \\
129
130The synchronization between all the interfaces sharing a unique DSP is done in the QTGUI. The problem being that if we don't have this QTGUI (see some use cases described in RemoteFeature.tex), there is no synchronization. For that matter, a class called FLInterfaceManager has been created. It is not yet of a great interest but if those use cases are implemented, it will become essential.
131
132\subsection{Audio client}
133
134The structure of the audio classes is described in section \ref{Audio}.
135
136From the FLWindow point of view, the creation of an audio client is easy. An audioManager is retrieved from the "AudioCreator" and used mostly like any Faust audio, independently from the real audio driver.
137
138\begin{itemize}
139\item init\_audioClient : initializes the audio manager with the client name and the DSP's number of input and output.
140\item setDSP : second step of the audio initialization, by passing the DSP to the audio Manager
141\item audioShutDown : callback given to the audio manager. In case the audio driver is shut or stops, the FLWindow can take actions.
142\item start/stop\_Audio : self explanatory
143
144\end{itemize}
145\subsection{ToolBar}
146
147The class "FLToolBar" shapes the settings of the FLWindow. Whenever a change in the settings is applied, the toolbar reacts by emitting signals. So that from the FLWindow, we have this set of functions :
148
149\begin{itemize}
150\item set\_ToolBar : the toolbar has to be created and its signals connected to the window SLOTs
151\item resizingSmall/Big : close/open toolbar
152\item setWindowsOptions : the options contained in FLToolBar can be modified outside of the toolbar (OSCUI ports for example when already used), so they have to be synchronized
153\item modifiedOptions : reaction to the modification of the compilation options from toolbar
154\item generateAuxFiles : reaction to the modification of the automatic export options from toolbar
155\item switchOsc : enable/disable OSC interface
156\item updateOSCInterface : update OSC interface with new port options
157\item switchHttp : enable/disable HTTP interface
158\item switchMIDI : enable/disable MIDI interface
159\item switchRelease : enable/disable factory publication (not yet implemented)
160\item switchRemoteControl : enable/disable remote control interface (not yet implemented)
161\end{itemize}
162
163\subsection{StatusBar}
164
165The class "FLStatusBar" holds the processing machine parameter and creates the wrapping layout.
166
167\begin{itemize}
168\item set\_StatusBar : the status bar has to be created
169\item redirectSwitch : update the window with new machine option
170\end{itemize}
171
172\subsection{Menus}
173
174In the constructor, a list of Menus is given to the FLWindow. Moreover, a window-specific menu is added, giving an access point to the following features :
175
176\begin{itemize}
177\item edit : opens the file corresponding to the running DSP. If the DSP is not linked to a source file, the user has to save the DSP as a new file.
178\item paste : copies the content of the clipboard into the window, activating the update of the window.
179\item duplicate : sends a signal, captured by the application, for it to execute the duplication.
180\item view\_qrcode : activates the remote HTTP control and displays the QrCode, corresponding to the HTML interface.
181\item view\_svg : opens the corresponding svg-diagram in the default navigator.
182\item export\_file : opens the export manager, allowing the user to export its DSP
183\item shut : closes the window
184\end{itemize}
185
186\subsection{Drag and Drop}
187
188The FLWindow accepts the Drag and Drop of Faust code as .dsp files, strings, urls but also .wav files. It is set up for that in the constructor, through setAccetDrop(true). The related functions are :
189
190\begin{itemize}
191\item dragEnterEvent : describes the accepted mime-types (urls and strings)
192\item dropEvent : updates the window with the new Faust content
193\end{itemize}
194
195The FLWindow is also set up to accept "reversed" Drag and Drop. The dragged content is whether a file, a string or a url, depending on the original source of the DSP.
196
197\begin{itemize}
198\item pressEvent : activate reversed Drag and Drop action
199\item eventFilter : filters the mouse events when left mouse button is pressed.
200\end{itemize}
201
202%%%%%%%%%%%%%%%%%SESSION MANAGER%%%%%%%%%%%%%%%%%
203\section{FLSessionManager}
204
205FLSessionManager is a singleton.\\
206The role of FLSessionManager is to be the link with libfaust and libfaustremote, to compile the DSPs. Moreover, it has the purpose to maintain the hierarchy of the current session and be able to save/recall sessions and snapshots.
207
208\subsection{Current Session Hierarchy}
209
210The current session is saved in the user home directory and is called .FaustLive-CurrentSession-versionNumber. On Windows, you can configurate an environment variable FAUSTLIVE\_SESSIONDIR to specify an alternative directory name. \\
211The content of the session  is composed of :
212\begin{itemize}
213\item Settings.ini : file containing the saved settings as described in FLSettings (\ref{FLSettings}).
214\item Examples : folder containing a copy of the example files of the Faust distribution
215\item Libs : folder containing a copy of the libraries of the Faust distribution
216\item Windows : folder containing the window-specific folders FLW-i, containing :
217	\begin{itemize}
218		\item Settings.ini : the window specific settings as described in FLWinSettings (\ref{FLWinSettings}).
219		\item Graphics.rc : file saving the graphical parameters of the last DSP contained in the window
220		\item Connections.jc : file saving the last known Jack connections of the window
221		\item SHAKey.dsp* : copy of the Faust code of the last DSP contained in the window (in case the original file is deleted or modified outside of FaustLive execution)
222	\end{itemize}
223\item SHAFolder : folder containing the DSP-specific folders, containing :
224	\begin{itemize}
225		\item SHAKey* : LLVM intermediate representation of the DSP, to accelerate compilation when the same DSP is reused.
226		\item SHAKey.dsp*: copy of the Faust code corresponding to this SHAKey
227		\item SHAKey-svg* : folder containing the svg diagram resources
228	\end{itemize}
229\end{itemize}
230
231*To establish an injection between a DSP and its saving files, the SHA-1 hash function is used. This SHAKey is calculated from the Faust code before compilation and its compilation options. That way, one code, compiled with different options is always saved.
232
233\subsection{DSP compilation}
234
235To compile a DSP, there are two steps :
236\begin{itemize}
237\item create a factory (builds the protoype of a the DSP class)
238\item create an instance of the factory (equivalent of a 'new class" in C++)
239\end{itemize}
240
241Because FaustLive enables remote processing, the factories and instances it creates can whether be local (llvm\_dsp\_factory / llvm-dsp ) through libfaust or remote (remote\_dsp\_factory / remote-dsp) through libfaustremote. \\
242
243The goal of FLSession Manager is to be the only class that deals with remote\_dsp\_factory, llvm\_dsp\_factory, remote-dsp, llvm-dsp, ...
244
245The classes that will need compilation will only retrieve a pointer to a dsp, without knowing its type. \\
246
247Still, the two steps cannot be united in the same function, because some audio initialization is needed between the two steps (for the remote case where the sample rate and buffer size are needed to create the instance and only available once the factory is created...).
248
249In conclusion, to create a dsp, there are those two functions :
250\begin{itemize}
251\item createFactory(const QString\& source, QString\& errorMsg, FLWinSettings* settings = NULL) \\ returns QPair<QString, void*> ;
252\item createDSP(QPair<QString, void*> factorySetts, const QString\& source, QString\& errorMsg, FLWinSettings* settings = NULL, RemoteDSPErrorCallback error\_callback = NULL, void* error\_callback\_arg = NULL) \\ returns dsp*;
253\end{itemize}
254
255\subsubsection{Create A Factory}
256
257The creation of the factory is described on Figure \ref{fig:Step1} and \ref{fig:Step2}. The final compilation is accomplished through libfaust or libfaustremote, depending on the machineName (described in the settings) (see Figure  \ref{fig:Step2}). The factory is created from a file, saved in the current session and named after a SHAKey. \\
258
259The calculation of this key is presented on Figure  \ref{fig:Step1}. In this process, the compilation options are sorted, following a certain pattern, in order to have -vec -sch giving the same key than -sch -vec. Moreover, the source given to createFactory can be a string, a file, a web url or a wav file. The function sourceToFaustContent has the role to transform any kind of source into a compilable faust content.
260
261\begin{figure}[!h]
262\begin{center}
263\includegraphics[width=\columnwidth]{images/Step1_Compilation.png}
264\caption{Create Factory - Step 1}
265\label{fig:Step1}
266\vspace{0.5cm}
267\includegraphics[width=\columnwidth]{images/Step2_Compilation.png}
268\caption{Create Factory - Step 2}
269\label{fig:Step2}
270\end{center}
271\end{figure}
272
273\subsubsection{Create An Instance}
274
275This function creates a llvm\_dsp or a remote\_dsp depending on the type of factory passed to the function. Moreover, it saves the new window settings, in case of successfull compilation. The dsp returned is abstract, so that the FLWindow doesn't have the information of real type.
276
277\subsection{Delete Factories and Instances}
278
279Every DSP created is mapped to its factory, so that when you delete the DSP, FLSessionManager has a track of which factory to delete.
280
281\subsection{Session/Snapshot Restoration}
282
283When the user recalls a snapshot or opens FaustLive and wishes to have his last session restored, the system has to go through some restoration steps. Those operations have, as goal, to make sure that the resources needed by the session were not deleted or corrupted outside of FaustLive execution.
284
285\subsubsection{Current Session Restoration}
286
287In case of changes, the user has the choice between :
288\begin{itemize}
289\item using the internal copy of the file
290\item using the original file and recompile its new content
291\end{itemize}
292
293\subsubsection{Recall or Import Snapshots}
294
295In case of snapshot loading, the user is informed that a change was made in his files but the internal copy is always used. This choice was made, considering that when the user has made a snapshot, it is to reload the exact same state, he saved.
296
297\section{MIDI Control}
298
299Each DSP can be controlled by a separated MIDI in/out controler.
300
301%%%%%%%%%%%%%%%%%NETWORK%%%%%%%%%%%%%%%%%
302\section{Network Interactions}
303
304There are different types of remote interfaces, described below. But the logic of them is common. The idea is that each interface is built and runs separately from the FLWindow declaring it. But a central server is used to keep track of all interfaces. That way, a request to that server permits to have a view of all remote interfaces.
305
306\subsection{HTTP interface}
307The HttpdUi described in Faust is used to create an HTTP Interface, synchronized with the local interface. This component embeds a HTTP server in the application. \\
308Moreover, in FaustLive, a central server, called FLServerHttp, handles the Drag and Drop on the remote HTML Interface and centralizes the HttpdUis.
309
310Here is the list of request that can be made to the server :\\
311http://IPofLocalHost:portConfiguredInPreferences
312\begin{itemize}
313\item returns the main page of the server, containing only a drop zone for DSP files.
314\item {\it /portOfSpecificInterface} : adds the HTML page \\(http://IPofLocalHost:portOfSpecificInterface)\\ containing the interface to the main page. By default, the port is 5510.
315\item {\it /portOfSpecificInterface/JSON} : this request is redirected to the interface-specific server (http://IPofLocalHost:portOfSpecificInterface/JSON) and returns the JSON application describing the interface.
316\item {\it /availableInterfaces} : returns an HTML page describing all http interfaces available.
317\item {\it /availableInterfaces/Json} : returns the interfaces available as a JSON application.
318\end{itemize}
319
320\subsection{OSC interface}
321
322The OSC interfaces are, for now, only used as specific interfaces in the FLWindows. The central OSC server is not yet implemented.
323
324\subsection{Remote interface}
325
326Not yet implemented. See RemoteFeatures.tex.
327
328%%%%%%%%%%%%%%%%%SETTING STRUCTURE%%%%%%%%%%%%%%%%
329\section{Setting Management}
330
331%%%%%%%%%%%%%%%%%GENERAL SETTINGS%%%%%%%%%%%%%%%%%
332\subsection{FLSettings \label{FLSettings}}
333
334FLSettings is a singleton. \\
335It reimplements QSettings. A hierarchy, presented {Figure \ref{fig:FLSettings}, allows us to access the settings easily. \\
336
337The setting file is saved at the root of the current session (/Users/you/.FaustLiveCurrentSession-version).
338
339\begin{figure}[!h]
340\begin{center}
341\includegraphics[width=\columnwidth]{images/FLSettings}
342\caption{FLSettings structure}
343\label{fig:FLSettings}
344\end{center}
345\end{figure}
346
347For example, the value is accessible like this :\\
348\textit{int httpPort = FLSettings::\_Instance()->value("General/Network/HttpDropPort", defaultValue);}
349
350%%%%%%%%%%%%%%%%%WINDOW SETTINGS%%%%%%%%%%%%%%%%%
351\subsection{FLWinSettings \label{FLWinSettings}}
352
353FLWinSettings reimplements QSettings. But, this class is not a singleton, each FLWindow is associated to a FLWinSettings.
354
355\begin{figure}[!h]
356\begin{center}
357\includegraphics[width=\columnwidth]{images/FLWinSettings}
358\caption{FLWinSettings structure}
359\label{fig:FLWinSettings}
360\end{center}
361\end{figure}
362
363
364For example, the value is accesible like this :\\
365\textit{int oscInPort = fSettings->value("Osc/InPort", defaultValue);} \\
366
367The added feature of FLWinSettings, compared to QSettings, is to synchronize three parameters of the window with the general FLSettings. That way, Name, SHA and Path are also accessible from the FLSettings. This feature is really usefull for snaspshot and session restoration, to have a global vision of the existing windows.
368
369%%%%%%%%%%%%%%%%%FILE WATCHER%%%%%%%%%%%%%%%%%
370\section{FLFileWatcher}
371
372FLFileWatcher is a singleton. \\
373Its role is to maintain the list of files currently used in FaustLive as DSP source or dependency. When a file is modified, renamed or deleted, it is set to redirect the action to the file-corresponding window(s).
374
375Whenever the signal directoryChanged is received on a watched directory, the content is compared to the previous one, in order to know if a file was renamed (same number of children files but new name) or deleted.
376
377Whenever a watched file is modified in a text editor or another external application, the signal fileChanged is received. The FLWindow is therefore informed that it has to update.
378
379%%%%%%%%%%%%%%%%%MENUS AND DIALOGS%%%%%%%%%%%%%%%%%
380\section{Menus and Dialogs}
381
382Each type of dialog/window used by FaustLive has its own class. It is mostly describing the layout of the dialog and is redirecting the specific actions to the application, connecting the right SLOTs.
383
384\subsection{FLErrorWindow}
385
386FLErrorWindow reimplements QMainWindow. Its role is to displays all errors occurring in the program.
387FLErrorWindow is a singleton.
388
389\subsection{FLMessageWindow}
390
391FLMessageWindow reimplements QDialog. Its role is to displays messages printed by the program, like (Compiling DSP..., etc).
392FLMessageWindow is a singleton.
393
394\subsection{FLHelpDialog}
395
396FLHelpDialog reimplements QDialog. Its role is to display the help menu, for the user to get information of FaustLive uses.
397
398\subsection{FLPreferenceWindow}
399
400FLPreferenceWindow reimplements QMainWindow. Its role is to display the preferences of FaustLive and to handle the changes of settings.
401
402\subsection{FLPresentationWindow}
403
404FLPresentationWindow reimplements QMainWindow. Its role is to display the presentation menu.
405
406\subsection{FLExportManager}
407
408FLExportManager contains two classes classes describing the two dialogs used in the export process. The first dialog presents all the targets available. The second one shows the progress of the export.
409
410%%%%%%%%%%%%%%%%%AUDIO STRUCTURE%%%%%%%%%%%%%%%%%
411\section{Audio \label{Audio}}
412
413In this section, we discuss the way the audio rendering is managed in FaustLive (see also the Appendix).
414First, will be described the type of audio driver used into FaustLive and how the linking is done. Then, the algorithm of the crossfade will be explained, taking care of smoothing the transition between two DSPs relaying in the same window.
415
416\subsection{Audio drivers used by FaustLive}
417
418Depending on the operating system and the compiling options, it is possible to embed different audio architectures in FaustLive.
419Default drivers are :
420\begin{itemize}
421\item CoreAudio on OSX
422\item JACK on Linux
423\item PortAudio on Windows
424\end{itemize}
425
426Then JACK, NetJack and PortAudio can be added with make options : JACK=1 NETJACK=1 PORTAUDIO=1.
427
428\subsection{Code Organisation}
429
430The general structure of the code is based on the "abstract factory" pattern. That way, the class "AudioCreator" is the only class knowing which type of driver is used. It is the intermediary between the FLWindow, handling the audio client, and the driver-specific elements.  \\
431
432The abstract factory contains the following pure virtual functions :
433\begin{itemize}
434\item createAudioSettings(QGroupBox* parent)
435\item createAudioManager(AudioShutDownCallaback, void* arg)
436\end{itemize}
437
438Then each audio driver has its own set of classes :
439\begin{itemize}
440\item audioFactory : creates the driver-specific elements through the reimplementation of createAudioSettings and createAudioManager.
441\item audioSettings : contains the settings needed by the driver and their graphical representation (for example a buffer size, a sample rate, ...)
442\item audioFader : mixes the audio and crossfade features
443\item audioManager : manipulates the audio faders and manages their crossfades
444\end{itemize}
445
446\subsection{Crossfade implementation}
447
448The specification is to smooth the transition between two relaying DSPs in a situation of drag and drop or source edition. If a DSP algorithm is not modified, the transition should not be hearable. \\
449
450Now, to implement this function, some functions are common to all architectures (implement\_crossfade, reset\_crossfade\_values, launch\_crossfade, etc). These features are divided in two classes \footnote{The separation between interface and implementation sometimes had to be made because some audio classes (like coreaudio-dsp) already made the difference (coreaudio/TCoreAudioRenderer). } :
451\begin{itemize}
452\item AudioFader\_Interface : containing the basic instructions needed by the client to launch a crossfade and know when it stopped.
453\item AudioFader\_Implementation : containing the calculation functions of the crossfade. This class holds the duration of a crossfade, described as a number of audio cycles.
454\end{itemize}
455
456The crossfade functions are mixed to the audio features in the driver-specific audioFader classes, by doble inheritance.
457
458\subsection{AudioManager}
459
460The role of the audio manager is to manipulate the audioFader(s) and manage the crossfade. Depending on the driver, there are two approaches of structure :
461\begin{itemize}
462\item the one managing one audioFader and fading two DSPs in its "process" function (JACK)
463\item the one managing two audioFaders, relaying with a fade in for one part and a fade out for the other (CoreAudio, NetJack, PortAudio)
464\end{itemize}
465
466\subsection{How to add a new audio architecture}
467
468To add a new type of driver audio in FaustLive, the first step is to implement the driver-specific set of classes :
469\begin{itemize}
470\item audioFactory
471\item audioSettings
472\item audioManager
473\item audioFader
474\end{itemize}
475
476Then, some elements have to be added to the class "AudioCreator" :
477\begin{itemize}
478\item add the new architecture to the enum "AudioArchitecture"
479\item add a new item in the comboBox "fAudioArchitecture"
480\item add a new case in createFactory
481\end{itemize}
482
483Finally, FaustLive.pro has to be modified (for each platform compatible with the new driver), in order to add the librairies (through conditional compilation).
484
485%%%%%%%%%%%%%%%%%REMOTE INTERFACES%%%%%%%%%%%%%%%%%
486\section{FLComponentWindow}
487
488The component window is a feature allowing the user to compose DSPs in a parallel/sequence/recursive way to create a new DSP.
489As in the FLWindow, it is possible to drop files and urls, so that you can combine elements from the web with local DSPs.
490
491\subsection{Component creation}
492
493The resulting DSP is a sequence of "stereoized parallel DSPs" : DSPs are first composed in parallel, then stereoized (see stereoize in music.lib) and finally put in sequence. The recursive loop is then applied with the function recursivize. \\
494Through this process, the resulting DSP is stereo, whatever DSPs were used as components.
495
496\subsection{Layout optimization}
497
498An "optimized" layout for the resulting DSP is calculated, taking as goal to reduce the surface of the interface. In order to do that, a binary tree of items is created. In this tree there are three types of elements :
499\begin{itemize}
500\item leaf nodes : containing the real faust interface
501\item vertical containers, putting in a vertical group it's two sub-nodes
502\item horizontal containers, putting in a horizontal group it's two sub-nodes.
503\end{itemize}
504
505Each element of the tree has a function render, so that called on the root node, the whole layout is calculated.
506
507%%%%%%%%%%%%%%%%%DISTRIBUTION STRUCTURE%%%%%%%%%%%%%%%%%
508\section{Distribution Structure}
509
510FaustLive's distribution has the following hierarchy :
511\begin{itemize}
512\item Build : Plateform-specific Makefiles and resources
513\item Documentation : Faust and FaustLive documentation
514\item Resources : examples, libs and all resources needed within FaustLive
515\item src : all the sources of FaustLive, structured as :
516\begin{itemize}
517\item Audio : containing the audio classes, depending on the driver architecture
518\item MainStructure : center of FaustLive, containing the three main classes : FLApp, FLWindow and FLSessionManager
519\item MenusAndDialogs
520\item Network : containing the server(s) embedded in FaustLive (FLHttpServer, coming soon FLOscServer)
521\item Utilities
522\end{itemize}
523\end{itemize}
524
525\subsection{Compile and Install}
526
527Whichever platform you are on, you will have to install some libraries to be able to compile FaustLive :
528\begin{itemize}
529\item faust / faustremote / httpdfaust
530\item jack2 (unix/windows) or portaudio (windows)
531\item libopenssl
532\item libmicrohttpd
533\item libqrencode
534\item libcurl
535\item llvm
536\item libcrypto
537\item liblo
538\end{itemize}
539
540You can whether download the packages and compile them yourself or get them through apt-get, macport, brew or some other package installer.
541
542\subsubsection{Unix}
543
544Once you installed all that, you can execute : \\
545{\it cd yourFaustLiveDirectory} \\
546{\it make} (JACK=1 NETJACK=1 PORTAUDIO=1 REMOTE=1 depending on the options you want to enable)\\
547{\it sudo make install}
548
549\subsubsection{Windows}
550
551On Windows, you will have to modify FaustLive.pro with your own paths, depending on where you compiled the needed librairies. \\
552
553Then you can execute : \\
554{\it qmake -spec win32-msvc2012 (depending on your version of Visual Studio) JVAR=1 NJVAR=1 PAVAR=1 REMVAR=1 (depending on the options you want to enable)} \\
555The solution created can be added in a new solution, that you can build and run.
556
557\subsection{Create a new distribution}
558
559\subsubsection{Unix}
560
561The idea is to create a self-contained application. Therefore, the dependent librairies have to be statically compiled. The following librairies can be easily downloaded and compiled with :
562
563\begin{multicols}{2}
564
565\begin{itemize}
566\item libqrencode
567\item libmicrohttpd
568\item libcurl
569\item libsndfile
570\end{itemize}
571
572
573./configure - -enable-static \\
574make \\
575sudo make install \\
576\end{multicols}
577
578Then, once those libraries are compiled, you can execute {\it make dist} in FaustLive's directory.
579
580\subsubsection{Windows}
581
582To create an installer with FaustLive.exe, you have to install InnoSetup. Then you can modify setup\_file.iss to your needs and run it.
583
584\section{Appendix}
585
586\begin{figure}[!h]
587\begin{center}
588\includegraphics[width=\columnwidth]{images/newAudioStructure}
589\caption{Audio Drivers Structure}
590\label{fig:FLWinSettings}
591\end{center}
592\end{figure}
593
594\end{document}
595
596
597
598
599