Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -6,13 +6,14 @@ from aubio import source, sink · 5 unmodified lines | |||
| 6 | _max_timestamp = 1e120 | 6 | _max_timestamp = 1e120 |
| 7 | 7 | ||
| 8 | def slice_source_at_stamps(source_file, timestamps, timestamps_end=None, | 8 | def slice_source_at_stamps(source_file, timestamps, timestamps_end=None, |
| 9 | output_dir=None, samplerate=0, hopsize=256): | 9 | output_dir=None, samplerate=0, hopsize=256, |
| 10 | create_first=False): | ||
| 10 | """ slice a sound file at given timestamps """ | 11 | """ slice a sound file at given timestamps """ |
| 11 | 12 | ||
| 12 | if timestamps is None or len(timestamps) == 0: | 13 | if timestamps is None or len(timestamps) == 0: |
| 13 | raise ValueError("no timestamps given") | 14 | raise ValueError("no timestamps given") |
| 14 | 15 | ||
| 15 | if timestamps[0] != 0: | 16 | if timestamps[0] != 0 and create_first: |
| 16 | timestamps = [0] + timestamps | 17 | timestamps = [0] + timestamps |
| 17 | if timestamps_end is not None: | 18 | if timestamps_end is not None: |
| 18 | timestamps_end = [timestamps[1] - 1] + timestamps_end | 19 | timestamps_end = [timestamps[1] - 1] + timestamps_end |
| @@ -77,7 +78,7 @@ def slice_source_at_stamps(source_file, timestamps, timestamps_end=None, · 58 unmodified lines | |||
| 77 | if remaining > start: | 78 | if remaining > start: |
| 78 | # write remaining samples from current region | 79 | # write remaining samples from current region |
| 79 | _sink.do_multi(vec[:, start:remaining], remaining - start) | 80 | _sink.do_multi(vec[:, start:remaining], remaining - start) |
| 80 | #print "closing region", "remaining", remaining | 81 | #print("closing region", "remaining", remaining) |
| 81 | # close this file | 82 | # close this file |
| 82 | _sink.close() | 83 | _sink.close() |
| 83 | elif read > start: | 84 | elif read > start: |