Changes in python/lib/aubio/slicing.py [c9c012e:dc654f8]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/lib/aubio/slicing.py
rc9c012e rdc654f8 7 7 8 8 def slice_source_at_stamps(source_file, timestamps, timestamps_end=None, 9 output_dir=None, samplerate=0, hopsize=256, 10 create_first=False): 9 output_dir=None, samplerate=0, hopsize=256): 11 10 """ slice a sound file at given timestamps """ 12 11 … … 14 13 raise ValueError("no timestamps given") 15 14 16 if timestamps[0] != 0 and create_first:15 if timestamps[0] != 0: 17 16 timestamps = [0] + timestamps 18 17 if timestamps_end is not None: … … 20 19 21 20 if timestamps_end is not None: 22 if len(timestamps_end) == len(timestamps) - 1: 23 timestamps_end = timestamps_end + [_max_timestamp] 24 elif len(timestamps_end) != len(timestamps): 21 if len(timestamps_end) != len(timestamps): 25 22 raise ValueError("len(timestamps_end) != len(timestamps)") 26 23 else: … … 52 49 vec, read = _source.do_multi() 53 50 # if the total number of frames read will exceed the next region start 54 whilelen(regions) and total_frames + read >= regions[0][0]:51 if len(regions) and total_frames + read >= regions[0][0]: 55 52 #print "getting", regions[0], "at", total_frames 56 53 # get next region … … 79 76 # write remaining samples from current region 80 77 _sink.do_multi(vec[:, start:remaining], remaining - start) 81 #print ("closing region", "remaining", remaining)78 #print "closing region", "remaining", remaining 82 79 # close this file 83 80 _sink.close() … … 86 83 _sink.do_multi(vec[:, start:read], read - start) 87 84 total_frames += read 88 # remove old slices89 slices = list(filter(lambda s: s['end_stamp'] > total_frames,90 slices))91 85 if read < hopsize: 92 86 break
Note: See TracChangeset
for help on using the changeset viewer.