Poor man's USB MIDI expression pedal (Guitar Rig Wahwah)

 
The end product: USB MIDI electronics integrated into an existing Wahwah

 Why do i need it?

As today the digital ampflifier simulations become better and better, you can do most of your guitar playing (at least for playing at home) with these programs. Just plug-in your guitar into an audio interface and you can play on a variety of simulated amplifiers with a variety of simulated effect pedals.
But what if you want to control one parameter while playing like for example the pedal value of a Wahwah? The commercial solutions (MIDI Expression Pedals etc.) seem to be pretty expensive, so i tried some DIY solution like these guys did [1].

Hardware

I use a Digispark here [2], which is essentially a Attiny85, with a PCB which can directly be plugged into the USB-Port of a PC. The advantage of this board in addition to it's price is it's ability to act like a USB device. So for example you could implement a simple keyboard, which prints something whenever you push a button. For the implementation of a simple expression pedal i just attached a potentiometer to GND, P2 and 5V Pins like this:
There are still some other Pins free on the Digispark for adding push-buttons etc.

Software

The Digispark is Arduino compatible in a reduced way (see more in Software part of this post). Getting it running with Arduino IDE is done as described in [3]. For it to behave like a MIDI device, you need the Arduino library DigisparkMIDI [4], which essentially does everything important for you. After installing these parts, the only thing left is combining all the parts in a simple Arduino sketch. See a very simple approach here:

#include <DigiMIDI.h>

/* SensorPin P2*/
int sensorPin = 1;   

#define THRESH_HIGH 995
/* Initially we are in high state */
bool stateOn = false;

DigiMIDIDevice midi;
#define MIDI_CHANNEL          1
#define COMMAND_EXPRESSION    0x07 /* See https://www.midi.org/specifications/item/table-3-control-change-messages-data-bytes-2. You can use other commands. */
#define MIDI_MIN_EXPRESSION   0
#define MIDI_MAX_EXPRESSION   127
#define COMMAND_ON_OFF        0x43 /* See https://www.midi.org/specifications/item/table-3-control-change-messages-data-bytes-2. You can use other commands. */
#define MIDI_OFF_VAL          0
#define MIDI_ON_VAL           127

void leaveStateOn(void) {
  midi.sendControlChange(COMMAND_ON_OFF, MIDI_OFF_VAL, MIDI_CHANNEL);
  stateOn = false;
}

void enterStateOn(void) {
  midi.sendControlChange(COMMAND_ON_OFF, MIDI_ON_VAL, MIDI_CHANNEL);
  stateOn = true;
}

void checkSensorValueBoundaries(int sensorValue) {
  if ( (sensorValue > THRESH_HIGH) && stateOn ) {
    leaveStateOn();
  }
  else if ( (sensorValue <= THRESH_HIGH) && !stateOn ) {
    enterStateOn();
  }
}

void processSensorValue(int sensorValue) {
  checkSensorValueBoundaries(sensorValue);
 
  if (stateOn) {
    static uint8_t oldExpVal = 255;
    uint8_t expVal = map(sensorValue, 0, THRESH_HIGH, MIDI_MIN_EXPRESSION, MIDI_MAX_EXPRESSION);

    /* Set expression value on change */
    if (oldExpVal != expVal) {   
      midi.sendControlChange(COMMAND_EXPRESSION, expVal, MIDI_CHANNEL);
      oldExpVal = expVal;
    }
  }
}

void setup() {
  leaveStateOn();
}

void loop() {
  processSensorValue(analogRead(sensorPin));
}


What this does is sending two kinds of MIDI commands dependent on the potentiometer position. If the potentiometer is turned all to one side, it deactivates the function "Soft Pedal" (which in this case is used for deactivating wah without having a push-button for it). When you turn the potentiometer outside this area, it activates the function "Soft Pedal" and sets the value of "Expression Controller" according to the potentiometer position continuously. This value can be assigned to the Wah pedal value in Guitar Rig as described below.
For a more sophisticated version of the code, which is extensible very easy, see the project in this git repo, which i am developing [5].

Usage in Guitar Rig 5

For using your new MIDI controller in Guitar Rig 5, plug it in and make sure it is recognized as MidiStomp as in this screenshot in the Windows device manager:

Afterwards you can go to the Options->Controller Page of Guitar Rig and let it detect your MIDI Commands. For this add a controller and click Learn for the first one and turn your potentiometer. You should see, "CC # 11" is detected.
Now move your potentiometer all to one side for it to deactivate "Soft Pedal". Then add another controller, click "Learn" and turn the potentiometer to activate "Soft Pedal". Guitar Rig should now have detected "CC # 67". The controller page should look something like this:


Now you can attach functions like "Wahwah"->"Pedal" and "Wahwah" -> "On/Off" to your controllers.
Finally have fun playing around with your new Guitar Rig controls.

Next steps

For the next steps i recommend putting your electronics into an existing pedal (maybe you find a broken Wahwah or some kind of footswitch) and adding some push-buttons for more control. 
Also the code from above is pretty simple and might need some tweaking. You could for example add a low pass filter for the analog input to smoothen it's value.


I integrated my electronics into an existing Dunlop CryBaby Wahwah pedal, which was pretty simple. The modified code (with utilitation of the integrated switch) can be found in this git repo [5]. The code in the repo is also much better in terms of extension for more potentiometers or buttons.

References

[1] https://www.codeproject.com/Articles/38203/Arduino-Based-MIDI-Expression-Pedal
[2] http://digistump.com/products/1
[3] https://digistump.com/wiki/digispark/tutorials/connecting
[4] https://github.com/heartscrytech/DigisparkMIDI
[5] https://github.com/RLars/UsbMidiWah 

Kommentare

Beliebte Posts