From f0a637fe7fce13ffe63b96bdfaf675636f71c3da Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sat, 28 Apr 2012 22:21:17 +0200 Subject: robust MIDI setup, configurable LFO oscillator waveform, multiple LFO shred support --- jack_patch.xml | 7 +++++++ lfo.ck | 54 ++++++++++++++++++++++++++++++++++++++++------------- lib/Oscope.ck | 13 ++++++------- settings.nktrl_set | Bin 1184 -> 1184 bytes 4 files changed, 54 insertions(+), 20 deletions(-) diff --git a/jack_patch.xml b/jack_patch.xml index 6497036..3d36072 100644 --- a/jack_patch.xml +++ b/jack_patch.xml @@ -21,6 +21,9 @@ capture_1 + + nanoKONTROL MIDI 1 + @@ -43,6 +46,9 @@ inport 2 + + Midi Through Port-0 + @@ -51,6 +57,7 @@ + diff --git a/lfo.ck b/lfo.ck index c784f48..7cb4821 100644 --- a/lfo.ck +++ b/lfo.ck @@ -7,22 +7,32 @@ new PulseOsc @=> lfo[1]; new SampOsc @=> lfo[2]; 10 => lfo[2].gain; /* preamp, to get value range 0 to 1000 */ +//lfo[2] => Bus.oscope[0]; +//0.1 => Bus.oscope[0].gain; + Step lfo_freq; for (0 => int i; i < 2 /*lfo.cap()*/; i++) lfo_freq => lfo[i]; 0 => int cur_lfo; +UGen @osc[2]; +new SawOsc @=> osc[0]; +new PulseOsc @=> osc[1]; + +0 => int cur_osc; + /* s.freq = lfo.freq*lfo.gain + base.value */ -lfo[cur_lfo] => Gain lfo_gain => SawOsc s => JCRev rev => Bus.out_left; +lfo[cur_lfo] => Gain lfo_gain => Gain lfo_dummy => osc[cur_osc] => Echo rev => Bus.out_left; rev => Bus.out_right; -Step base => s; +Step base => lfo_dummy; //50::ms => echo.delay; //.3 => echo.mix; -0.1 => rev.mix; -0.2 => rev.gain; +1::second => rev.max; +500::ms => rev.delay; +0.5 => rev.mix; 10 => lfo_freq.next; 400 => base.next; @@ -46,20 +56,31 @@ change_lfo(int new_lfo) } } +fun void +change_osc(int new_osc) +{ + lfo_dummy =< osc[cur_osc] =< rev; + lfo_dummy => osc[new_osc => cur_osc] => rev; +} + /* - * LFO configuration via MIDI (Channel/Scene 0) + * LFO configuration via MIDI */ /* FIXME: custom nanoKONTROL events */ if (me.args() > 1) me.exit(); -1 => int device; -if (me.args() == 1) - me.arg(0) => Std.atoi => device; +/* first param: scene number */ +0 => int on_channel; +if (me.args() > 0) + (me.arg(0) => Std.atoi)-1 => on_channel; +if (on_channel < 0 || on_channel > 3) + me.exit(); MidiIn min; -if (!min.open(device)) +/* always open MIDI Through port, actual connection is done by Jack */ +if (!min.open(0)) me.exit(); <<< "MIDI device:", min.num(), " -> ", min.name() >>>; @@ -69,7 +90,7 @@ while (min => now) { msg.data1 & 0xF0 => int cmd; (msg.data3 $ float)/127 => float value; - if (channel == 0 && cmd == 0xB0) { + if (channel == on_channel && cmd == 0xB0) { <<< "Channel:", channel, "Command:", cmd, "Controller:", msg.data2, "Value:", value >>>; if (msg.data2 == 22) { @@ -84,11 +105,18 @@ while (min => now) { /* setting lfo_freq does not influence SampOsc! */ value*20 => lfo_freq.next => (lfo[2] $ SampOsc).freq; } else if (msg.data2 == 31) { - change_lfo(0); + 0 => change_lfo; } else if (msg.data2 == 41) { - change_lfo(1); + 1 => change_lfo; } else if (msg.data2 == 30) { - change_lfo(2); + 2 => change_lfo; + } else if (msg.data2 == 40) { + if (value $ int) + 1 => change_osc; + else + 0 => change_osc; + } else if (msg.data2 == 9) { + value*second => rev.delay; } /*else if (msg.data2 == 9) value $ int => lfo.harmonics;*/ diff --git a/lib/Oscope.ck b/lib/Oscope.ck index 5849b3f..b18a0b2 100644 --- a/lib/Oscope.ck +++ b/lib/Oscope.ck @@ -78,26 +78,25 @@ for (0 => int i; i < Bus.oscope.cap(); i++) * jack.scope configuration via MIDI (Channel/Scene 1) */ /* FIXME: custom nanoKONTROL events */ -if (me.args() > 1) +if (me.args() > 0) me.exit(); -1 => int device; -if (me.args() == 1) - me.arg(0) => Std.atoi => device; - MidiIn min; -if (!min.open(device)) +/* always open MIDI Through port, actual connection is done by Jack */ +if (!min.open(0)) me.exit(); <<< "MIDI device:", min.num(), " -> ", min.name() >>>; +3 => int on_channel; /* scene 4 */ + while (min => now) { while (MidiMsg msg => min.recv) { msg.data1 & 0x0F => int channel; msg.data1 & 0xF0 => int cmd; (msg.data3 $ float)/127 => float value; - if (channel == 1 && cmd == 0xB0) { + if (channel == on_channel && cmd == 0xB0) { <<< "Channel:", channel, "Command:", cmd, "Controller:", msg.data2, "Value:", value >>>; if (msg.data2 == 67) { diff --git a/settings.nktrl_set b/settings.nktrl_set index 14d7c64..5682f73 100644 Binary files a/settings.nktrl_set and b/settings.nktrl_set differ -- cgit v1.2.3