oddson
Well-known member
Yeah I was a bit skeptical about ResonsiveAnalogRead() for MIDI projects but it really is pretty good and with Teensy you have so much horsepower to spare it doesn't really matter if it burns a few more cycles than if you'd written your own smoothing/hysteresis code. I still haven't looked under the hood for it's more advanced features but the basic functionality is pretty good for MIDI CC from a voltage divider source....Getting a bit of glitch on both the wheels but I'll try and add the responsive analog read library to the code and see if it helps.
Your code already is limited to a change in the result before sending MIDI updates but with CC even modest noise from the pot you can still end up toggling at a high rate between adjacent values because the voltage happened to land very near a rounding point in the MIDI mapping. With pitchbend you are bound to have the problem even if you are only updating when it changes mapping... because the mapping has more values than your signal.
I also have an issue when trying to assign something in ableton to the mod wheel where the pitchbend will always send a message after I move the mod wheel which makes ableton think I want to assign to the pitchbend wheel. I need to click the midi assign button off real quickly to get it to assign to mod wheel.
I think this issue is the same thing...
It's not just when you move the mod wheel but likely it's a steady stream from the pitchbend, whose voltage is much more likely to hover near boundaries of the MIDI mapping (especially in your case with the very limited voltage range).
So the pitchbend, without some algorithm to tame it, will pump out adjacent-or-nearly-so pitch messages at a very high rate (or would if you didn't have those delay commands in your code which were the only things giving you any chance of getting the software not to hear the errant message.
Delays prevent processing and are not the best way to stabilize MIDI output and if you need to use them for this it's best they are a brief as possible. I found delay(1) was enough to give an early weak-smoothing method stability.
Adding ResponsiveAnalogRead() should either cure or at least dramatically reduce the amount of garbage MIDI.
If any remains it's best to continue calculating the result on each pass but to only update and send after an elapsed period.
Use elapsedMillis() for this or at least you should be able to turn down the delay times.
But to know for sure what its sending you need a MIDI monitor application so you can see every message it's generating.
...and here too you can only know what your code is doing if you can see the messages that are received. (Although you can print them to the serial monitor instead but I like to know from the receiving side what's actually getting through and when.)The problems im having are getting the pitch bend to scale properly so it does +/- 2 semi tones. I now understand that altering pitch bend sensitivity is done on the receiving unit but at the moment i'm barely even getting a semi tone pb. I ran a serial monitor code on it and the pots travel is between 320 and 700 with 510 in the centre (same as the mod wheel) but I don't understand where to adjust my code to get this working.
It could be difficult to hear a micro-tonal wobble in your intonation because your controller is sending a stream of pitch messages all very near the neutral value. But you definitely need to stop it all the same.
Last edited: