diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-06-25 17:06:46 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-06-25 17:06:46 +0200 |
commit | d18ff8ed2bb1def654e04b5826ed3d7b3f67c734 (patch) | |
tree | 565945886c4e36a344b0539e2b76926560983c95 | |
parent | a8c27f74d03e2992d504450158ef091b4ee263c3 (diff) | |
download | digitale-debutanten-d18ff8ed2bb1def654e04b5826ed3d7b3f67c734.tar.gz |
several fixes
* fixed (pseudo) constructor name ("new" not allowed, use "init" instead)
* fixed NanoEvent's channel and CC Id mappings (due to several ChucK bugs, we have to use wrapper classes for strings and arrays)
* store CC Id in NanoEvent object (for non-symbolic access to values)
-rw-r--r-- | contact_mic.ck | 3 | ||||
-rw-r--r-- | lib/NanoEvent.ck | 57 | ||||
-rw-r--r-- | lib/Oscope.ck | 2 | ||||
-rw-r--r-- | midi_recorder.ck | 2 | ||||
-rw-r--r-- | settings.nktrl_set | bin | 1184 -> 1184 bytes |
5 files changed, 45 insertions, 19 deletions
diff --git a/contact_mic.ck b/contact_mic.ck index 667a89f..32eb869 100644 --- a/contact_mic.ck +++ b/contact_mic.ck @@ -4,6 +4,7 @@ */ Clipper clipper; adc.chan(0) => Gain pregain => Echo echo => Gain amp => clipper.input; +clipper.output => Bus.channels[0]; clipper.output => Bus.out_left; clipper.output => Bus.out_right; clipper.output => Delay del => amp; @@ -35,7 +36,7 @@ adc.chan(1) => Bus.out_right; * Mic/effect configuration via MIDI */ -"primary" => NanoEvent.new @=> NanoEvent @nanoev; +"primary" => NanoEvent.init @=> NanoEvent @nanoev; while (nanoev => now) { if ("feedbackDistKnob" => nanoev.isControl) { diff --git a/lib/NanoEvent.ck b/lib/NanoEvent.ck index fac8580..f4637c8 100644 --- a/lib/NanoEvent.ck +++ b/lib/NanoEvent.ck @@ -1,16 +1,29 @@ /* + * ChucK is so buggy, it hurts... + * You just cannot declare plain static string arrays, so + * we must wrap them in "real" objects + */ +class String { + string v; +} +class StringArray { + String @v[]; +} + +/* * nanoKONTROL event class */ public class NanoEvent extends Event { /* map channel (0-15) to scene name */ - static string @channelToScene[]; + static String @__channelToScene[]; /* pseudo-private */ /* map scene name and control id (0-255) to control name */ - static string @controlToName[][]; + static StringArray @__controlToName[]; /* pseudo-private */ string wantScene; string scene; string control; + int CCId; float value; fun int @@ -69,18 +82,19 @@ public class NanoEvent extends Event { while (min => now) { while (MidiMsg msg => min.recv) { - channelToScene[msg.data1 & 0x0F] @=> scene; + __channelToScene[msg.data1 & 0x0F].v @=> scene; if (scene == null) { - <<< "Unknown channel", msg.data & 0x0F >>>; + <<< "Unknown channel", msg.data1 & 0x0F >>>; msg.data1 & 0x0F => Std.itoa @=> scene; } msg.data1 & 0xF0 => int cmd; + msg.data2 => CCId; - controlToName[scene][msg.data2] @=> control; + __controlToName[scene].v[CCId].v @=> control; if (control == null) { - <<< "Unknown controller", msg.data2 >>>; - msg.data2 => Std.itoa @=> control; + <<< "Unknown controller", CCId >>>; + CCId => Std.itoa @=> control; } (msg.data3 $ float)/127 => value; @@ -94,7 +108,7 @@ public class NanoEvent extends Event { spork ~ __midi_loop(0); fun static NanoEvent @ - new(string scene) + init(string scene) /* pseudo-constructor */ { NanoEvent obj; @@ -106,18 +120,20 @@ public class NanoEvent extends Event { fun static void registerScene(int channel, string name) { - name @=> channelToScene[channel]; + name @=> __channelToScene[channel].v; + new StringArray @=> __controlToName[name]; + new String[0x100] @=> __controlToName[name].v; } fun static void registerControl(string sceneName, int id, string controlName) { - controlName @=> controlToName[sceneName][id]; + controlName @=> __controlToName[sceneName].v[id].v; } } /* static initialization */ -new string[0x0F] @=> NanoEvent.channelToScene; -new string[0][0xFF] @=> NanoEvent.controlToName; +new String[0x10] @=> NanoEvent.__channelToScene; +new StringArray[0] @=> NanoEvent.__controlToName; /* * global mappings @@ -132,6 +148,9 @@ NanoEvent.registerControl("primary", 02, "feedbackPitchSlider"); NanoEvent.registerControl("primary", 03, "feedbackPregainSlider"); NanoEvent.registerControl("primary", 15, "feedbackGainKnob"); +for (23 => int i; i <= 29; i++) + NanoEvent.registerControl("primary", i, "chooseSampleButton#"+i); + fun void registerLFO(string scene) { @@ -148,10 +167,16 @@ registerLFO(string scene) "primary" => registerLFO; "secondary" => registerLFO; -NanoEvent.registerControl("secondary", 44, "recordToggle"); -NanoEvent.registerControl("secondary", 45, "playButton"); -NanoEvent.registerControl("secondary", 46, "stopButton"); -NanoEvent.registerControl("secondary", 49, "loopToggle"); +fun void +registerTransport(string scene) +{ + NanoEvent.registerControl(scene, 44, "recordToggle"); + NanoEvent.registerControl(scene, 45, "playButton"); + NanoEvent.registerControl(scene, 46, "stopButton"); + NanoEvent.registerControl(scene, 49, "loopToggle"); +} +"primary" => registerTransport; +"secondary" => registerTransport; NanoEvent.registerControl("oscope", 67, "modeToggle"); NanoEvent.registerControl("oscope", 76, "fillToggle"); diff --git a/lib/Oscope.ck b/lib/Oscope.ck index 8ecec70..e206b7a 100644 --- a/lib/Oscope.ck +++ b/lib/Oscope.ck @@ -77,7 +77,7 @@ for (0 => int i; i < Bus.oscope.cap(); i++) /* * jack.scope configuration */ -"oscope" => NanoEvent.new @=> NanoEvent @nanoev; +"oscope" => NanoEvent.init @=> NanoEvent @nanoev; while (nanoev => now) { if ("modeToggle" => nanoev.isControl) { diff --git a/midi_recorder.ck b/midi_recorder.ck index 7b4482b..7cba165 100644 --- a/midi_recorder.ck +++ b/midi_recorder.ck @@ -75,7 +75,7 @@ Shred @playback_shred; /* * Recorder configuration via MIDI */ -"secondary" => NanoEvent.new @=> NanoEvent @nanoev; +"secondary" => NanoEvent.init @=> NanoEvent @nanoev; while (nanoev => now) { if ("recordToggle" => nanoev.isControl) { diff --git a/settings.nktrl_set b/settings.nktrl_set Binary files differindex d8dc839..d9d3cf5 100644 --- a/settings.nktrl_set +++ b/settings.nktrl_set |