09-partial-table.py - Store out-of-tune harmonics in a table

.

import random
from pyo import *

s = Server().boot()

harms = [(0.57, 0.67), (1.92, 1), (3.19, 2.67),
         (4.7, 1.67), (5, 1.46), (6.74, 1.33), (7, 1.33), (9.76, 1), (11.07, 1.33)]

t = PartialTable(list=harms, size=65536)
t.normalize()
t.view()

f = Fader(fadein=0.005, fadeout=10, dur=10.1)
f.setExp(6)

a = Osc(t, freq=[1, 1], mul=f*0.4)
b = ButLP(a, freq=0, mul=[1, 1]).out()

def play():
    freq = midiToHz(36) * random.uniform(0.99, 1.01)
    a.freq = freq / 100
    b.freq = f * freq * 8 + freq
    f.play()

pat = Pattern(function=play, time=1).play()

s.gui(locals())