Transpose number in one range into another range


#1

hey folks

is there any class in Juce (or STL etc) for dealing with converting a number in one range to a number in another?

For example, maybe I have an incoming MIDI value which is between 0 - 127 and I want to transpose that value into another range (say 0 - 22,000).

I knocked together a simple function that does this, but now I need something more flexible (not linear), and figured I would ask before trying to reinvent the wheel :)

nick


#2

There's NormalisableRange, and also the jmap function?


#3

ah yes thanks! thought I'd seen something like that but couldn't find it ... probably because i was typing "normaliZe" into the search box :D