1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
|
/************************************************************************
************************************************************************
FAUST compiler
Copyright (C) 2003-2013 GRAME, Centre National de Creation Musicale
---------------------------------------------------------------------
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
************************************************************************
************************************************************************/
//
// main.cpp
//
//
// Created by Sarah Denoux on 30/05/13.
// Copyright (c) 2013 GRAME. All rights reserved.
//
//
// MAIN OF DYNAMIC COMPILER
//
//-------------------------------------------------------------------------
// MAIN
//-------------------------------------------------------------------------
// Example:
// ./RemoteClient --file freeverb.dsp --portserver 7778 --ipserver 127.0.0.1
#include <sys/stat.h>
#include <iostream>
#include "../../utilities.h"
#include "faust/dsp/remote-dsp.h"
#include "faust/gui/QTUI.h"
#include "faust/audio/coreaudio-dsp.h"
#include "faust/audio/jack-dsp.h"
std::list<GUI*> GUI::fGuiList;
ztimedmap GUI::gTimedZoneMap;
int main(int argc, const char* argv[])
{
list<QTGUI*> listInterfaces;
list<remote_dsp*> listDSPs;
list<remote_dsp_factory*> listFactories;
list<audio*> listAudios;
if (argv[1] && !strcmp(argv[1], "--help")){
printf("\nOPTIONS OF FAUST DISTRIBUTED : \n\n\
########### REMOTE CALCULATION PARAMETERS ############\n\
--ipserver ==> default is localhost\n\
--portserver ==> default is 7777 \n\
--frequency ==> default is 44100 \n\
--buffer ==> default is 512 \n\n\
########### NET JACK PARAMETER #######################\n\
--NJ_ip ==> MULTICAST_DEFAULT_IP \n\
--NJ_port ==> MULTICAST_DEFAULT_PORT\n\
--NJ_compression ==> default is -1\n\
--NJ_mtu ==> default is 1500\n\
--NJ_latency ==>default is 2 \n\
########### DSP TO BE REMOTLY COMPILED ###############\n\
--file ==> no DSP = no application\n\
--n ==> indicates the number of instances of DSP \n\n\
You can also add faust compilation options\n\
-vec/-sch/...\n\
\n");
return 0;
}
string ipServer = loptions(argv, "--ipserver", "localhost");
int portServer = lopt(argv, "--portserver", 7777);
int srate = lopt(argv, "--frequency", 44100);
int fpb = lopt(argv, "--buffer", 512);
printf("srate = %i fpb = %i\n", srate, fpb);
QApplication myApp(argc, (char**)argv);
for (int i = 0; i < argc; i++){
char filePath[256];
int numberInstances = lopt_spe(i, argv, "--file", filePath);
if (numberInstances != 0) {
if (numberInstances > 1) i += 2;
string errorFactory("");
const char* arguments[argc];
int nbArgument = 0;
for (int i = 1; i < argc; i++) {
if (string(argv[i]).find("--") != string::npos) {
i ++;
} else {
arguments[nbArgument] = argv[i];
nbArgument++;
}
}
arguments[nbArgument++] = "-machine";
string content = pathToContent(filePath);
remote_dsp_factory* factory = createRemoteDSPFactoryFromString("FaustRemote", content, nbArgument, arguments, ipServer, portServer, errorFactory, 3);
if (factory != NULL) {
listFactories.push_back(factory);
for (int j = 0; j < numberInstances; j++) {
int errorInstance;
remote_dsp* DSP = createRemoteDSPInstance(factory, argc, (const char**)(argv), NULL, NULL, errorInstance);
if (DSP != NULL) {
QTGUI* interface = new QTGUI();
listInterfaces.push_back(interface);
listDSPs.push_back(DSP);
// jackaudio* audio = new jackaudio;
coreaudio* audio = new coreaudio(srate, fpb);
listAudios.push_back(audio);
DSP->buildUserInterface(interface);
if (!audio->init("Test", DSP)) {
break;
} else {
printf("INIT\n");
}
if (!audio->start()) {
break;
} else {
printf("START\n");
}
interface->run();
} else {
printf("CREATE INSTANCE FAILED = %d\n", errorInstance);
}
}
} else {
printf("CREATE FACTORY FAILED = %s\n", errorFactory.c_str());
}
}
}
//myApp.setStyleSheet(STYLESHEET);
myApp.exec();
// STOP && DESALLOCATION OF ALL RESOURCES
list<QTGUI*>::iterator itI = listInterfaces.begin();
list<remote_dsp*>::iterator itD = listDSPs.begin();
list<remote_dsp_factory*>::iterator itF = listFactories.begin();
list<audio*>::iterator itA = listAudios.begin();
while (itI != listInterfaces.end()){
(*itI)->stop();
itI++;
}
listInterfaces.clear();
while (itA != listAudios.end()){
(*itA)->stop();
itA++;
}
listAudios.clear();
while (itA != listAudios.end()){
(*itA)->stop();
itA++;
}
listAudios.clear();
while (itD != listDSPs.end()){
deleteRemoteDSPInstance(*itD);
itD++;
}
listDSPs.clear();
while(itF != listFactories.end()){
deleteRemoteDSPFactory(*itF);
itF++;
}
listFactories.clear();
return 0;
}
|