pitch logic of sound.play_effect
Can anyone tell me how this parameter works? I've experimented a bit but my ear isn't accurate enough to recognise exactly what is a one-octave shift etc. My plan is to import some bass samples and use play_effect to play some tunes.
´pitch´ seems to be a factor that is applied to the frequencies of the ´note´ parameter. E.g. factor 2.0 moves the tone one octave up, or 2.0**(1.0/12.0) moves it a tempered halftone up. See the following example.
Duration of tones in the example must be limited, since there is only 30 fold polyphony and the duration of every tone would be 1.3 seconds.
notePitch_C3 = ('C3', 1.0) # use C3 as base, since it is lowest available C
notePitch_C0 = ('C3', notePitch_C3/(2**3)) # pitch factor = 1/8
htf = 2.0**(1.0/12.0) # half tone frequency step, tempered
store pairs of note and pitch. note is always 'C3':
notesPitch = [notePitch_C0] # start with C0, 3 octaves below C3
for i in xrange(72):
notesPitch.append((notePitch_C0, notesPitch[-1]*htf)) # next halftone
reverse = notesPitch[:]
play upstairs and downstairs
for note, pitch in notesPitch + reverse: # note is always C3
id = sound.play_effect('Piano_' + note, 1, pitch)