File: SimpleSampler.py

package info (click to toggle)
zyne 0.1.2-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, stretch
  • size: 1,384 kB
  • ctags: 706
  • sloc: python: 3,873; sh: 32; makefile: 15
file content (35 lines) | stat: -rw-r--r-- 797 bytes parent folder | download
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
#!/usr/bin/env python
# encoding: utf-8
"""
Created by belangeo on 2010-11-25.
"""
from pyo import *
import os, sys

if len(sys.argv) < 2:
    print "SimpleSampler must be called with a sound folder path in argument!"
    sys.exit()
else:
    path = sys.argv[1]

pm_list_devices()

s = Server(sr=44100, nchnls=2, buffersize=256, duplex=0)
dev = input("Enter your midi device number : ")
s.setMidiInputDevice(dev)
s.boot()

snds = sorted([f for f in os.listdir(path) if f[-4:].lower() in [".wav", ".aif"]])

print "loading soundfiles..."

objs = []
for i, f in enumerate(snds):
    t = SndTable(os.path.join(path,f))
    n = Notein(1,0,i+36,i+36)
    pl = TrigEnv(Thresh(n["velocity"]), t, t.getDur(), mul=Port(n["velocity"],.001,1)).out()
    objs.extend([t,n,pl])

print "Done."

s.gui(locals())