History

[py] [slicing] add option create_first, default to False

Paul Brossier committed 8 years ago

Commit c9c012e1 parent a88594d1 file · +4 −3Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/lib/aubio/slicing.py+4−3
@@ -6,13 +6,14 @@ from aubio import source, sink · 5 unmodified lines
6_max_timestamp = 1e1206_max_timestamp = 1e120
7 7
8def slice_source_at_stamps(source_file, timestamps, timestamps_end=None,8def 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] + timestamps17 timestamps = [0] + timestamps
17 if timestamps_end is not None:18 if timestamps_end is not None:
18 timestamps_end = [timestamps[1] - 1] + timestamps_end19 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 region79 # 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", remaining81 #print("closing region", "remaining", remaining)
81 # close this file82 # close this file
82 _sink.close()83 _sink.close()
83 elif read > start:84 elif read > start:

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t