A simple MIDI switch would solve all of this in an instant.
Maybe something like the Morningstar MC3?
A simple MIDI switch would solve all of this in an instant.
Maybe something like the Morningstar MC3?
yup - that was the direction of my recommendation as well:
Hadn’t come across the Morningstar box yet - interesting.
But TBH, when I need a simple USB to MIDI thingy, I usually just build something based on a Teensy…
Here is a side-by-side of the MIDI In/Out. This is with my reverse polarity adapted TRS and my foot constantly on the pedal. Only one state change has been fired in this sample. Not nearly as many MIDI events. It does not continually put out MIDI events as it had before. It has worked correctly through all the states of one song so that gives me hope that reversing the polarity is the final piece of the answer.
Ha, it looks like the polarity reverse has solved the issue with the narrow pedal range. In this case, you don’t need the Expression Stretch rack anymore; values look healthy!
Give it a try and connect the binding directly to the keyboard input instead of the rack output. Based on your screenshots, it should work now.
Cheers,
Torsten
I did some playing this evening and the jumping issue seems to be resolved. I made my own reverse polarity adapter from a piece of mic wire and the male / female 1/4" pieces. It works.
I tried disabling the inputs to the Expression Stretch rack but when I did the pedal stopped working. I also tried separately to disable the output in the Expression Stretch rack but the pedal did not work then either.
Whether I put the Roland pedal on Continuous or Switch now makes no difference to its function.
The only difference in the function at this point is that before I would step on the pedal and nothing would change until I lifted my foot off the pedal. That was convenient for starting songs because I could just stand on the pedal without changing states. Now the pedal changes states when it is depressed. That means that I have to either back up one state or just remember not to step on the pedal until I’m ready to change the first state.
Other than that I have just a question that I don’t understand about how the MIDI functions. We put a MIDI filter on the Input to the rack which suppresses everything except #11. We then reassigned everything from 71-102 to 0-127 in the Expression Stretch rack. Yet in the MIDI Out monitor I will still see some events pop up with numbers like 108, something in the 1-10 range or like in this snapshot. They are not causing problems but I just don’t quite understand how they are getting through the filters. Just curious.
Well, you’d also have to change your binding to use Main Keyboard as its source instead of the rack output.
That’s pretty simple: the mapping 71…102 to 0-127 is just a scaling of the range. So for all values between 71 and 102, Cantabile calculates:
out = (in - 71) * 127 / (102-71)
So an input value of 97 gets translated into 108, an input value of 73 to 10.
All input values below 71 get “clamped” to 71 (and then transformed to 0), all values above 102 are clamped to 102 and transformed to 127.
That’s where your values like 108 or 10 come from - source values of 97 or 73 translate to that.
The reason for that is that a Controller (Button) binding fires when the values pass from below 64 to above 64. This way, the binding fires whenever you step on your pedal. If you want your binding to fire on lifting your foot, try using the filter rack to reverse the values:
Since your pedal range seems to be behaving now, there’s no need for the 71…102 transformation anymore.
What still confuses the h*** out of me is that your MIDI monitor shows CC11 values from two different MIDI channels - with the Channel 2 values not being scaled, even though your filter is set to “omni”.
You’ll want to check why your keyboard is sending the same pedal values twice on two different channels - maybe you have set it up with keyboard zones and activated the pedal to send for both zones?
In any case, I’d suggest that to avoid craziness, you set the route from Main Keyboard to the Expression rack to only use channel 1 (MIDI Route Settings):
Cheers,
Torsten
This is now the input / output from one press and release of the pedal. It is working just fine now and changing states on the release of the pedal.
I did try using only the Main Keyboard input in my binding. It worked but it had the same action of either changing states when the pedal was depressed or changing states when the pedal was depressed or released (depending upon if I had it on Continuous or Switch). So I’m just keeping the Expression Stretch rack for now. It is working just fine. Thank you for all your help. I clearly have a lot to learn about how MIDI works. It is fascinating.
Related: I have run into a situation where a keyboard on location is older and has no footswitch other than the sustain pedal and no USB interface. So I’m considering a simple build to add a USB footswitch to my computer. It looks like Teensy may be the way to go. I figure what I’ll do is just use a 1/4" mono jack plug and plug in the existing foot pedal. Seems like it should work. I’ve seen a Teensy 2.0 for $17 on Amazon. Any reason that I can’t use it for this purpose? Or any recommendations? I’m trying not to spend much on this simple use. I’ve looked at this guy’s video. https://www.youtube.com/watch?v=H3WevrsmO9o
No reason why this shouldn’t work - I’ve used Teensy 2.0s for stuff like that.
These days, I prefer the Teensy LC - cheaper than the 2.0, and smaller as well. I usually just stick it inside some shrink tubing once I’ve connected the wires for switch and USB, so you could actually pack it inside the housing of a cheap foot pedal and just lead the USB cable outside, removing the original jack plug cable. But of course the alternative of simply putting it inside a small box with a jack socket on one end and the USB cable exiting on the other side is valid.
Both devices do the job easily - just need to make sure to configure them as MIDI devices in the Arduino IDE. Here is a code sketch that should do the job - knocked it together from some of my existing sketches, so not tested, but ought to work:
#include <Bounce2.h>
// defines
// constants
#define SWITCH1 0
#define MIDICC 64
#define CHANNEL 1
// 1-based!
Bounce2::Button myButton = Bounce2::Button();
void setup() {
// setup code here, to run once:
// !! uncomment this for debugging via Serial !!
// Serial.begin(9600);
myButton.attach(SWITCH1,INPUT_PULLUP);
myButton.interval(5);
myButton.setPressedState(LOW);
}
void loop() {
// main code here, runs repeatedly:
myButton.update();
if (myButton.pressed() ) {
// send MIDI CC
usbMIDI.sendControlChange(MIDICC, 127, CHANNEL);
} else if (myButton.released()){
usbMIDI.sendControlChange(MIDICC, 0, CHANNEL);
}
// MIDI Controllers should discard incoming MIDI messages.
while (usbMIDI.read()) {
// do nothing with data
}
} // MIDI read loop
}
Simply set the correct values for the initial constant defines for the switch pin, the MIDI CC and the MIDI channel, and push this to the Teensy. And be sure you set up the correct connection for the switch pedal: the pedal needs to close the connection between the switch pin and Ground - that’s the logic of the internal pullup on the Teensy.
Cheers,
Torsten
Thanks. the LCs are sold out everywhere so I had to get the 2.0 for $22. At least I will have something.
Regarding expression pedals and use with expression port, in particular Tiny 85, et. al. and probably Teensy as well, some pedals implement with a 100K potentiometer while others implement with a 10K pot. Tiny 85 and Arduino for sure expect to see 10K pot and 100K can trip them up, especially when using longer cord, as the signal to noise ratio goes berzerk and then the A/D can no longer determine the pot position due to the bad S/N.
MAudio’s pedal uses 10K and works fine with such devices. Numa Compact probably lists the ohms needed for the expression pedal in their documentation. Don’t ask me why I know all of this, it resurrects a brief period of great frustration… But let’s just say my midi output looked not so different than some of the stuff above until I swapped out the 100K pedal for a 10K.
edit: An example of a commercial item that won’t work with a 100K expression pedal is EH’s Pitch Fork. But it works great with a 10K pedal (and even says so right in the documentation)
Yup - expression pedals are typically built with10 K Ohm pots - except Yamaha with the FC7 and 50 K…
But as long as the measuring principle is a voltage divider, with the swiper dividing the overall resistance between VCC and GND, things are mostly fine. I’m not sure if S/N ratio is a key issue for your troubles - I suspect linear vs. logarithmic pots. 100 K sounds very much like a volume pedal converted to an expression pedal - volume pedals typically use logarithmic taper potentiometers, while expression pedals generally use linear pots.
But of course, there is also the A/D converter side on the Expression input to consider - not all ADCs are truly linear…
BUT: as I understand it, the OP really just wants to build a simple switch with the Teensy, so just a simple on-off pedal on a digital input port will be enough. Resistance is futile…
Cheers,
Torsten
Mine are all linear. It was definitely S/N problem with the 100K, as confirmed with oscilloscope at the A/D while pedal hooked up and basically random midi output skewed to one end. Believe it or not, there are a number of 100K expression pedals out there. Hopefully not the majority, but its easy enough to stumble upon one. All to say its worth verifying when buying or if having problems. Some of the cheaper ones with wired in cables have unshielded cable, compounding the problem. As for OP, if all he wants is a switch then you’re right it doesn’t much matter in his case.
I sure believe that - there’s a good overview of the market here: http://expressionpedals.com/list-of-expression-pedals. Tons of 10K pedals, but some more exotic values around…
Using the Teensy 2.0 has proven to be more difficult than I thought. I’ve tried your script here and I get this error when compiling.
Arduino: 1.8.19 (Windows 10), TD: 1.57, Board: “Teensy 2.0, MIDI, 16 MHz, US English”
Torsten:37: error: expected declaration before ‘}’ token
}
^
It doesn’t stop the compiling but I’m not sure if I should upload it or not.
The other script that I was trying to use for multiple switches called for “usb_names.h” in the names.c file but I can’t find any such library to install and it kills the compiling process. I have found names.h files on Github for Teensy 3 & 4 so I’m not even sure they would work with 2. That script was written for Teensy LC as well. You can find it here. I’m using the 1.8 Arudino per the video.
Oooops - sorry, sloppy work on my side. I currently don’t have the Arduino IDE installed, so I simply did a bit of copy/paste without testing
Try deleting line 35, that should at least get the code to compile (fingers crossed)…
Using the “names.c” is a way to create an individual USB device name for your project, so it doesn’t appear as “Teensy”. As long as you don’t have multiple Teensy devices connected to the same PC, you don’t really need to deal with this. See the Teensy USB MIDI page on this: Teensyduino: Using USB MIDI with Teensy on the Arduino IDE - there’s a section at the bottom on “Customizing the MIDI name”.
If the “usb_names.h” file isn’t found, there is probably an issue with your Teensyduino installation - not sure if you have installed both the Arduino IDE and the Teensyduino add-on. You definitely need both - see: Teensyduino: Download and Install Teensy support into the Arduino IDE
Cheers,
Torsten
Much thanks. I did install both the Arduino IDE and the Tensyduino. The good news is that I have been able to make your script compile and load successfully to the Teensy. The other good news is that I created the names.h file in a directory in the Arduino program, copied the code from Github and that solved my compiling errors. Both programs will now load to Teensy 2.0. I believe all of the information here is correct.
I have activated the Teensy MIDI port in Cantabile and both programs are properly recognized. Thank you very much!
Great you got it working - have fun with your new sustain switch!