Re: "normalizing" a value

2015-07-02 Thread bvdp
On Wednesday, July 1, 2015 at 8:37:18 PM UTC-7, Dennis Lee Bieber wrote: > On Wed, 1 Jul 2015 18:49:34 -0700 (PDT), bvdp declaimed > the following: > > > > >Thanks guys. Yes, that is exactly what I want. I have a number of places > >where a MIDI note value is being generated. MIDI should be 0..1

Re: "normalizing" a value

2015-07-02 Thread Skip Montanaro
This looks like a straightforward linear transformation issue to me (like Fahrenheit to Celsius). Add 50 to all input values, giving you values in the range 0 to 100. Then scale them into your 0 to 12 range by multiplying them by 12/100: >>> for n in range(-50, 50, 3): ... print n, n + 50, (n +

Re: "normalizing" a value

2015-07-01 Thread Mark Lawrence
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: whi

Re: "normalizing" a value

2015-07-01 Thread bvdp
On Wednesday, July 1, 2015 at 7:15:28 PM UTC-7, Steven D'Aprano wrote: > On Thu, 2 Jul 2015 10:12 am, bvdp wrote: > > > Not sure what this is called (and I'm sure it's not normalize). Perhaps > > "scaling"? > > > Could be normalising, could be scaling. > > > Anyway, I need to convert various v

Re: "normalizing" a value

2015-07-01 Thread bvdp
On Wednesday, July 1, 2015 at 7:23:19 PM UTC-7, rand...@fastmail.us wrote: > On Wed, Jul 1, 2015, at 21:49, bvdp wrote: > > Interesting that negative values translate properly. That's an > > non-intuitive result to me. Guess I should have studied that math stuff > > harder way back when! > > There

Re: "normalizing" a value

2015-07-01 Thread random832
On Wed, Jul 1, 2015, at 21:49, bvdp wrote: > Interesting that negative values translate properly. That's an > non-intuitive result to me. Guess I should have studied that math stuff > harder way back when! There are multiple interpretations of the operation, and not all languages behave the same w

Re: "normalizing" a value

2015-07-01 Thread Steven D'Aprano
On Thu, 2 Jul 2015 10:12 am, bvdp wrote: > Not sure what this is called (and I'm sure it's not normalize). Perhaps > "scaling"? Could be normalising, could be 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 p

Re: "normalizing" a value

2015-07-01 Thread bvdp
On Wednesday, July 1, 2015 at 6:27:57 PM UTC-7, rand...@fastmail.us wrote: > On Wed, Jul 1, 2015, at 20: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 > > a

Re: "normalizing" a value

2015-07-01 Thread random832
On Wed, Jul 1, 2015, at 20: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 whe

Re: "normalizing" a value

2015-07-01 Thread Denis McMahon
On Wed, 01 Jul 2015 17:12:36 -0700, 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 plac

Re: "normalizing" a value

2015-07-01 Thread Paul Rubin
bvdp writes: >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. x = x % 12 should be the same as the above. But are you sure that's really what you want? -- https://mail.python.org/mailman/listinf

Re: "normalizing" a value

2015-07-01 Thread MRAB
On 2015-07-02 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: whi

"normalizing" a value

2015-07-01 Thread bvdp
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: