Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #93411

Re: "normalizing" a value

Path csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!bcyclone05.am1.xlned.com!bcyclone05.am1.xlned.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.039
X-Spam-Evidence '*H*': 0.92; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.05; 'works.': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'wrote:': 0.16; 'library,': 0.18; 'language': 0.19; '(or': 0.21; 'lawrence': 0.22; 'tried': 0.24; 'header:In-Reply-To:1': 0.24; '(this': 0.24; 'written': 0.24; 'wondering': 0.25; 'header:User-Agent:1': 0.26; 'header:X -Complaints-To:1': 0.26; 'this.': 0.28; "i'm": 0.29; 'convert': 0.29; 'values': 0.30; 'you?': 0.32; 'language.': 0.32; 'to:addr :python-list': 0.35; 'there': 0.36; '(and': 0.36; 'subject:" ': 0.36; 'received:org': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'sure': 0.40; 'where': 0.40; 'mark': 0.40; 'called': 0.40; 'further': 0.60; 'even': 0.61; 'places': 0.64; 'our': 0.64; 'charset:windows-1252': 0.65; 'music': 0.78; '12:': 0.84; 'pythonistas,': 0.84; 'do:': 0.91; 'ranging': 0.91; 'subject:value': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: "normalizing" a value
Date Thu, 02 Jul 2015 05:41:31 +0100
References <fd370a7b-ea6a-48e5-90f4-9d86b89a745e@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host host-78-147-21-40.as13285.net
User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0
In-Reply-To <fd370a7b-ea6a-48e5-90f4-9d86b89a745e@googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.234.1435812108.3674.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1435812108 news.xs4all.nl 2850 [2001:888:2000:d::a6]:42171
X-Complaints-To abuse@xs4all.nl
X-Received-Bytes 3477
X-Received-Body-CRC 1348636553
Xref csiph.com comp.lang.python:93411

Show key headers only | View raw


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 
for you?

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

"normalizing" a value bvdp <bob@mellowood.ca> - 2015-07-01 17:12 -0700
  Re: "normalizing" a value MRAB <python@mrabarnett.plus.com> - 2015-07-02 01:30 +0100
  Re: "normalizing" a value Paul Rubin <no.email@nospam.invalid> - 2015-07-01 17:36 -0700
  Re: "normalizing" a value Denis McMahon <denismfmcmahon@gmail.com> - 2015-07-02 01:06 +0000
  Re: "normalizing" a value random832@fastmail.us - 2015-07-01 21:27 -0400
    Re: "normalizing" a value bvdp <bob@mellowood.ca> - 2015-07-01 18:49 -0700
      Re: "normalizing" a value random832@fastmail.us - 2015-07-01 22:23 -0400
        Re: "normalizing" a value bvdp <bob@mellowood.ca> - 2015-07-01 19:41 -0700
      Re: "normalizing" a value Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-07-01 23:36 -0400
        Re: "normalizing" a value bvdp <bob@mellowood.ca> - 2015-07-02 10:03 -0700
  Re: "normalizing" a value Steven D'Aprano <steve@pearwood.info> - 2015-07-02 12:15 +1000
    Re: "normalizing" a value bvdp <bob@mellowood.ca> - 2015-07-01 19:42 -0700
  Re: "normalizing" a value Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-07-02 05:41 +0100
  Re: "normalizing" a value Skip Montanaro <skip.montanaro@gmail.com> - 2015-07-02 10:05 -0500

csiph-web