void AddSynthApp::initializePresets() { // mPresetHandler.print(); sequencer << synth.mPresetHandler; recorder << synth.mPresetHandler; // mKeyboardPresets.presets = &mPresetHandler; // MIDI Control of parameters int midiPort = 0; parameterMIDI.init(midiPort); parameterMIDI.connectControl(synth.mCumulativeDelay, 75, 1); parameterMIDI.connectControl(synth.mCumulativeDelayRandomness, 76, 1); parameterMIDI.connectControl(synth.mArcStart, 77, 1); parameterMIDI.connectControl(synth.mArcSpan, 78, 1); // MIDI control of presets // 74 71 91 93 73 72 5 84 7 // 75 76 77 78 74 71 24 102 presetMIDI.init(midiPort, synth.mPresetHandler); presetMIDI.setMorphControl(102, 1, 0.0, 8.0); // MIDI preset mapping // presetMIDI.connectNoteToPreset(1, 0, 36, 24, 59); // Print out names of available input ports for(unsigned i=0; i< midiIn.getPortCount(); ++i){ printf("Port %u: %s\n", i, midiIn.getPortName(i).c_str()); } try { // Open the port specified above midiIn.openPort(midiPort); } catch(MIDIError &error){ error.printMessage(); } midiIn.setCallback(AddSynthApp::midiCallback, this); }
int main(){ MIDIIn midiIn; // Check available ports vs. specified unsigned portToOpen = 0; unsigned numPorts = midiIn.getPortCount(); if(portToOpen >= numPorts){ printf("Invalid port specifier!\n"); } try { // Print out names of available input ports for(unsigned i=0; i<numPorts; ++i){ printf("Port %u: %s\n", i, midiIn.getPortName(i).c_str()); } // Open the port specified above midiIn.openPort(portToOpen); } catch(MIDIError &error){ error.printMessage(); return 1; } // Set our callback function. This should be done immediately after // opening the port to avoid having incoming messages written to the // queue instead of sent to the callback function. midiIn.setCallback(&midiCallback); // Don't ignore sysex, timing, or active sensing messages. midiIn.ignoreTypes(false, false, false); printf("\nReading MIDI input ... press <enter> to quit.\n"); getchar(); }