From: Paul Brossier Date: Mon, 29 Oct 2018 14:32:24 +0000 (+0100) Subject: [py] [slicing] add option create_first, default to False X-Git-Tag: 0.4.8~92^2~13^2~4 X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=c9c012e61e07a5e4b1fe44e70bab45dc34ff7d5a;p=aubio.git [py] [slicing] add option create_first, default to False --- diff --git a/python/lib/aubio/slicing.py b/python/lib/aubio/slicing.py index 2ca116ec..c504ca02 100644 --- a/python/lib/aubio/slicing.py +++ b/python/lib/aubio/slicing.py @@ -6,13 +6,14 @@ from aubio import source, sink _max_timestamp = 1e120 def slice_source_at_stamps(source_file, timestamps, timestamps_end=None, - output_dir=None, samplerate=0, hopsize=256): + output_dir=None, samplerate=0, hopsize=256, + create_first=False): """ slice a sound file at given timestamps """ if timestamps is None or len(timestamps) == 0: raise ValueError("no timestamps given") - if timestamps[0] != 0: + if timestamps[0] != 0 and create_first: timestamps = [0] + timestamps if timestamps_end is not None: timestamps_end = [timestamps[1] - 1] + timestamps_end @@ -77,7 +78,7 @@ def slice_source_at_stamps(source_file, timestamps, timestamps_end=None, if remaining > start: # write remaining samples from current region _sink.do_multi(vec[:, start:remaining], remaining - start) - #print "closing region", "remaining", remaining + #print("closing region", "remaining", remaining) # close this file _sink.close() elif read > start: