USBMIDIIsm{ var 0, { postln("Resetting list of MIDI input devices."); devices.do({|device,i| if(device.inPortNum.notNil || device.outPortNum.notNil,{ // stateManager.store(device)? device.cleanup(); }); }); devices = Array(); }); postln("Restarting MIDIClient..."); MIDIClient.disposeClient; MIDIClient.init(verbose: verbose); }); postln("Scanning for MIDI devices..."); //TODO: find way to select in/out-only devices MIDIClient.sources.do({ |inEndPoint, inPortNum| if((inEndPoint.device.contains("SuperCollider") || inEndPoint.device.contains("Midi Through") || inEndPoint.device.contains("Timer") || inEndPoint.device.contains("Announce")).not, { // correlate with output devices MIDIClient.destinations.do({|outEndPoint, outPortNum| var device, state; if((inEndPoint.device == outEndPoint.device && inEndPoint.uid == outEndPoint.uid), { // available devices case {inEndPoint.device.contains("Platform M+")} { devices = devices.add( PlatformMPlus.new( name: inEndPoint.device, uid: inEndPoint.uid.asSymbol, inPort: inPortNum, outPort: outPortNum, verbose: verbose, states: stateManager.requestState( inEndPoint.device, inEndPoint.uid.asSymbol, inPortNum, outPortNum ); ) ); } {inEndPoint.device.contains("nanoKONTROL2")} { devices = devices.add( NanoKontrol2.new( inEndPoint.device, uid: inEndPoint.uid.asSymbol, inPort: inPortNum, outPort: outPortNum, verbose: verbose, states: stateManager.requestState( inEndPoint.device, inEndPoint.uid.asSymbol, inPortNum, outPortNum ); ) ); }; }); }); }); }); } listDevices{ devices.do({|device, i| postln(i.asString++": ["++device.name++", "++device.uid++", "++device.inPortNum++", "++device.outPortNum++"]"); }); } setStates{ arg device; } listen{ arg listen = true; if(listen, { MIDIdef.cc(\listen_cc, {arg ...args; ("control : "++args).postln}); MIDIdef.noteOn(\listen_noteOn, {arg ...args; ("noteOn : "++args).postln}); MIDIdef.noteOff(\listen_noteOff, {arg ...args; ("noteOff : "++args).postln}); MIDIdef.polytouch(\listen_polytouch, {arg ...args; ("polyTouch: "++args).postln}); MIDIdef.touch(\listen_touch, {arg ...args; ("touch: "++args).postln}); MIDIdef.bend(\listen_bend, {arg ...args; ("bend: "++args).postln}); MIDIdef.program(\listen_program, {arg ...args; ("program: "++args).postln}); // TODO: find something for sysex (too noisy) // MIDIdef.sysex(\listen_sysex, {arg ...args; ("sysex: "++args).postln}); MIDIdef.smpte(\listen_smpte, {arg ...args; ("smpte: "++args).postln}); MIDIdef.songPosition(\listen_songPosition, {arg ...args; ("songPosition: "++args).postln}); MIDIdef.songSelect(\listen_songSelect, {arg ...args; ("songSelect: "++args).postln}); MIDIdef.tuneRequest(\listen_tuneRequest, {arg ...args; ("tuneRequest: "++args).postln}); MIDIdef.midiClock(\listen_midiClock, {arg ...args; ("midiClock: "++args).postln}); MIDIdef.sysrt(\listen_sysrt, {arg ...args; ("sysrt: "++args).postln}); MIDIdef.tick(\listen_tick, {arg ...args; ("tick: "++args).postln}); MIDIdef.start(\listen_start, {arg ...args; ("start: "++args).postln}); MIDIdef.stop(\listen_stop, {arg ...args; ("stop: "++args).postln}); MIDIdef.continue(\listen_continue, {arg ...args; ("continue: "++args).postln}); MIDIdef.reset(\listen_reset, {arg ...args; ("reset: "++args).postln}); MIDIdef.activeSense(\listen_activeSense, {arg ...args; ("activeSense: "++args).postln}); }, { MIDIdef(\listen_cc).free; MIDIdef(\listen_noteOn).free; MIDIdef(\listen_noteOff).free; MIDIdef(\listen_polytouch).free; MIDIdef(\listen_touch).free; MIDIdef(\listen_bend).free; MIDIdef(\listen_program).free; // MIDIdef(\listen_sysex).free; MIDIdef(\listen_smpte).free; MIDIdef(\listen_songPosition).free; MIDIdef(\listen_songSelect).free; MIDIdef(\listen_tuneRequest).free; MIDIdef(\listen_midiClock).free; MIDIdef(\listen_sysrt).free; MIDIdef(\listen_tick).free; MIDIdef(\listen_start).free; MIDIdef(\listen_stop).free; MIDIdef(\listen_continue).free; MIDIdef(\listen_reset).free; MIDIdef(\listen_activeSense).free; }); } }