{
   "labels" : [
      "pattern",
      "midi",
      "nrpn",
      "external synth"
   ],
   "code" : "MIDIClient.init;\r\n\r\n~ob6 = MIDIOut.newByName(\"OB-6\", \"OB-6\");\r\n// ~ob6.latency = Server.default.latency;\r\n\r\n(\r\np = Pbind(\r\n\t\\type, \\midi,\r\n\t\\midicmd, \\noteOn,\r\n\t\\midiout, ~ob6,\r\n\t\\chan, 0,\r\n\t\\degree, Pwhite(-7, 12, inf),\r\n\t\\dur, Pwrand([0.25, Pn(0.125, 2)], #[0.8, 0.2], inf),\r\n\t\\legato, sin(Ptime(inf) * 0.5).linexp(-1, 1, 1/10, 1),\r\n\t\\amp, Pexprand(0.5, 1.0, inf)\r\n).play(quant: 1);\r\n)\r\n\r\n~ob6.allNotesOff(0);\r\n\r\n(\r\nEvent.addEventType(\\OB6_NRPN, {\r\n\tvar midiout = ~midiout.value;\r\n\tvar chan = ~chan.value;\r\n\tvar nrpnNum = ~nrpnNum.value;\r\n\tvar nrpnValue = ~nrpnValue.value;\r\n\r\n\tif (nrpnValue.class == String) {\r\n\t\tif (nrpnValue.beginsWith(\"c\")) {\r\n\t\t\tnrpnValue = Bus.new('control', nrpnValue[1..].asInteger, 1, s).getSynchronous();\r\n\t\t};\r\n\t};\r\n\r\n\tnrpnValue = nrpnValue.asInteger;\r\n\r\n\tmidiout.control(chan, 0x63, nrpnNum >> 7);\r\n\tmidiout.control(chan, 0x62, nrpnNum & 0x7F);\r\n\tmidiout.control(chan, 0x06, nrpnValue >> 7);\r\n\tmidiout.control(chan, 0x26, nrpnValue & 0x7F);\r\n});\r\n)\r\n\r\n// randomize filter cutoff\r\n\r\n(\r\np = Pbind(\r\n\t\\type, \\OB6_NRPN,\r\n\t\\midiout, ~ob6,\r\n\t\\chan, 0,\r\n\t\\nrpnNum, 45,\r\n\t\\nrpnValue, Pwhite(0, 164),\r\n\t\\dur, 1\r\n).play(quant: 1);\r\n)\r\n\r\n// randomize filter cutoff with a LFO from a Node bus\r\n\r\n(\r\np = Pbind(\r\n\t\\type, \\OB6_NRPN,\r\n\t\\midiout, ~ob6,\r\n\t\\chan, 0,\r\n\t\\nrpnNum, 45,\r\n\t\\nrpnValue, Ndef(\\bla, { SinOsc.kr(1/10).range(0,164) }).asMap,\r\n\t\\dur, 0.1\r\n).play(quant: 1);\r\n)\r\n\r\n// do crazy stuff\r\n\r\n(\r\np = Pbind(\r\n\t\\type, \\OB6_NRPN,\r\n\t\\midiout, ~ob6,\r\n\t\\chan, 0,\r\n\t\\nrpnNum, Pwhite(0, 150),\r\n\t\\nrpnValue, Pwhite(0,255),\r\n\t\\dur, 1\r\n).play(quant: 1);\r\n)",
   "id" : "1-5ea",
   "is_private" : null,
   "name" : "Controlling an external synth parameters with NRPN / adding LFOs",
   "author" : "g_montel",
   "ancestor_list" : [],
   "description" : "I bought a Sequential OB-6 recently and you can control all the parameters with NRPN messages.\r\nI wanted to control these NRPN parameters with patterns, adding LFOs for instance."
}
