zeffii / pyBLOK

small python scripting lib to generate BLOK patches. (unofficial)
GNU General Public License v3.0
0 stars 0 forks source link

demos #4

Open zeffii opened 8 years ago

zeffii commented 8 years ago

image

from blok_functions import pBlk, pCompile
from blok_utils import rate_from_herz

# http://computermusicresource.com/Simple.bell.tutorial.html
overtones = [0.56, .92, 1.19, 1.71, 2.0, 2.74, 3, 3.76, 4.07]

out = pBlk('MonoOut', (520, 110))
out.set_params(volume=0.3)

env1 = pBlk('EnvBasic', (20, 110))
env1.set_params(attack=0.11, decay=0.65, release=0.8)

noise = pBlk('NoiseOsc', (180, 110))
env1 > noise.index(0)

fundamental = 200
ypositions = [(120 + 80*i) for i, _ in enumerate(overtones)]

keytrk = pBlk('Keytrack', (20, 300))
rescale = pBlk('Rescale', (20, 500))
keytrk > rescale.index(0)
rescale.set_params(factor=0.75, offset=.63)

for freq, y in zip(overtones, ypositions):
    fz = rate_from_herz(fundamental*freq)
    _filter = pBlk('Filter', (380, y))
    _filter.set_params(cutoff=fz, resonance=0.98)
    noise > _filter.index(0)
    _filter > out.index(0)
    rescale > _filter.index(1)

pCompile(path=r'C:\Users\zeffi\Desktop\fluxo_bell.blkx', silent=0)
zeffii commented 8 years ago

image

now this works

from blok_functions import pBlk, pCompile

out = pBlk('MonoOut', (320, 110))

env1 = pBlk('EnvBasic', (30, 110))
env1.set_params(attack=0.085, decay=0.45, release=0.6)

for freq, y in zip([0, 0.5, 1], [120, 200, 280]):
    osc = pBlk('Osc', (170, y))
    osc.tuning(freq) 
    env1 > osc._amp
    osc > out._input

env1.attack(0.7)
env1.decay(0.22)

pCompile(path=r'C:\Users\zeffi\Desktop\demux1.blkx', silent=0)