5

I was hoping some super electronics expert dude could give me some advice. How do I get this http://www.amazon.co.uk/Cherub-WTB-004-Keyboard-Sustain-Pedal/dp/B000UDVV6E to work with my computer? I basically want to use it to replace/emulate a keystroke or something in my games. Anyone with some experience with something like this got any advice? I'm willing to try simple software related hacks... or more advanced software stuff if there are resources online for it.

Edit:

Pedal Waveform

I tried plugging it into my microphone jack and lo and behold, whenever I activate (step on) the pedal, I get a signal - this is the recording (on audacity).

The first "thick" one is from holding down on the pedal, the rest were just taps.

5
  • I don't think this exists, as the pedal talks in the language MIDI. You'd need a device that translates this into MIDI signals and maybe then you can somehow do something with this. This, to my knowledge, does not exist.
    – LPChip
    Apr 7, 2015 at 14:04
  • 1
    @LPChip The pedal does not talk MIDI. It only has an analog jack connector.
    – slhck
    Apr 7, 2015 at 14:43
  • @slhck: the pedal is a midi trigger ( midi trigger interface )
    – Yorik
    Apr 7, 2015 at 15:35
  • So there's no way to process this without additional hardware?
    – Dois
    Apr 7, 2015 at 17:08
  • Technically you could process it w/o additional hardware, but unless someone wrote software to do this, you'd have to write your own code to translate the microphone input into a usable keystroke. Apr 7, 2015 at 18:35

4 Answers 4

3

Why go through all the trouble, when you can just buy exactly what you are looking for? A USB Foot Pedal made for PCs, like this:

enter image description here

They are cheap and does exactly what you are looking to do.

5
  • 2
    This isn't really an answer, since the OP already owns the device and wants to know how to make use of it as-is. I agree that this is easier, but he will still need suitable midi-aware software to make use of it (DAW, amp simulator, midi-pass-through etc all of which can be gotten as freeware)
    – Yorik
    Apr 7, 2015 at 15:49
  • 1
    @Yorik this is an answer, as it is an alternative that will work
    – Keltari
    Apr 7, 2015 at 16:27
  • He said "how to get this thing that I already own to work" You said "use something else." So in this sense, it isn't an answer. I think you know that.
    – Yorik
    Apr 7, 2015 at 16:30
  • I want to go through the trouble because I think it'll be fun trying to repurpose this thing... and also like the people above have said, I don't wanna buy something else.
    – Dois
    Apr 7, 2015 at 16:48
  • you will spend more on parts to make it work than the $13 it would take to make it. However, I will provide an answer on how to do it, as well.
    – Keltari
    Apr 7, 2015 at 17:40
2

Well it's been 7 months or so and I totally forgot about this... came back and tried it again today and I managed to get it working.

Here's a simple Java program that works for my pedal. It converts the presses into keyboard "V"s (it's for me to activate +voice_record in cS GO)

    package pedal2keyboard;
    
    import java.io.ByteArrayOutputStream;
    import java.nio.ByteBuffer;
    import java.nio.ByteOrder;
    
    import javax.sound.sampled.*;
    
    import java.awt.AWTException;
    import java.awt.Robot;
    import java.awt.event.KeyEvent;
    
    /***
     * Author: Dois Koh
     * Date: 27th October 2015
     * 
     * Gets your microphone signal and you can go do whatever you want with it.
     * Right now, it takes signals from my Cherub WTB-004 Keyboard Sustain Pedal, plugged into
     * my microphone jack, and converts it into key presses (holds down V when depressed,
     * releases V when released)
     */
    public class PedalToKeyboard {
    
        // Robot for performing keyboard actions (pressing V)
        public static Robot robot = null;
        
        // Currently 8KHz, 16 bit signal (2 bytes), single channel, signed (+ and -) and BIG ENDIAN format
        public static AudioFormat format = new AudioFormat(8000.0f, 16, 1, true, true);
        
        public static TargetDataLine microphone = null;
        public static boolean pedalPressed = false;
    
        public static void main(String[] args) {
            
            try {
                // Initialize robot for later use
                robot = new Robot();
                
                // Retrieve the line to from which to read in the audio signal
                microphone = AudioSystem.getTargetDataLine(format);
                
                // Open the line in the specified format -
                // Currently 8KHz, 16 bit signal (2 bytes), single channel, signed (+ and -) and BIG ENDIAN format      
                microphone.open(new AudioFormat(8000.0f, 16, 1, true, true));
    
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                byte[] data = new byte[microphone.getBufferSize()/8];
                
                // Begin audio capture.
                microphone.start();
    
                int numBytesRead = 0;
                short previousShort = 0;
                
                // Continue until program is manually terminated
                while (true) {
                    
                    // Read the next chunk of data from the TargetDataLine.
                    numBytesRead = microphone.read(data, 0, data.length);
                    
                    // Reset the buffer (get rid of previous data)
                    out.reset();
                    
                    // Save this chunk of data.
                    out.write(data, 0, numBytesRead);
                    
                    byte[] bytes = out.toByteArray();
                    short[] shorts = new short[bytes.length/2];
                    
                    // to turn bytes to shorts as either big endian or little endian. 
                    ByteBuffer.wrap(bytes).order(ByteOrder.BIG_ENDIAN).asShortBuffer().get(shorts);
                    
                    // Iterate through retrieved 16 bit data (shorts)
                    for (short s : shorts) {
                        
                        // Check if descending or ascending (pedal press is descending, release is ascending)
                        if (s < 0) { // descending                  
                            // make sure drop is large instantaneous drop
                            if (Math.abs(previousShort - s) > 200 && s < -32700) {
                                if (!pedalPressed) {
                                    PedalPressedAction();
                                    previousShort = s;
                                    break;
                                }
                            }
                        } else if (s > 0) { // ascending
                            // make sure increase is large instantaneous increase
                            if (Math.abs(previousShort - s) > 200 && s > 32700) {
                                if (pedalPressed) {
                                    PedalReleasedAction();
                                    previousShort = s;
                                    break;
                                }
                            }
                        }
                        
                        previousShort = s;
                    }
                }    
                
            } catch (LineUnavailableException | AWTException e) {
                e.printStackTrace();
            } finally {
                if (microphone != null)
                    microphone.close();
            }
        }
        
        /***
         * The action to perform when the pedal is depressed
         */
        public static void PedalPressedAction() {
            pedalPressed = true;
            robot.keyPress(KeyEvent.VK_V);
        }
        
        /***
         * The action to perform when the pedal is released
         */
        public static void PedalReleasedAction(){
            pedalPressed = false;
            robot.keyRelease(KeyEvent.VK_V);        
        }
    }
1
  • I just wanted to say that this is extremely cool. Thanks a lot for sharing!
    – megamer
    Sep 22, 2021 at 14:43
1

To actually do this. All you really need is keyboard. Something small like this. Gut the pedal and the keyboard. You might even be able to fit the keyboard inside the pedal with the USB cable to replace the audio wire. The pedal probably has 3 leads, + & - and the resistor lead. Just find the + and - leads through trial and error (only 6 possible choices). Wire one of the keys to the leads in the pedal. When you press the pedal and close the circuit... keypress!

-2

As you discovered, this pedal is just a momentary switch.

You need a midi "head" device to read the switch state and convert to midi; a way to plug that head unit into your computer; and then software to make use of the midi input.

Alternatively, you can look into devices which convert to joystick inputs. People who make cockpit simulators use real switches to interface with their sim software. If you go this route, you would use a simple joystick-to-midi driver and then again, software suitable for use with the inputs.

Note that you can get a 10$ gamepad and hack leads onto the circuit board and connect 1$ Radio Shack switches mounted on a board for a whole bank of foot pedals. You would use the joy-midi driver to route the signals to a DAW or Amp Simulator.

Usually, for music interface and recording integration, you want a DAW application (Digital Audio Workstation).

There are also wah-wah pedal style audio intrerfaces which have ports for expression pedals. These are usually for guitar, but there is no reason you can't use them as general audio interfaces, and the midi signals can be routed to ANY function, so the rocker pedal can be used for e.g. crossfade, volume, wah, toggle switch etc etc

Even with an appropriate device to get the button push to register on your PC, you cannot use Audacity for this. You can try the free "vsthost" and some VST effect proccessors (try "simuanalog" also free). The VSTHost is a host to load amp sims and can route midi and joystick input signals to any exposed function/button/dial on a VST application. It has a built-in recorder, and you can then edit the files with audacity.

Anything that generates voltage can be plugged into the microphone jack and generate a recordable signal so long as it doesn't set the computer on fire and even then...

So: to recap. You need to hack your two wires (1/4-1/8 inch cable stripped and soldered to a joypad) or otherwise get the signal onto the computer in joystick or midi form. Then you can translate that signal to anything that handles it. Joy2midi, Midi translator, midi2joy.

6
  • Sorry, what do you mean "generate voltage"? There's no battery on this thing and it's is pulling current from my PC so I don't get that part (just clarifying). Also, is there some other way to process the signal that I can get with just software? (I can try writing the software if you can point me in the right direction) I don't understand how the signal is generated or what format it's in but surely I can do something with this... Does it HAVE to be converted into "joystick or midi" form externally?
    – Dois
    Apr 7, 2015 at 17:04
  • It is probably moving a plunger with a coil and magnet, so it is "passive" like a guitar pickup or a diaphragm mic. You microphone jack has an amplifier connected to it, and most computers have a +10 gain option for the microphone. As far as software, there are all kinds of things you can do. If you google around for "simpit switch" you will find all sorts of information about cockpit flight simulators i.e. games)
    – Yorik
    Apr 7, 2015 at 17:59
  • where people take switches and convert the inputs. google "keyboard pedalboard" for info about using keybards as a base for footswitches. Hacking a joypad or keyboard is the most common and they are super low volatge/current so your risk of killing yourself or starting a fire are almost nil. Joystick buttons and keyboard keys are just switches that close a circuit by touching two wires together.
    – Yorik
    Apr 7, 2015 at 17:59
  • The software might be called "midi translator" for midi >joystick or midi>keyboard. There was something called Joy2Midi for converting joysticks to midi control signals. Joy2Key was a program that did joystick to keyboard. There are lots of options, but look for opensource and be careful that they don't have spamware coinstallers etc
    – Yorik
    Apr 7, 2015 at 18:03
  • FYI: moving a wire in a magnetic field induces voltage ( resources.schoolscience.co.uk/CDA/16plus/copelech4pg2.html ) it is a reversible process, so microphones and speakers are basically the same thing with tweaks for their specific function.
    – Yorik
    Apr 7, 2015 at 18:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .