Data Mapping

One math thing that I’m finding I’m doing a lot of with the theramin is mapping positional data to a set range of integers. The midi library uses a range from 0 to 127 for pitch. So I need to map the distance value between the controller and the pitch rod to that number.

One technique is to convert the value of range 1 into a percent and then multiplying the maximum of range 2 by that percent to get your new value (and then rounding to an integer). Because I already know that its only going to work inside the trigger box, I compare the current distance from the rod with the maximum distance to get a percentage.

But if one range uses negative numbers and the other uses positive numbers then that becomes a bit harder to do. So another technique you can use is a mapping algorithm.

I found a pretty great forum thread where people are sharing different algorithms they use for remapping:

Leave a Reply

Your email address will not be published. Required fields are marked *