summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2012-06-28 23:43:21 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2012-06-28 23:43:21 +0200
commit9cfd5aed215bbb5079571b464448c954152bbf51 (patch)
tree4762ae020d7b65469fa77a6f63145e5c3ac47bde
parent899033e19b308b7a76f8c694f178994c5918361d (diff)
downloaddigitale-debutanten-9cfd5aed215bbb5079571b464448c954152bbf51.tar.gz
additional live-sampler volume and pitch controls
* check for collisions when registering scenes/controls in NanoEvent * fixed null-string checks in NanoEvent.ck
-rw-r--r--lib/NanoEvent.ck19
-rw-r--r--live_sampler.ck41
2 files changed, 44 insertions, 16 deletions
diff --git a/lib/NanoEvent.ck b/lib/NanoEvent.ck
index f4637c8..aba3822 100644
--- a/lib/NanoEvent.ck
+++ b/lib/NanoEvent.ck
@@ -83,7 +83,7 @@ public class NanoEvent extends Event {
while (min => now) {
while (MidiMsg msg => min.recv) {
__channelToScene[msg.data1 & 0x0F].v @=> scene;
- if (scene == null) {
+ if (scene == "") {
<<< "Unknown channel", msg.data1 & 0x0F >>>;
msg.data1 & 0x0F => Std.itoa @=> scene;
}
@@ -92,14 +92,14 @@ public class NanoEvent extends Event {
msg.data2 => CCId;
__controlToName[scene].v[CCId].v @=> control;
- if (control == null) {
+ if (control == "") {
<<< "Unknown controller", CCId >>>;
CCId => Std.itoa @=> control;
}
(msg.data3 $ float)/127 => value;
- if (cmd == 0xB0 && (wantScene == null || scene == wantScene))
+ if (cmd == 0xB0 && (wantScene == "" || scene == wantScene))
broadcast();
}
}
@@ -120,6 +120,11 @@ public class NanoEvent extends Event {
fun static void
registerScene(int channel, string name)
{
+ if (__channelToScene[channel].v != "")
+ <<< "Warning: Already registered channel", channel >>>;
+ if (__controlToName[name] != null)
+ <<< "Warning: Already registered scene name", name >>>;
+
name @=> __channelToScene[channel].v;
new StringArray @=> __controlToName[name];
new String[0x100] @=> __controlToName[name].v;
@@ -128,6 +133,10 @@ public class NanoEvent extends Event {
fun static void
registerControl(string sceneName, int id, string controlName)
{
+ if (__controlToName[sceneName].v[id].v != "")
+ <<< "Warning: Already registered control", id,
+ "on scene", sceneName >>>;
+
controlName @=> __controlToName[sceneName].v[id].v;
}
}
@@ -149,7 +158,9 @@ NanoEvent.registerControl("primary", 03, "feedbackPregainSlider");
NanoEvent.registerControl("primary", 15, "feedbackGainKnob");
for (23 => int i; i <= 29; i++)
- NanoEvent.registerControl("primary", i, "chooseSampleButton#"+i);
+ NanoEvent.registerControl("primary", i, "samplerBankButton#"+i);
+NanoEvent.registerControl("primary", 19, "samplerVolumeKnob");
+NanoEvent.registerControl("primary", 08, "samplerPitchSlider");
fun void
registerLFO(string scene)
diff --git a/live_sampler.ck b/live_sampler.ck
index b75bfe7..5dae578 100644
--- a/live_sampler.ck
+++ b/live_sampler.ck
@@ -1,22 +1,26 @@
/*
- * Live (and stock) sampler based on LiSa
+ * Live (and stock) sampler based on LiSaX (LiSa)
+ * in-port: Bus.channels[0]
*/
+
LiSaX lisa[7];
+Gain amp => Bus.out_left;
+amp => Bus.out_right;
/* stock samples */
"samples/stier_loop.wav" => lisa[0].read;
for (0 => int i; i < lisa.cap(); i++) {
- if (lisa[i].duration() == 0::samp)
- 10::second => lisa[i].duration;
- lisa[i].duration() => lisa[i].loopEnd;
- lisa[i].duration() => lisa[i].loopEndRec;
+ if (lisa[i].duration() == 0::samp) {
+ 30::second => lisa[i].duration;
+ } else {
+ lisa[i].duration() => lisa[i].loopEnd;
+ lisa[i].duration() => lisa[i].loopEndRec;
+ }
0 => lisa[i].loop;
-}
-for (0 => int i; i < lisa.cap(); i++) {
- Bus.channels[0] => lisa[i] => Bus.out_left;
- lisa[i] => Bus.out_right;
+ /* patch */
+ Bus.channels[0] => lisa[i] => amp;
}
lisa[0] @=> LiSaX @currentSample;
@@ -29,14 +33,23 @@ lisa[0] @=> LiSaX @currentSample;
while (nanoev => now) {
if ("recordToggle" => nanoev.isControl) {
if (nanoev.getBool()) {
- currentSample.loop() => currentSample.loopRec;
- currentSample.loopEnd() => currentSample.loopEndRec;
+ if (!currentSample.loop() ||
+ currentSample.loopEndRec() == 0::samp) {
+ currentSample.duration() => currentSample.loopEndRec;
+ currentSample.clear();
+ } else {
+ currentSample.loopEnd() => currentSample.loopEndRec;
+ }
0::samp => currentSample.recPos;
} else if (!currentSample.loopRec() ||
currentSample.loopEnd() == 0::samp) {
currentSample.recPos() => currentSample.loopEnd;
}
- nanoev.getBool() => currentSample.record;
+
+ if (currentSample.loop()) {
+ nanoev.getBool() => currentSample.loopRec;
+ } else
+ nanoev.getBool() => currentSample.record;
} else if ("playButton" => nanoev.isControl) {
if (nanoev.getBool()) {
0::samp => currentSample.playPos;
@@ -47,6 +60,10 @@ while (nanoev => now) {
0 => currentSample.play;
} else if ("loopToggle" => nanoev.isControl) {
nanoev.getBool() => currentSample.loop;
+ } else if ("samplerVolumeKnob" => nanoev.isControl) {
+ nanoev.getFloat(10) => amp.gain;
+ } else if ("samplerPitchSlider" => nanoev.isControl) {
+ nanoev.getFloat(2) => currentSample.rate;
} else if (nanoev.CCId >= 23 && nanoev.CCId <= 29) {
/* chooseSampleButton#CCId pressed */
lisa[nanoev.CCId - 23] @=> currentSample;