Zum Inhalt springen
Startseite » MIDI Controller für Arme – Nachtrag

MIDI Controller für Arme – Nachtrag

Union Jack Go to english version

Irgendwie ließ mir das ja keine Ruhe, daß der Controller nicht so funktionierte wie das Gigboard und man immer erst einen Fußtaster drücken musste um die „zweite Ebene“ zu erreichen. Also machte ich mich an die Verbesserung des Midi Controllers, um die gleiche Funktionalität wie auf dem Gigboard zu erreichen.

Wer suchet, der findet

Ich forschte mal ein wenig zu langen Tastendrücken mit dem Arduino und wurde auch fündig. Die von mir verwendete Bibliothek, um die Tastendrücke zu Entprellen, machte nicht nur das, sie enthielt auch noch diverse andere Funktionen, u.a. longPress. Das war doch genau das, was ich gesucht hatte.

Eigentlich ganz einfach

Nach ein bißchen rumprobieren fand ich heraus, daß die Funktionen singleClick und longPress mir ermöglichten, das zu erreichen was ich wollte. Ich ergänzte die entsprechenden Stellen in meinem Sketch und es funktionierte. :-)

Das fünfte Rad am Wagen

Aber da war ja noch der 5. Fußtaster. Was sollte ich denn mit dem jetzt anfangen? Die Lösung war schnell gefunden nachdem ich einen Blick in die MIDI Tabelle des Gigboards geworfen hatte. Dort gab es nämlich auch einen Controlwert für „Tap Tempo“, Bingo! Das kann man immer gebrauchen und fehlte mir schonmal auf dem Gigboard. Also baute ich auch das schnell ein und das funktionierte ebenfalls bestens. Nun ist der Midi Controller auch gigtauglich.:)

Der Sketch

Und nun der geänderte Sketch

/*
   Simple program to send program changes over the MIDI protokol, if a switch is pushed.
   For every switch there is a LED to present, that this switch is pressed.
   
   Adapted by grossmaggul to work with Headrush Gigboard v0.3

*/
#include "midi.h"
#include <avdweb_Switch.h>


const byte SWITCH_1 = 2;
const byte LED_1 = 3;
const byte SWITCH_2 = 4;
const byte LED_2 = 5;
const byte SWITCH_3 = 6;
const byte LED_3 = 7;
const byte SWITCH_4 = 8;
const byte LED_4 = 9;
const byte SWITCH_5 = 10;
const byte LED_5 = 11;

bool longpress = false;


Midi midi;
Switch switch_1 = Switch(SWITCH_1);
Switch switch_2 = Switch(SWITCH_2);
Switch switch_3 = Switch(SWITCH_3);
Switch switch_4 = Switch(SWITCH_4);
Switch switch_5 = Switch(SWITCH_5);

void setup() {
  initLEDs();
  midi.initMidi();
  led_run();
}


void loop() {
  pollSwitches();
  // sub switches(cc,led,longpress)
  
  // FS 1/VIEW
  if (switch_1.singleClick()) {  
      switches(50,LED_1,false);
  }
  if (switch_1.longPress()) {
      switches(50,LED_1,true);
  }

  // FS 2/HANDSFREE  
  if (switch_2.singleClick()) {
    switches(51,LED_2,false);
  }
  if (switch_2.longPress()) {
      switches(51,LED_2,true);
  }

  //FS 3/Looper  
  if (switch_3.singleClick()) {
    switches(52,LED_3,false);
  }
  if (switch_3.longPress()) {
      switches(52,LED_3,true);
  }

  //FS 4/TUNER
  if (switch_4.singleClick()) {
    switches(53,LED_4,false);
  }
  if (switch_4.longPress()) {
      switches(53,LED_4,true);
  }

  // Tap Tempo
  if (switch_5.pushed()) {
      switches(64,LED_5,false);
  }
}

void switches(int cc, int sw_led, bool longpress) { 
   if (!longpress)
    {
      midi.changeController(1,cc,64);
      delay(50);
      midi.changeController(1,cc,0);
    }
    else if (longpress)
    {
     midi.changeController(1,cc,127);
     longpress = false;
    }
    setLEDs(sw_led);
}


void led_run() {
  int x = 2;
  for (int i = 1; i > -1; i = i + x) {
    setLEDs(i);
    if (i == 11) {
      x = -2;  // switch direction at peak
    }
    delay(10);
  }
}

void initLEDs() {
  pinMode(LED_1, OUTPUT);
  pinMode(LED_2, OUTPUT);
  pinMode(LED_3, OUTPUT);
  pinMode(LED_4, OUTPUT);
  pinMode(LED_5, OUTPUT);  
  allLEDsOff();
}

void pollSwitches() {
  switch_1.poll();
  switch_2.poll();
  switch_3.poll();
  switch_4.poll();
  switch_5.poll();
}

void setLEDs(byte led) {
  allLEDsOff();
  digitalWrite(led, HIGH);
  delay(100);
  digitalWrite(led,LOW);
}

void allLEDsOff() {
  digitalWrite(LED_1, LOW);
  digitalWrite(LED_2, LOW);
  digitalWrite(LED_3, LOW);
  digitalWrite(LED_4, LOW);
  digitalWrite(LED_5, LOW);
}


MIDI Controller for poor – Addendum

Somehow that didn’t let me rest, that the controller did not work like the Gigboard and you had to press a footswitch to get to the „second level“

He who seeks finds

So I made some searchings on the web that dealed with long switch presses on the Arduino and found it too. The lib I used for reducing the key bouncing, did not only do this, it had some more functions, like longPress. That was that what I had searched for.

Actually quite simple

After fiddling around a little bit, I found out, that the functions singleClick and longPress made it possible to get there where I wanted to get. I added the new found functions und it works.

The fifth wheel on the wagon

But there was the fifth footswitch, that now had no function anymore, what should I do with it? The solution was found quite fast, after I had a look into the MIDI table of the Gigboard. There was a controller value for the „tap tempo“, bingo! One can always need that and I had missed it sometimes on my Gigboard. So I did put in the sketch and it worked flawlessly. Now the MIDI controller is also useable on live gigs.

The modified Sketch

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert