Show Posts
Pages: [1]
1  Using Arduino / Audio / Re: Controlling a Guitar Effect (DigiTech Whammy) with MIDI on: January 26, 2013, 12:06:39 pm

I have managed to get my circuit working. I found a different sketch to use as a starting point and also got some help from someone on IRC.

I have attached the sketch I am using, should anyone else ever want to do something similar. I'm sure someone will find a better way to write it but it does exactly what I want it to do. I also cleaned up the sketch and removed references to an LED, it was never my intention to add an LED as there are already LEDs on the guitar pedal itself which I can use to see which preset I am using.

When I press on the momentary switch the pedal advances to the next preset. If I press + hold the switch down, the pedal cycles continuously until I let go of the switch. This will be useful if I want to switch from preset 1 to preset 13 without having to press the switch 12 times.

Cyclegadget, thanks for your help. I tried your sketch, but it only switches from one preset to the other momentarily. I don't know if my explanation in previous posts was clear enough, hopefully this post has cleared that up.

Code:
   
    // DigiTech Whammy IV - MIDI Controller.
    // MichaelJGuitar 2013
    // Switch allows changing of Whammy preset.
    // Configured to cycle through all modes in active mode, an option for bypassing the effect is not required as there is already a switch on the unit for that.
   
    #include <MIDI.h>
     
    #define KEY 8 // The switch is connected to PIN 8.
     
    int keyispressed = 0; // Variable. Is the key currently pressed?
    int currentprogram = 0;

    void  setup()
    {
      pinMode(KEY, INPUT);
      MIDI.begin(); // Initialise midi library
      setProgram(currentprogram);
    }
    //---------------------------------------------
    void loop() //the main loop
    {
      keyispressed = digitalRead(KEY); // Read pin 8
     
      if (keyispressed == LOW){
        currentprogram++;
        delay (175); // When footswitch is pressed, the preset will change and then wait the amount specified before moving on to the next preset.
        if(currentprogram > 16) currentprogram = 0; // The Whammy has 16 presets, 0 - 16 are all active.
        setProgram(currentprogram);
      }
      else{
       
      }
    }
   
    void setProgram(uint8_t p) {
    Serial.write((uint8_t)0xC0);
    Serial.write((uint8_t)p);}
2  Using Arduino / Audio / Re: Controlling a Guitar Effect (DigiTech Whammy) with MIDI on: January 23, 2013, 04:50:48 pm
Can anyone help with where I am going wrong with this?

The guitar pedal's manual says the the presets (mode) can be selected using MIDI Program Change commands. The Program Changes recognised by the pedal are #1 -> #34. Although, I'm only interested in modes #1 -> #17 as 18# ->#34 are with the effect turned off.

How do I tell it to use the button to cycle through each mode one by one with each press?
3  Using Arduino / Audio / Controlling a Guitar Effect (DigiTech Whammy) with MIDI on: January 22, 2013, 07:18:40 pm

I am trying use my Arduino to control a guitar pedal, a DigiTech Whammy via MIDI, the pedal has a single MIDI In that can be used to control every funtion of the pedal. On the pedal there is a mode select dial, this sweeps through 17 different modes of pitch shift. So far I have found a sketch that has given me the ability to sweep through each mode continuously. Or I can create sequences for the mode change to follow.

Want I want, is a circuit and sketch that will allow me to choose when it advances to the next mode with a momentary footswitch. I have searched a lot to try and find a sketch that will allow me to use a single footswitch to control the Whammy in this way without success, I have attached a second code at the bottom which gave me A result, but not the correct result. Instead of advancing through each mode, it only jumps back and forth between two modes.

If anyone can help that would be amazing, I am still new to Arduino so I apologise if the problem is quite simple to fix.

Thanks!!

Here is the sketch that simply sweeps through each mode:

Code:
#define DLY 90
#define MIN 0
#define MAX 125
 
void setProgram(uint8_t p) {
 Serial.write((uint8_t)0xC0);
 Serial.write((uint8_t)p);
}
 
void setup() {
 Serial.begin(31250);
 
}
void loop() {
 setProgram(0);        //This loop simply sweeps through each mode that the pedal has.
 delay(DLY);
 setProgram(1);
 delay(DLY);
 setProgram(2);
 delay(DLY);
 setProgram(3);
 delay(DLY);
 setProgram(4);
 delay(DLY);
 setProgram(5);
 delay(DLY);
 setProgram(6);
 delay(DLY);
 setProgram(7);
 delay(DLY);
 setProgram(8);
 delay(DLY);
 setProgram(9);
 delay(DLY);
 setProgram(10);
 delay(DLY);
 setProgram(11);
 delay(DLY);
 setProgram(12);
 delay(DLY);
 setProgram(13);
 delay(DLY);
 setProgram(14);
 delay(DLY);
 setProgram(15);
 delay(DLY);
 setProgram(16);
 delay(DLY);
}

The code that gave almost the correct results, it switches between two modes, the switching is also quite flaky and if the button is held down it switches between the two modes erratically:

//Button 1
int ledPin = 12;                      //led output
int buttonPin = 10;                   //button input pin             
int buttonVal = 0;                    //variable for reading the button status
int buttonState = 0;                  //variable to hold the buttons current state
int bounceCheck = 0;                  //variable for debouncing




void setup() {
  pinMode(ledPin, OUTPUT);            //declare LED as output
  pinMode(buttonPin, INPUT);          //declare pushbutton as input
  Serial.begin(31250);                //MIDI communicates at 31250 baud
}

void loop()
{
  ////////////////////////////TOGGLE////////////////////////////////////
  buttonVal = digitalRead(buttonPin);     //read input value from button
  delay(5);                              //wait 10ms
  bounceCheck = digitalRead(buttonPin);   //check again
 
 
  if(buttonVal == bounceCheck){ //if val is the same then not a bounce
                                if (buttonVal == HIGH && buttonState == 1) {    //check if the input is HIGH
                                                                                digitalWrite(ledPin, HIGH);         //turn LED OFF
                                                                                midiOUT(0xC0, 0, 1);              //Note ON (CH 1), C1, velocity 127
                                                                                buttonState = 0;
                                                                            }
                                if(buttonVal == LOW && buttonState == 0){
                                                                              digitalWrite(ledPin, LOW);       //turn LED ON
                                                                              midiOUT(0xC0, 0, 0);           //Note ON (CH 1), middle C1, velocity 0
                                                                              buttonState = 1;
                                                                         }
                               }

   
 

}
void midiOUT(char command, char value1, char value2) {
  Serial.print(command);
  Serial.print(value1);
  Serial.print(value2);

}
4  Using Arduino / Audio / Re: MIDI Note Player Help Needed on: January 13, 2013, 07:45:40 pm
SOLVED! Well, sort of. I skipped ahead and tried to communicate with my Whammy pedal with another sketch I found online. Worked first time. I don't know why it won't work with my PC though, but I will be attempting that again. Thanks for the help anyway.
5  Using Arduino / Audio / Re: MIDI Note Player Help Needed on: January 13, 2013, 04:46:40 pm
I tried rebuilding the circuit from scratch, following the diagram available. I even tried a 220 ohm resistor between the tx1 pin on the arduino and the MIDI data wire although, the diagram does not mention this, I did see this mentioned in other posts.

Again, the Tx LED flashes as if data is being transmitted but nothing is received at the other end. At the other end is a Digidesign Digi001. I have used this Midi In socket with other hardware before without any issues so I'm really not sure why this isn't working. My guess is that I'm missing something, software/hardware, I'm not sure. IS the UNO the wrong board for this kind of project?

I'm hoping to build a controller that I can connect to my Digitech Whammy pedal, the plan would be to have a kit as a sort of break-out box with a footswitch that would enable me to switch modes on the Whammy, rather than having to bend over and adjust this manually on the pedal. There is also the possibility of controlling the treadle with pre-programmed sequences. But, if I can't get the arduino to communicate with my PC then I'm not really sure how I can progress further with this.

Any help is appreciated!
6  Using Arduino / Audio / Re: MIDI Note Player Help Needed on: January 13, 2013, 01:54:54 pm

I have tried a few different codes, but this is the code I am using right now and the wiring diagram that goes with it.

Code:
/*
 MIDI note player
 
 This sketch shows how to use the serial transmit pin (pin 1) to send MIDI note data.
 If this circuit is connected to a MIDI synth, it will play
 the notes F#-0 (0x1E) to F#-5 (0x5A) in sequence.

 
 The circuit:
 * digital in 1 connected to MIDI jack pin 5
 * MIDI jack pin 2 connected to ground
 * MIDI jack pin 4 connected to +5V through 220-ohm resistor
 Attach a MIDI cable to the jack, then to a MIDI synth, and play music.

 created 13 Jun 2006
 modified 13 Aug 2012
 by Tom Igoe

 This example code is in the public domain.
 
 http://www.arduino.cc/en/Tutorial/Midi
 
 */

void setup() {
  //  Set MIDI baud rate:
  Serial.begin(31250);
}

void loop() {
  // play notes from F#-0 (0x1E) to F#-5 (0x5A):
  for (int note = 0x1E; note < 0x5A; note ++) {
    //Note on channel 1 (0x90), some note value (note), middle velocity (0x45):
    noteOn(0x90, note, 0x45);
    delay(100);
    //Note on channel 1 (0x90), some note value (note), silent velocity (0x00):
    noteOn(0x90, note, 0x00);   
    delay(100);
  }
}

//  plays a MIDI note.  Doesn't check to see that
//  cmd is greater than 127, or that data values are  less than 127:
void noteOn(int cmd, int pitch, int velocity) {
  Serial.write(cmd);
  Serial.write(pitch);
  Serial.write(velocity);
}
7  Using Arduino / Audio / MIDI Note Player Help Needed on: January 13, 2013, 01:23:30 pm
Hi,

I am trying to set-up the MIDI Note Player example, but I don't seem to be receiving anything at the other end.

As far as I can tell I have connected everything as described in the diagram. When I upload the sketch to my board (Arduino UNO) I get a flashing Tx LED. An LED labelled L is also lit, as is the green on LED.

Can anyone help with any suggestions as to what I might be doing wrong?

What happens to the two unused wires from the MIDI cable? Do I just leave them unconnected?

Is there anything else I need to do to the Arduino before uploading the sketch?

Thanks!

(Previously posted in the Installation & Troubleshooting forum in error!)
Pages: [1]