joshnishikawa / MIDIcontroller

A library for creating Teensy MIDI controllers with support for hold or latch buttons, potentiometers, encoders, capacitive sensors, Piezo transducers and other velocity sensitive inputs with aftertouch.
223 stars 19 forks source link

MIDI stops when/if the max value setting of the new inputRange is exceeded #11

Closed digitalelements closed 3 years ago

digitalelements commented 3 years ago

The new inputRange allows us to adjust the (min & max) of analog input to optimize the dynamic range. By lowering the Max input it is easier to reach the top dynamic and send MIDI values at or near 127. If the analog signal exceeds the max value. no MIDI gets sent or a note with (low) MIDI velocity of 1-5.

It would be ideal to have a Max velocity (127) sent if the analog signal exceeds the inputRange max value.

I've tested with a wide range of waitTime and Threshold settings. It appears these have no bearing on the issues and are not a secondary trigger event.

I'm Using Teensy 4 with the latest MIDIcontroller library and a variety of FSR sensors wired as suggested in the example sketches. I'm also playing with drumsticks and using an assortment of materials on top of the FSR for protection and playability.

I've added code to allow me to watch the Serial plotter as I'm playing for testing.

joshnishikawa commented 3 years ago

Thanks for pointing this out. I facepalmed pretty hard when I realized that the constrain() function that was supposed to be inline with the map() function was missing. Someone setting a threshold of say 20 and a maximum analog input of say 900 would assume that any analog input higher than 900 would be mapped to the maximum possible output (127). But without a constrain() function, the map() function was attempting to map an analog reading of say 915 to the input range that it was told would be 20~900. This obviously isn't going to work. This has been fixed as of version 2.4.0