Example #1
0
int main(int argc, char *argv[])
{
    char name[256];
    char rcfilename[256];
    char* home = getenv("HOME");

    snprintf(name, 255, "%s", basename(argv[0]));
    snprintf(rcfilename, 256, "%s/.%src", home, basename(argv[0]));

    long srate = (long)lopt(argv, "--frequency", 44100);
    int fpb = lopt(argv, "--buffer", 512);

#ifdef POLY
    int poly = lopt(argv, "--poly", 4);
    int group = lopt(argv, "--group", 1);

#if MIDICTRL
    if (hasMIDISync()) {
        DSP = new timed_dsp(new mydsp_poly(new mydsp(), poly, true, group));
    } else {
        DSP = new mydsp_poly(new mydsp(), poly, true, group);
    }
#else
    DSP = new mydsp_poly(new mydsp(), poly, false, group);
#endif

#else

#if MIDICTRL
    if (hasMIDISync()) {
        DSP = new timed_dsp(new mydsp());
    } else {
        DSP = new mydsp();
    }
#else
    DSP = new mydsp();
#endif

#endif
    if (DSP == 0) {
        std::cerr << "Unable to allocate Faust DSP object" << std::endl;
        exit(1);
    }

    QApplication myApp(argc, argv);

    QTGUI interface;
    FUI finterface;
    DSP->buildUserInterface(&interface);
    DSP->buildUserInterface(&finterface);

#ifdef MIDICTRL
    rt_midi midi_handler(name);
    MidiUI midiinterface(&midi_handler);
    DSP->buildUserInterface(&midiinterface);
    std::cout << "MIDI is on" << std::endl;
#endif

#ifdef HTTPCTRL
    httpdUI httpdinterface(name, DSP->getNumInputs(), DSP->getNumOutputs(), argc, argv);
    DSP->buildUserInterface(&httpdinterface);
    std::cout << "HTTPD is on" << std::endl;
#endif

#ifdef OSCCTRL
    OSCUI oscinterface(name, argc, argv);
    DSP->buildUserInterface(&oscinterface);
    std::cout << "OSC is on" << std::endl;
#endif

    rtaudio audio(srate, fpb);
    audio.init(name, DSP);
    finterface.recallState(rcfilename);
    audio.start();

    printf("ins %d\n", audio.getNumInputs());
    printf("outs %d\n", audio.getNumOutputs());

#ifdef HTTPCTRL
    httpdinterface.run();
#ifdef QRCODECTRL
    interface.displayQRCode(httpdinterface.getTCPPort());
#endif
#endif

#ifdef OSCCTRL
    oscinterface.run();
#endif
#ifdef MIDICTRL
    if (!midiinterface.run()) {
        std::cerr << "MidiUI run error\n";
    }
#endif
    interface.run();

    myApp.setStyleSheet(interface.styleSheet());
    myApp.exec();
    interface.stop();

#ifdef MIDICTRL
    midiinterface.stop();
#endif

    audio.stop();
    finterface.saveState(rcfilename);

    return 0;
}
Example #2
0
int main(int argc, char *argv[])
{
 	char appname[256];
	char rcfilename[256];
	char* home = getenv("HOME");

	snprintf(appname, 255, "%s", basename(argv[0]));
	snprintf(rcfilename, 255, "%s/.%src", home, appname);
    
    int poly = lopt(argv, "--poly", 4);
    
#if MIDICTRL
    rtmidi midi;
#endif
	
#ifdef POLY
#if MIDICTRL
    DSP = new mydsp_poly(poly, true);
    midi.addMidiIn(DSP);
#else
    DSP = new mydsp_poly(poly);
#endif
#else
    DSP = new mydsp();
#endif
    if (DSP == 0) {
        std::cerr << "Unable to allocate Faust DSP object" << std::endl;
        exit(1);
    }

    QApplication myApp(argc, argv);
    
    QTGUI interface;
    FUI finterface;
    DSP->buildUserInterface(&interface);
    DSP->buildUserInterface(&finterface);
    
#ifdef MIDICTRL
    MidiUI midiinterface(&midi);
    DSP->buildUserInterface(&midiinterface);
    std::cout << "MIDI is on" << std::endl;
#endif

#ifdef HTTPCTRL
	httpdUI httpdinterface(appname, DSP->getNumInputs(), DSP->getNumOutputs(), argc, argv);
	DSP->buildUserInterface(&httpdinterface);
    std::cout << "HTTPD is on" << std::endl;
#endif

#ifdef OSCCTRL
    OSCUI oscinterface(appname, argc, argv);
    DSP->buildUserInterface(&oscinterface);
    std::cout << "OSC is on" << std::endl;
#endif
	
	jackaudio audio;
	audio.init(appname, DSP);
	finterface.recallState(rcfilename);	
	audio.start();
    
    printf("ins %d\n", audio.get_num_inputs());
    printf("outs %d\n", audio.get_num_outputs());
    
#if MIDICTRL
    midi.start();
#endif
	
#ifdef HTTPCTRL
	httpdinterface.run();
#ifdef QRCODECTRL
    interface.displayQRCode(httpdinterface.getTCPPort());
#endif
#endif
	
#ifdef OSCCTRL
	oscinterface.run();
#endif
#ifdef MIDICTRL
	midiinterface.run();
#endif
	interface.run();
	
    myApp.setStyleSheet(interface.styleSheet());
    myApp.exec();
    interface.stop();
    
	audio.stop();
	finterface.saveState(rcfilename);
    
#if MIDICTRL
    midi.stop();
#endif
    
  	return 0;
}