File: random_waves.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 (14 lines) | stat: -rw-r--r-- 399 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import random

feed = SigTo(0.05, 0.05, 0.05)
amp = Fader(fadein=0.005, fadeout=0.12, dur=0.125)
syn = SineLoop(freq=[500, 510], feedback=feed, mul=amp * amp)
rev = WGVerb(syn, feedback=0.85, cutoff=4500, bal=0.1).out()


def choose(a, b):
    x = random.randint(a, b)
    deg = [0, 2, 3, 5, 7, 8, 11][x % 7]
    hz = midiToHz(deg + (x / 7 * 12 + 36))
    syn.freq = [hz, hz * 1.005]
    amp.play()