Skip to content

Instantly share code, notes, and snippets.

@hecanjog
Created December 24, 2014 21:06
Show Gist options
  • Save hecanjog/2d065dd75586ba4868f9 to your computer and use it in GitHub Desktop.
Save hecanjog/2d065dd75586ba4868f9 to your computer and use it in GitHub Desktop.
skip.py
from pippi import dsp
skip_length = dsp.mstf(178)
num_alts = 5
num_sections = 20
section_length = dsp.stf(30)
snd = dsp.read('shadows.wav').data
out = ''
def choose_part(snd, skip_length):
return dsp.cut(snd, dsp.randint(0, dsp.flen(snd) - skip_length), skip_length)
snd = dsp.cut(snd, 0, dsp.stf(15))
for section in range(num_sections):
elapsed = 0
ost = choose_part(snd, skip_length)
alts = [ choose_part(snd, skip_length) for a in range(num_alts) ]
while elapsed < section_length:
if dsp.rand() < 0.975:
out += ost
elapsed += skip_length
else:
num_skips = dsp.randint(2, 3)
out += ''.join([ dsp.randchoose(alts) for a in range(num_skips) ])
elapsed += skip_length * num_skips
dsp.write(out, 'skipout')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment