File: schedule_sequence.py

package info (click to toggle)
bespokesynth 1.3.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 44,592 kB
  • sloc: cpp: 117,136; ansic: 18,752; python: 593; xml: 74; makefile: 4
file content (22 lines) | stat: -rw-r--r-- 1,141 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
#schedule a sequence with a tidal-like pattern notation

def schedule_seq(seq, pitchOffset=0, velocity=80, start=0, bars=1, sustain=1, pan=0, output=None, velocityRandomization=0, panRandomization=0):
   if output is None:
      output = this.get_caller()
   if not type(seq) is list:
      seq = [seq]
   if len(seq) == 0:
      return
   stepLength = float(bars) / len(seq)
   for i,entry in enumerate(seq):
      if entry != '':
         if type(entry) is tuple:
            for subentry in entry:
               schedule_seq(subentry, pitchOffset, velocity, start + stepLength * i, stepLength, sustain, pan, output)
         elif type(entry) is list:
            schedule_seq(entry, pitchOffset, velocity, start + stepLength * i, stepLength, sustain, pan, output)
         elif type(entry) is int or type(entry) is str:
            pitch = entry
            if type(entry) is str:
               pitch = bespoke.name_to_pitch(entry)
            output.schedule_note(start + stepLength * i, pitch + pitchOffset, int(velocity * random.uniform(1-velocityRandomization,1)), stepLength*sustain, pan=pan * random.uniform(1-panRandomization,1))