SRC: Music Synthesizer written in 100% Python
Tres Seaver
tseaver at starbase.neosoft.com
Thu Aug 31 01:03:54 EDT 2000
In article <8oe3i1$pom$1 at bob.news.rcn.net>,
Jeffrey P Shell <jeffrey at digicool.com> wrote:
>> > def pitchhz(note):
>> > if note=="A0":
>> > return 13.75
>> > if note=="A1":
>> > return 27.5
>> > if note=="A2":
>> > return 55.0
>> > if note=="A3":
>> > return 110.0
>>
>>
>> how about something more along the lines of:
>>
>> def pitchhz(note):
>> return {
>> "A0" : 13.75,
>> "A1" : 27.5,
>> "A2" : 55.0,
>> ...
>> }[note]
>
>Or even: (for the increasingly_brave):
>
>pitchhz = {
> "AO": 13.75,
> "A1": 27.5,
> "A2": 55.0
>}.get
>
>:)
>
>>>> pitchhz("A1")
>27.5
>>>>
>
>
>jeffr , http://euc.cx/
*Somebody* has been reading lots of Jim Fulton's code. :)
Tres.
--
===============================================================
Tres Seaver tseaver at digicool.com
Digital Creations "Zope Dealers" http://www.zope.org
More information about the Python-list
mailing list