Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
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.Cheers
<pre>
import sound
import timenotePitch_C3 = ('C3', 1.0) # use C3 as base, since it is lowest available C
notePitch_C0 = ('C3', notePitch_C3[1]/(2**3)) # pitch factor = 1/8htf = 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[0], notesPitch[-1][1]*htf)) # next halftonereverse = notesPitch[:]
reverse.reverse()play upstairs and downstairs
for note, pitch in notesPitch + reverse: # note is always C3
id = sound.play_effect('Piano_' + note, 1, pitch)
time.sleep(0.2)
sound.stop_effect(id)
</pre>