Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding stomp keyboard and midi devices

  • Loading branch information...
commit 42ada7357399c53f614052109c3351971653291c 1 parent fde60c2
@heuermh authored
Showing with 250 additions and 0 deletions.
  1. +120 −0 StompKeyboard.ck
  2. +128 −0 StompMidi.ck
  3. +2 −0  import.ck
View
120 StompKeyboard.ck
@@ -0,0 +1,120 @@
+/*
+
+ LiCK Library for ChucK.
+ Copyright (c) 2007-2012 held jointly by the individual authors.
+
+ This file is part of LiCK.
+
+ LiCK is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ LiCK is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LiCK. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+public class StompKeyboard
+{
+ Hid hid;
+ HidMsg msg;
+
+ Procedure button0Up;
+ Procedure button0Down;
+ Procedure button1Up;
+ Procedure button1Down;
+ Procedure button2Up;
+ Procedure button2Down;
+ Procedure button3Up;
+ Procedure button3Down;
+ Procedure button4Up;
+ Procedure button4Down;
+ Procedure button5Up;
+ Procedure button5Down;
+
+ fun void open(int device)
+ {
+ hid.openKeyboard(device);
+
+ while (true)
+ {
+ hid => now;
+ while (hid.recv(msg))
+ {
+ if (msg.isButtonUp())
+ {
+ if (30 == msg.which)
+ {
+ spork ~ button0Up.run();
+ }
+ else if (31 == msg.which)
+ {
+ spork ~ button1Up.run();
+ }
+ else if (32 == msg.which)
+ {
+ spork ~ button2Up.run();
+ }
+ else if (33 == msg.which)
+ {
+ spork ~ button3Up.run();
+ }
+ else if (34 == msg.which)
+ {
+ spork ~ button4Up.run();
+ }
+ else if (35 == msg.which)
+ {
+ spork ~ button5Up.run();
+ }
+ }
+ if (msg.isButtonDown())
+ {
+ if (30 == msg.which)
+ {
+ spork ~ button0Down.run();
+ }
+ else if (31 == msg.which)
+ {
+ spork ~ button1Down.run();
+ }
+ else if (32 == msg.which)
+ {
+ spork ~ button2Down.run();
+ }
+ else if (33 == msg.which)
+ {
+ spork ~ button3Down.run();
+ }
+ else if (34 == msg.which)
+ {
+ spork ~ button4Down.run();
+ }
+ else if (35 == msg.which)
+ {
+ spork ~ button5Down.run();
+ }
+ }
+ }
+ }
+ }
+}
+
+/*
+
+ default stomp key mapping
+
+ button0 "0" 30
+ button1 "1" 31
+ button2 "2" 32
+ button3 "3" 33
+ button4 "4" 34
+ button5 "5" 35
+
+*/
View
128 StompMidi.ck
@@ -0,0 +1,128 @@
+/*
+
+ LiCK Library for ChucK.
+ Copyright (c) 2007-2012 held jointly by the individual authors.
+
+ This file is part of LiCK.
+
+ LiCK is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ LiCK is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LiCK. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+public class StompMidi
+{
+ MidiIn min;
+ MidiMsg msg;
+
+ Procedure button0Up;
+ Procedure button0Down;
+ Procedure button1Up;
+ Procedure button1Down;
+ Procedure button2Up;
+ Procedure button2Down;
+ Procedure button3Up;
+ Procedure button3Down;
+ Procedure button4Up;
+ Procedure button4Down;
+ Procedure button5Up;
+ Procedure button5Down;
+
+ fun int open(int device)
+ {
+ min.open(device);
+
+ while (true)
+ {
+ min => now;
+ while (min.recv(msg))
+ {
+ msg.data1 => int control;
+ msg.data2 => int controlChange;
+ msg.data3 => int value;
+
+ // see notes below
+ if (control == 176)
+ {
+ if (value == 0)
+ {
+ if (controlChange == 1)
+ {
+ spork ~ button0Up.run();
+ }
+ else if (controlChange == 2)
+ {
+ spork ~ button1Up.run();
+ }
+ else if (controlChange == 3)
+ {
+ spork ~ button2Up.run();
+ }
+ else if (controlChange == 4)
+ {
+ spork ~ button3Up.run();
+ }
+ else if (controlChange == 5)
+ {
+ spork ~ button4Up.run();
+ }
+ else if (controlChange == 6)
+ {
+ spork ~ button5Up.run();
+ }
+ }
+ else
+ {
+ if (controlChange == 1)
+ {
+ spork ~ button0Down.run();
+ }
+ else if (controlChange == 2)
+ {
+ spork ~ button1Down.run();
+ }
+ else if (controlChange == 3)
+ {
+ spork ~ button2Down.run();
+ }
+ else if (controlChange == 4)
+ {
+ spork ~ button3Down.run();
+ }
+ else if (controlChange == 5)
+ {
+ spork ~ button4Down.run();
+ }
+ else if (controlChange == 6)
+ {
+ spork ~ button5Down.run();
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+/*
+
+ default stomp midi mapping
+
+ button0 cc1 176, 1, 65 for on, 0 for off
+ button1 cc2 176, 2, 65 for on, 0 for off
+ button2 cc3 176, 3, 65 for on, 0 for off
+ button3 cc4 176, 4, 65 for on, 0 for off
+ button4 cc5 176, 5, 65 for on, 0 for off
+ button5 cc6 176, 6, 65 for on, 0 for off
+
+*/
View
2  import.ck
@@ -220,6 +220,8 @@ Machine.add("Monome.ck");
Machine.add("Mouse.ck");
Machine.add("NanoPad.ck");
Machine.add("Ozone.ck");
+Machine.add("StompKeyboard.ck");
+Machine.add("StompMidi.ck");
// osc, package osc
Machine.add("ControlOscServer.ck");
Please sign in to comment.
Something went wrong with that request. Please try again.