-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathtruncate.py
More file actions
34 lines (26 loc) · 846 Bytes
/
truncate.py
File metadata and controls
34 lines (26 loc) · 846 Bytes
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
import sys
from wavio import read_wave_file
from utils import start_of, end_of
def chop(aif):
file = read_wave_file(aif)
start, end = min([start_of(chan) for chan in file]), \
max([end_of(chan) for chan in file])
print aif, start, end, float(end) / len(file[0])
# outfile = aif + '.chopped.aif'
# r = wave.open(aif, 'rb')
# w = wave.open(outfile, 'wb')
# w.setnchannels(r.getnchannels())
# w.setsampwidth(r.getsampwidth())
# w.setframerate(r.getframerate())
# # Seek forward to the start point
# r.readframes(start)
# # Copy the frames from in to out
# w.writeframes(r.readframes(end - start))
# r.close()
# w.close()
# plt.plot(file[0][:(44100 * 2)])
# plt.axvline(start)
# plt.axvline(end)
# plt.show()
if __name__ == "__main__":
chop(sys.argv[1])