[Tutor] (No Subject)

kevin parks cpsoct@lycos.com
Wed, 27 Dec 2000 19:35:51 +0900

```What i am trying to do is perhaps easy for seasoned pythonites, but confronted with a new langauge and a wonderful new array of data types i am a bit baffled as to how to best approach it. I suppose that what i need is a some kind of dictionary and tuple to function as a classic table look up type structure. It is very hard to decribe the problem abstractly so i will just deal with exactly what it is i am trying to do and hope that someone here can get their head around the problem.

I have a set of sound samples that are set at discreet values. However i want to use them any tuning scheme. So what i have is an algorhythm that figures out the frequency that i want based on some tuning mombo-jumbo that i wrote.

What i need now is to use that frequency (the desired frequency) as a key or index and to do the following:

1. find the frequnce in the list below that is closest.
2. return that frequency and the name of the associated sample.
e.g.: if i arrive at a frequency of  31.001 Hz, the code should look up and see that 32.703 is my closest available sample base frequency. It should return that number along with the name of the sample 'sh.forte C_1' so that i now have the desired frequency (31.001), the base frequency (32.703) and the sample name ('sh.forte C_1') which i can then use to calulate a transposition factor (31.001/32.703).

What is the best way to do this? In my old language i would use a look-up table to choose the base freq. and then a table with a step function to choose the sample. so that all frequncies from 0-27.500 chose sample1, all frequncies from 27.500 to 32.703 choose sample2, etc. (we want the samples to be responsible for the frequncies, up to and including it as we usually want to transpose down to get our note, as up sounds "micky mouse").

{ 'sh.forte A_0' : 27.500  , 'sh.forte C_1' : 32.703 , 'sh.forte D#1' : 38.891 , 'sh.forte F#1' : 46.249 , 'sh.forte A_1' : 55.000 , 'sh.forte C_2' : 65.406 , 'sh.forte D#2' : 77.782 , 'sh.forte F#2' : 92.499 , 'sh.forte A_2' : 110.000 , 'sh.forte C_3' : 130.813 , 'sh.forte D#3' : 155.563 , 'sh.forte F#3' : 184.997  , 'sh.forte A_3' : 220.000 , 'sh.forte C_4' : 261.626 , 'sh.forte D#4' : 311.127, 'sh.forte F#4' : 369.994 , 'sh.forte A_4' : 440.000 , 'sh.forte C_5' : 523.251 , 'sh.forte D#5' : 622.254 , 'sh.forte F#5' : 739.989 , 'sh.forte A_5' : 880.000 , 'sh.forte C_6' : 1046.502  , 'sh.forte D#6' : 1244.508 , 'sh.forte F#6' : 1479.978  , 'sh.forte A_6' : 1760.000 , 'sh.forte C_7' : 2093.005 , 'sh.forte D#7' : 2489.016 , 'sh.forte F#7' : 2959.955 , 'sh.forte A_7' : 3520.000 , 'sh.forte C_8' : 4186.009 }

Sorry this is so long winded, i tried to explain the problem as simply as i could. i am just certain this is easier to do with python's built in structures, but can't quite get my head around it just yet.

best,
kevin parks
seoul, korea

Get FREE Email/Voicemail with 15MB at Lycos Communications at http://comm.lycos.com

```