-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmilk.py
More file actions
50 lines (37 loc) · 1.14 KB
/
milk.py
File metadata and controls
50 lines (37 loc) · 1.14 KB
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
44
45
46
47
48
49
50
import pprint
import os
import hashlib
def sha256(s):
h = hashlib.sha256((s)).digest()[0:8]
return h.encode("hex")
class MilkDrop:
def play(self):
self.spill()
os.system('play %s' % self.filename())
class SoxDrop(MilkDrop):
def __init__(self, indrops, effect):
self.indrops = indrops
self.effect = effect
self._filename = None
def filename(self):
if self._filename == None:
pprint.pprint(self.indrops)
self._filename = sha256("soxdrop%s%s" % (self.effect, "".join(map(lambda x: x.filename(), self.indrops))))
return self._filename+'.wav'
def spill(self, filename = None):
if filename == None:
filename = self.filename()
if os.path.exists(filename):
return
for drop in self.indrops:
drop.spill()
infiles = " ".join(map(lambda x: x.filename(), self.indrops))
os.system('sox %s %s %s' % (infiles, filename, self.effect))
print('sox %s %s %s\n' % (infiles, filename, self.effect))
class FileDrop(MilkDrop):
def __init__(self, filename):
self._filename = filename
def filename(self):
return self._filename
def spill(self):
pass