Mercurial > hg > touchkeys
changeset 50:114427cb39f0
Changes to allow software to be run from the command line (still needs testing)
line wrap: on
line diff
--- a/Source/GUI/ControlWindowMainComponent.cpp Mon Apr 13 19:30:27 2015 -0700 +++ b/Source/GUI/ControlWindowMainComponent.cpp Mon Apr 13 20:51:17 2015 -0700 @@ -17,7 +17,9 @@ ============================================================================== */ + //[Headers] You can add your own extra header files here... +#ifndef TOUCHKEYS_NO_GUI #include "KeyboardZoneComponent.h" //[/Headers] @@ -958,4 +960,5 @@ //[EndFile] You can add extra defines here... +#endif // TOUCHKEYS_NO_GUI //[/EndFile]
--- a/Source/GUI/ControlWindowMainComponent.h Mon Apr 13 19:30:27 2015 -0700 +++ b/Source/GUI/ControlWindowMainComponent.h Mon Apr 13 20:51:17 2015 -0700 @@ -21,6 +21,8 @@ #define __JUCE_HEADER_FD693E32C8291DFA__ //[Headers] -- You can add your own extra header files here -- +#ifndef TOUCHKEYS_NO_GUI + #include "JuceHeader.h" #include "../MainApplicationController.h" //[/Headers] @@ -131,6 +133,7 @@ }; //[EndFile] You can add extra defines here... +#endif // TOUCHKEYS_NO_GUI //[/EndFile] #endif // __JUCE_HEADER_FD693E32C8291DFA__
--- a/Source/GUI/KeyboardZoneComponent.cpp Mon Apr 13 19:30:27 2015 -0700 +++ b/Source/GUI/KeyboardZoneComponent.cpp Mon Apr 13 20:51:17 2015 -0700 @@ -18,6 +18,7 @@ */ //[Headers] You can add your own extra header files here... +#ifndef TOUCHKEYS_NO_GUI //[/Headers] #include "KeyboardZoneComponent.h" @@ -799,4 +800,5 @@ //[EndFile] You can add extra defines here... +#endif // TOUCHKEYS_NO_GUI //[/EndFile]
--- a/Source/GUI/KeyboardZoneComponent.h Mon Apr 13 19:30:27 2015 -0700 +++ b/Source/GUI/KeyboardZoneComponent.h Mon Apr 13 20:51:17 2015 -0700 @@ -21,6 +21,8 @@ #define __JUCE_HEADER_E3CF42F64919BE28__ //[Headers] -- You can add your own extra header files here -- +#ifndef TOUCHKEYS_NO_GUI + #include "JuceHeader.h" #include "MappingListComponent.h" #include "../MainApplicationController.h" @@ -169,6 +171,7 @@ }; //[EndFile] You can add extra defines here... +#endif // TOUCHKEYS_NO_GUI //[/EndFile] #endif // __JUCE_HEADER_E3CF42F64919BE28__
--- a/Source/GUI/MainWindow.cpp Mon Apr 13 19:30:27 2015 -0700 +++ b/Source/GUI/MainWindow.cpp Mon Apr 13 20:51:17 2015 -0700 @@ -20,6 +20,8 @@ MainWindow.cpp: the control window, plus menu bar and Juce application methods */ +#ifndef TOUCHKEYS_NO_GUI + #include "../../JuceLibraryCode/JuceHeader.h" #include "MainWindow.h" @@ -371,3 +373,5 @@ item->clearPreset(); } } + +#endif // TOUCHKEYS_NO_GUI \ No newline at end of file
--- a/Source/GUI/MainWindow.h Mon Apr 13 19:30:27 2015 -0700 +++ b/Source/GUI/MainWindow.h Mon Apr 13 20:51:17 2015 -0700 @@ -23,6 +23,8 @@ #ifndef MAINWINDOW_H_INCLUDED #define MAINWINDOW_H_INCLUDED +#ifndef TOUCHKEYS_NO_GUI + #include "../../JuceLibraryCode/JuceHeader.h" #include "ControlWindowMainComponent.h" #include "../MainApplicationController.h" @@ -120,5 +122,6 @@ JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindow) }; +#endif // TOUCHKEYS_NO_GUI #endif // MAINWINDOW_H_INCLUDED
--- a/Source/GUI/MappingEditorComponent.h Mon Apr 13 19:30:27 2015 -0700 +++ b/Source/GUI/MappingEditorComponent.h Mon Apr 13 20:51:17 2015 -0700 @@ -25,6 +25,8 @@ #ifndef __MAPPINGEDITORCOMPONENT_H_C93E7296__ #define __MAPPINGEDITORCOMPONENT_H_C93E7296__ +#ifndef TOUCHKEYS_NO_GUI + #include "../../JuceLibraryCode/JuceHeader.h" //============================================================================== @@ -84,5 +86,6 @@ JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MappingEditorComponent) }; +#endif // TOUCHKEYS_NO_GUI #endif // __MAPPINGEDITORCOMPONENT_H_C93E7296__
--- a/Source/GUI/MappingExtendedEditorWindow.h Mon Apr 13 19:30:27 2015 -0700 +++ b/Source/GUI/MappingExtendedEditorWindow.h Mon Apr 13 20:51:17 2015 -0700 @@ -11,6 +11,8 @@ #ifndef MAPPINGEXTENDEDEDITORWINDOW_H_INCLUDED #define MAPPINGEXTENDEDEDITORWINDOW_H_INCLUDED +#ifndef TOUCHKEYS_NO_GUI + #include "../../JuceLibraryCode/JuceHeader.h" #include "../TouchKeys/MidiKeyboardSegment.h" #include "../Mappings/MappingFactory.h" @@ -89,5 +91,6 @@ JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MappingExtendedEditorWindow) }; +#endif // TOUCHKEYS_NO_GUI #endif // MAPPINGEXTENDEDEDITORWINDOW_H_INCLUDED
--- a/Source/GUI/PreferencesComponent.cpp Mon Apr 13 19:30:27 2015 -0700 +++ b/Source/GUI/PreferencesComponent.cpp Mon Apr 13 20:51:17 2015 -0700 @@ -18,6 +18,7 @@ */ //[Headers] You can add your own extra header files here... +#ifndef TOUCHKEYS_NO_GUI #include "../MainApplicationController.h" //[/Headers] @@ -248,4 +249,5 @@ //[EndFile] You can add extra defines here... +#endif // TOUCHKEYS_NO_GUI //[/EndFile]
--- a/Source/GUI/PreferencesComponent.h Mon Apr 13 19:30:27 2015 -0700 +++ b/Source/GUI/PreferencesComponent.h Mon Apr 13 20:51:17 2015 -0700 @@ -21,6 +21,7 @@ #define __JUCE_HEADER_248C56742F074362__ //[Headers] -- You can add your own extra header files here -- +#ifndef TOUCHKEYS_NO_GUI #include "JuceHeader.h" class MainApplicationController; @@ -91,6 +92,7 @@ }; //[EndFile] You can add extra defines here... +#endif // TOUCHKEYS_NO_GUI //[/EndFile] #endif // __JUCE_HEADER_248C56742F074362__
--- a/Source/GUI/PreferencesWindow.h Mon Apr 13 19:30:27 2015 -0700 +++ b/Source/GUI/PreferencesWindow.h Mon Apr 13 20:51:17 2015 -0700 @@ -11,6 +11,8 @@ #ifndef PREFERENCESWINDOW_H_INCLUDED #define PREFERENCESWINDOW_H_INCLUDED +#ifndef TOUCHKEYS_NO_GUI + #include "../../JuceLibraryCode/JuceHeader.h" #include "PreferencesComponent.h" #include "../MainApplicationController.h" @@ -62,5 +64,6 @@ JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PreferencesWindow) }; +#endif // TOUCHKEYS_NO_GUI #endif // PREFERENCESWINDOW_H_INCLUDED
--- a/Source/Main.cpp Mon Apr 13 19:30:27 2015 -0700 +++ b/Source/Main.cpp Mon Apr 13 20:51:17 2015 -0700 @@ -107,7 +107,8 @@ {"touchkeys", required_argument, NULL, 't'}, {"midi-input", required_argument, NULL, 'i'}, {"midi-output", required_argument, NULL, 'o'}, - {"virtual-midi-output", no_argument, NULL, 'O'}, + {"virtual-midi-output", no_argument, NULL, 'V'}, + {"osc-input-port", required_argument, NULL, 'P'}, {0,0,0,0} }; @@ -120,10 +121,11 @@ cerr << "Usage: " << processName << " [-h] [-l] [-t touchkeys] [-i MIDI-in] [-o MIDI-out]\n"; cerr << " -h: Print this menu\n"; cerr << " -l: List available TouchKeys and MIDI devices\n"; - cerr << " -t: Specify TouchKeys device path\n"; + cerr << " -t: Specify TouchKeys device path and autostart\n"; cerr << " -i: Specify MIDI input device\n"; cerr << " -o: Specify MIDI output device\n"; - cerr << " -O: Open virtual MIDI output\n"; + cerr << " -V: Open virtual MIDI output\n"; + cerr << " -P: Specify OSC input port (default: " << kDefaultOscReceivePort << ")\n"; } void list_devices(MainApplicationController& controller) @@ -167,13 +169,17 @@ int main (int argc, char* argv[]) { MainApplicationController controller; + int ch, option_index; int midiInputNum = 0, midiOutputNum = 0; bool useVirtualMidiOutput = false; bool shouldStart = true; + bool autostartTouchkeys = false; + bool autoopenMidiOut = false, autoopenMidiIn = false; + int oscInputPort = kDefaultOscReceivePort; string touchkeysDevicePath; - while((ch = getopt_long(argc, argv, "hli:o:t:O", long_options, &option_index)) != -1) + while((ch = getopt_long(argc, argv, "hli:o:t:VP:", long_options, &option_index)) != -1) { if(ch == 'l') { // List devices list_devices(controller); @@ -182,15 +188,22 @@ } else if(ch == 't') { // TouchKeys device touchkeysDevicePath = optarg; + autostartTouchkeys = true; } else if(ch == 'i') { // MIDI input device midiInputNum = atoi(optarg); + autoopenMidiIn = true; } else if(ch == 'o') { // MIDI output device midiOutputNum = atoi(optarg); + autoopenMidiOut = true; } - else if(ch == 'O') { // Virtual MIDI output + else if(ch == 'V') { // Virtual MIDI output useVirtualMidiOutput = true; + autoopenMidiOut = true; + } + else if(ch == 'P') { // OSC port + oscInputPort = atoi(optarg); } else { usage(basename(argv[0])); @@ -199,67 +212,68 @@ } } + if(shouldStart) { // Main initialization: open TouchKeys and MIDI devices + controller.initialise(); + + // Always enable OSC input without GUI, since it is how we control + // the system + controller.oscReceiveSetPort(oscInputPort); + controller.oscReceiveSetEnabled(true); + try { - // Check whether TouchKeys device was specified. If not, take the first available one. - /*if(touchkeysDevicePath == "") { - std::vector<std::string> touchkeysDevices = controller.availableTouchkeyDevices(); - - if(touchkeysDevices.empty()) { - cout << "No TouchKeys devices found. Check that the TouchKeys are connected.\n"; - throw new exception; + // Open MIDI devices + if(autoopenMidiIn) { + cout << "Opening MIDI input device " << midiInputNum << endl; + controller.enableMIDIInputPort(midiInputNum, true); + } + + // TODO: enable multiple keyboard segments + if(autoopenMidiOut) { + if(useVirtualMidiOutput) { +#ifndef JUCE_WINDOWS + cout << "Opening virtual MIDI output\n"; + controller.enableMIDIOutputVirtualPort(0, "TouchKeys"); +#endif } else { - touchkeysDevicePath = "/dev/"; - touchkeysDevicePath.append(touchkeysDevices[0]); + cout << "Opening MIDI output device " << midiOutputNum << endl; + controller.enableMIDIOutputPort(0, midiOutputNum); } - }*/ - - // Open MIDI devices - //cout << "Opening MIDI input device " << midiInputNum << endl; - //controller.enableMIDIInputPort(midiInputNum); - - // TODO: enable multiple keyboard segments - if(useVirtualMidiOutput) { -#ifndef JUCE_WINDOWS - cout << "Opening virtual MIDI output\n"; - controller.enableMIDIOutputVirtualPort(0, "TouchKeys"); -#endif - } - else { - cout << "Opening MIDI output device " << midiOutputNum << endl; - controller.enableMIDIOutputPort(0, midiOutputNum); } // Start the TouchKeys - cout << "Starting the TouchKeys on " << touchkeysDevicePath << " ... "; - if(!controller.touchkeyDeviceStartupSequence(touchkeysDevicePath.c_str())) { - cout << "failed: " << controller.touchkeyDeviceErrorMessage() << endl; - throw new exception; + if(autostartTouchkeys) { + cout << "Starting the TouchKeys on " << touchkeysDevicePath << " ... "; + if(!controller.touchkeyDeviceStartupSequence(touchkeysDevicePath.c_str())) { + cout << "failed: " << controller.touchkeyDeviceErrorMessage() << endl; + throw new exception; + } + else + cout << "succeeded!\n"; } - else - cout << "succeeded!\n"; // Set up interrupt catching so we can stop with Ctrl-C - /*struct sigaction sigIntHandler; + struct sigaction sigIntHandler; sigIntHandler.sa_handler = sigint_handler; sigemptyset(&sigIntHandler.sa_mask); sigIntHandler.sa_flags = 0; sigaction(SIGINT, &sigIntHandler, NULL); + // Wait until interrupt signal is received while(!programShouldStop_) { Thread::sleep(50); - }*/ - - Thread::sleep(1000); - - cout << "Cleaning up...\n"; + } } catch(...) { } + + // Stop TouchKeys if still running + if(controller.touchkeyDeviceIsRunning()) + controller.stopTouchkeyDevice(); } // Clean up any MessageManager instance that JUCE creates
--- a/Source/MainApplicationController.cpp Mon Apr 13 19:30:27 2015 -0700 +++ b/Source/MainApplicationController.cpp Mon Apr 13 20:51:17 2015 -0700 @@ -200,7 +200,9 @@ touchkeyErrorMessage_ = ""; touchkeyErrorOccurred_ = false; +#ifndef TOUCHKEYS_NO_GUI showKeyboardDisplayWindow(); +#endif // Automatically detect the lowest octave if set if(getPrefsAutodetectOctave())
--- a/Source/Mappings/Control/TouchkeyControlMappingExtendedEditor.cpp Mon Apr 13 19:30:27 2015 -0700 +++ b/Source/Mappings/Control/TouchkeyControlMappingExtendedEditor.cpp Mon Apr 13 20:51:17 2015 -0700 @@ -18,6 +18,7 @@ */ //[Headers] You can add your own extra header files here... +#ifndef TOUCHKEYS_NO_GUI //[/Headers] #include "TouchkeyControlMappingExtendedEditor.h" @@ -748,4 +749,5 @@ //[EndFile] You can add extra defines here... +#endif // TOUCHKEYS_NO_GUI //[/EndFile]
--- a/Source/Mappings/Control/TouchkeyControlMappingExtendedEditor.h Mon Apr 13 19:30:27 2015 -0700 +++ b/Source/Mappings/Control/TouchkeyControlMappingExtendedEditor.h Mon Apr 13 20:51:17 2015 -0700 @@ -21,6 +21,8 @@ #define __JUCE_HEADER_AD461861885EB942__ //[Headers] -- You can add your own extra header files here -- +#ifndef TOUCHKEYS_NO_GUI + #include "JuceHeader.h" #include "TouchkeyControlMappingFactory.h" //[/Headers] @@ -105,6 +107,7 @@ }; //[EndFile] You can add extra defines here... +#endif // TOUCHKEYS_NO_GUI //[/EndFile] #endif // __JUCE_HEADER_AD461861885EB942__
--- a/Source/Mappings/Control/TouchkeyControlMappingShortEditor.cpp Mon Apr 13 19:30:27 2015 -0700 +++ b/Source/Mappings/Control/TouchkeyControlMappingShortEditor.cpp Mon Apr 13 20:51:17 2015 -0700 @@ -18,6 +18,7 @@ */ //[Headers] You can add your own extra header files here... +#ifndef TOUCHKEYS_NO_GUI //[/Headers] #include "TouchkeyControlMappingShortEditor.h" @@ -344,4 +345,5 @@ //[EndFile] You can add extra defines here... +#endif // TOUCHKEYS_NO_GUI //[/EndFile]
--- a/Source/Mappings/Control/TouchkeyControlMappingShortEditor.h Mon Apr 13 19:30:27 2015 -0700 +++ b/Source/Mappings/Control/TouchkeyControlMappingShortEditor.h Mon Apr 13 20:51:17 2015 -0700 @@ -21,6 +21,8 @@ #define __JUCE_HEADER_61C9A7081A6F3E0__ //[Headers] -- You can add your own extra header files here -- +#ifndef TOUCHKEYS_NO_GUI + #include "JuceHeader.h" #include "TouchkeyControlMappingFactory.h" //[/Headers] @@ -84,6 +86,7 @@ }; //[EndFile] You can add extra defines here... +#endif // TOUCHKEYS_NO_GUI //[/EndFile] #endif // __JUCE_HEADER_61C9A7081A6F3E0__
--- a/Source/Mappings/MultiFingerTrigger/TouchkeyMultiFingerTriggerMappingShortEditor.cpp Mon Apr 13 19:30:27 2015 -0700 +++ b/Source/Mappings/MultiFingerTrigger/TouchkeyMultiFingerTriggerMappingShortEditor.cpp Mon Apr 13 20:51:17 2015 -0700 @@ -18,6 +18,7 @@ */ //[Headers] You can add your own extra header files here... +#ifndef TOUCHKEYS_NO_GUI //[/Headers] #include "TouchkeyMultiFingerTriggerMappingShortEditor.h" @@ -272,4 +273,5 @@ //[EndFile] You can add extra defines here... +#endif // TOUCHKEYS_NO_GUI //[/EndFile]
--- a/Source/Mappings/MultiFingerTrigger/TouchkeyMultiFingerTriggerMappingShortEditor.h Mon Apr 13 19:30:27 2015 -0700 +++ b/Source/Mappings/MultiFingerTrigger/TouchkeyMultiFingerTriggerMappingShortEditor.h Mon Apr 13 20:51:17 2015 -0700 @@ -21,6 +21,8 @@ #define __JUCE_HEADER_575F04D6673EEA8A__ //[Headers] -- You can add your own extra header files here -- +#ifndef TOUCHKEYS_NO_GUI + #include "JuceHeader.h" #include "TouchkeyMultiFingerTriggerMappingFactory.h" //[/Headers] @@ -81,6 +83,7 @@ }; //[EndFile] You can add extra defines here... +#endif // TOUCHKEYS_NO_GUI //[/EndFile] #endif // __JUCE_HEADER_575F04D6673EEA8A__
--- a/Source/Mappings/PitchBend/TouchkeyPitchBendMappingShortEditor.cpp Mon Apr 13 19:30:27 2015 -0700 +++ b/Source/Mappings/PitchBend/TouchkeyPitchBendMappingShortEditor.cpp Mon Apr 13 20:51:17 2015 -0700 @@ -18,6 +18,7 @@ */ //[Headers] You can add your own extra header files here... +#ifndef TOUCHKEYS_NO_GUI //[/Headers] #include "TouchkeyPitchBendMappingShortEditor.h" @@ -263,4 +264,5 @@ //[EndFile] You can add extra defines here... +#endif // TOUCHKEYS_NO_GUI //[/EndFile]
--- a/Source/Mappings/PitchBend/TouchkeyPitchBendMappingShortEditor.h Mon Apr 13 19:30:27 2015 -0700 +++ b/Source/Mappings/PitchBend/TouchkeyPitchBendMappingShortEditor.h Mon Apr 13 20:51:17 2015 -0700 @@ -21,6 +21,8 @@ #define __JUCE_HEADER_FBFB213EC27EA3A0__ //[Headers] -- You can add your own extra header files here -- +#ifndef TOUCHKEYS_NO_GUI + #include "JuceHeader.h" #include "TouchkeyPitchBendMappingFactory.h" //[/Headers] @@ -80,6 +82,7 @@ }; //[EndFile] You can add extra defines here... +#endif // TOUCHKEYS_NO_GUI //[/EndFile] #endif // __JUCE_HEADER_FBFB213EC27EA3A0__
--- a/Source/Mappings/ReleaseAngle/TouchkeyReleaseAngleMappingExtendedEditor.cpp Mon Apr 13 19:30:27 2015 -0700 +++ b/Source/Mappings/ReleaseAngle/TouchkeyReleaseAngleMappingExtendedEditor.cpp Mon Apr 13 20:51:17 2015 -0700 @@ -18,6 +18,7 @@ */ //[Headers] You can add your own extra header files here... +#ifndef TOUCHKEYS_NO_GUI //[/Headers] #include "TouchkeyReleaseAngleMappingExtendedEditor.h" @@ -782,4 +783,5 @@ //[EndFile] You can add extra defines here... +#endif // TOUCHKEYS_NO_GUI //[/EndFile]
--- a/Source/Mappings/ReleaseAngle/TouchkeyReleaseAngleMappingExtendedEditor.h Mon Apr 13 19:30:27 2015 -0700 +++ b/Source/Mappings/ReleaseAngle/TouchkeyReleaseAngleMappingExtendedEditor.h Mon Apr 13 20:51:17 2015 -0700 @@ -21,6 +21,8 @@ #define __JUCE_HEADER_24D73157539FBFD0__ //[Headers] -- You can add your own extra header files here -- +#ifndef TOUCHKEYS_NO_GUI + #include "JuceHeader.h" #include "TouchkeyReleaseAngleMappingFactory.h" //[/Headers] @@ -110,6 +112,7 @@ }; //[EndFile] You can add extra defines here... +#endif // TOUCHKEYS_NO_GUI //[/EndFile] #endif // __JUCE_HEADER_24D73157539FBFD0__
--- a/Source/Mappings/Vibrato/TouchkeyVibratoMappingShortEditor.cpp Mon Apr 13 19:30:27 2015 -0700 +++ b/Source/Mappings/Vibrato/TouchkeyVibratoMappingShortEditor.cpp Mon Apr 13 20:51:17 2015 -0700 @@ -18,6 +18,7 @@ */ //[Headers] You can add your own extra header files here... +#ifndef TOUCHKEYS_NO_GUI //[/Headers] #include "TouchkeyVibratoMappingShortEditor.h" @@ -263,4 +264,5 @@ //[EndFile] You can add extra defines here... +#endif // TOUCHKEYS_NO_GUI //[/EndFile]
--- a/Source/Mappings/Vibrato/TouchkeyVibratoMappingShortEditor.h Mon Apr 13 19:30:27 2015 -0700 +++ b/Source/Mappings/Vibrato/TouchkeyVibratoMappingShortEditor.h Mon Apr 13 20:51:17 2015 -0700 @@ -21,6 +21,8 @@ #define __JUCE_HEADER_15DE9AB413FD564C__ //[Headers] -- You can add your own extra header files here -- +#ifndef TOUCHKEYS_NO_GUI + #include "JuceHeader.h" #include "TouchkeyVibratoMappingFactory.h" //[/Headers] @@ -80,6 +82,7 @@ }; //[EndFile] You can add extra defines here... +#endif // TOUCHKEYS_NO_GUI //[/EndFile] #endif // __JUCE_HEADER_15DE9AB413FD564C__