/*RUN*/

//////////////////////////////////////////////////////////////
// SYSTEM SETUP AND GLOBAL FUNCTIONS
//////////////////////////////////////////////////////////////

( s.boot;

MIDIClient.init; // INITIALISE MIDI DEVICES

/*MIDIClient.list; MIDIClient.destinations;*/

// connect for korg in

MIDIIn.connectAll;

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

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

// DECLARE MIDI DEVICES //////////////////////////

// MOTHER32 MIDI DEVICES

~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);

// HYDROGEN SOFTWARE DRUM MACHINE MIDI SETUP /////////////////
// KIT: HARD ELECTRO

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

);

// // 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);