File: 02_scale_snap.py

package info (click to toggle)
python-pyo 1.0.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 52,332 kB
  • sloc: python: 135,133; ansic: 127,822; javascript: 16,116; sh: 395; makefile: 388; cpp: 242
file content (43 lines) | stat: -rw-r--r-- 994 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""
Algorithmic melody patterns snapped on a specific scale...

"""

from pyo import *

s = Server(duplex=0).boot()

scls = [
    [0, 4, 7, 11, 13, 17, 21, 25, 29, 33],
    [0, 7, 12, 14, 17, 21, 24, 29, 31, 34],
    [0, 7, 10, 12, 15, 19, 20],
]

env = CosTable([(0, 0), (50, 1), (500, 0.25), (8191, 0)])
wav = SquareTable(5)

met = Metro(time=0.125, poly=8).play()
note = TrigXnoiseMidi(met, dist="loopseg", x1=1, x2=0.2, mrange=(48, 97))
snp = Snap(note, choice=scls[0], scale=1)

curscl = 0


def changeScl():
    # change the scale for snp.choice argument
    global curscl
    curscl = (curscl + 1) % len(scls)
    snp.choice = scls[curscl]
    print(snp.choice)


metscl = Metro(time=8).play()
tr = TrigFunc(metscl, function=changeScl)

c = TrigEnv(met, table=env, mul=0.07)
d = Osc(table=wav, freq=snp, mul=c).out()
d1 = Osc(table=wav, freq=snp * 0.999, mul=c).out()
d2 = Osc(table=wav, freq=snp * 1.002, mul=c).out()
d3 = Osc(table=wav, freq=snp * 0.997, mul=c).out()

s.gui(locals())