"normalizing" a value
breamoreboy at yahoo.co.uk
Thu Jul 2 06:41:31 CEST 2015
On 02/07/2015 01:12, bvdp wrote:
> Not sure what this is called (and I'm sure it's not normalize). Perhaps "scaling"?
> Anyway, I need to convert various values ranging from around -50 to 50 to an 0 to 12 range (this is part of a MIDI music program). I have a number of places where I do:
> while x < 0: x += 12
> while x >= 12: x -= 12
> Okay, that works. Just wondering if there is an easier (or faster) way to accomplish this.
Further to other answers have you tried looking for a library, or even
just a recipe, that has already been written and tested that does this
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
More information about the Python-list