/*RUN*/

s.boot;

//"/home/rob/algomom/sc/motherPatterns.scd".load;

MIDIClient.init;
MIDIClient.list;
MIDIClient.destinations;

// connect for korg in
MIDIIn.connectAll;

n = NetAddr("192.168.178.166", 47120);
//n = NetAddr("localhost", 47120);

~m32_1 = MIDIOut.newByName("MidiSport 4x4", "MidiSport 4x4 MIDI 1").latency_(Server.default.latency);
~m32_2 = MIDIOut.newByName("MidiSport 4x4", "MidiSport 4x4 MIDI 2").latency_(Server.default.latency);

~hydro_0 = MIDIOut.newByName("Hydrogen", "Hydrogen Midi-In").latency_(Server.default.latency);

// ~m32_1 = MIDIOut.newByName("SuperCollider", "in0").latency_(Server.default.latency);
// ~m32_2 = MIDIOut.newByName("SuperCollider", "in1").latency_(Server.default.latency);


// //////////////////////////////////////////////////////////////////
//
// //  setup of mother 32 noteon events
//
// Pdef(\m_1,  Pbind( \type, \midi, \midicmd, \noteOn, \midiout, ~m32_1)).play(quant: 4);
//
// Pdef(\m_2,  Pbind( \type, \midi, \midicmd, \noteOn, \midiout, ~m32_2)).play(quant: 4);
//
//
// // CC Control Message 1 --->  TOP Mother32 ASSIGN OUT
//
// ( Pdef(\m_1_CC,  Pbind( \type, \midi, \midicmd, \control, \midiout, ~m32_1, \ctlNum, 1, \control, Pexprand(72,127, inf), \dur, ~r1)).play(quant:4));
//
// // CC Control Message 1 --->  BOTTOM Mother32 ASSIGN OUT
//
// Pdef(\m_2_CC,  Pbind( \type, \midi, \midicmd, \control, \midiout, ~m32_2, \ctlNum, 1, \control, Pexprand(77,127, inf), \dur, 1/8 )).play(quant:4);



// MIDIFunc.trace;
/*//MIDIIn.connectAll;

~nK2srcID = MIDIIn.findPort("nanoKONTROL2", "nanoKONTROL2 nanoKONTROL2 _ CTR","nanoKONTROL2", "nanoKONTROL2 nanoKONTROL2 _ CTR").uid;
~nK2MIDIOut = MIDIOut.newByName("nanoKONTROL2", "nanoKONTROL2 nanoKONTROL2 _ CTR","nanoKONTROL2", "nanoKONTROL2 nanoKONTROL2 _ CTR");
~nk2OutPort = 0;*/

//MIDIOut.connect(~nk2OutPort,~nK2MIDIOut.port);

//~nk = NanoKONTROL2(s, srcID: ~nK2scrID, outport: ~nk2OutPort);

//postln(~nk.knobs[2][2].kr);

//~nk.knobs[2][2].kr

//{ SinOsc.ar(~nk.knobs[2][2].kr, 0, 0.5) }.play;

// n = NetAddr("127.0.0.1", 47120);