History

python/scripts/aubiocut: add --cut-until-nsamples and --cut-until-nslices options

Paul Brossier committed 12 years ago

Commit 94b16e81 parent 35a44e91 file · +20 −2Browse files

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

Unified · Split

python/scripts/aubiocut+20−2
@@ -110,6 +110,15 @@ def parse_args(): · 109 unmodified lines
110110 metavar = "<outputdir>",
111111 action="store", dest="output_directory", default=None,
112112 help="specify path where slices of the original file should be created")
113+ parser.add_option("--cut-until-nsamples", type = int,
114+ metavar = "<samples>",
115+ action = "store", dest = "cut_until_nsamples", default = None,
116+ help="how many extra samples should be added at the end of each slice")
117+ parser.add_option("--cut-until-nslices", type = int,
118+ metavar = "<slices>",
119+ action = "store", dest = "cut_until_nslices", default = None,
120+ help="how many extra slices should be added at the end of each slice")
121+
113122 parser.add_option("-v","--verbose",
114123 action="store_true", dest="verbose", default=True,
115124 help="make lots of noise [default]")
@@ -165,9 +174,18 @@ if __name__ == '__main__': · 49 unmodified lines
165174
166175 # cutting pass
167176 if options.cut and nstamps > 0:
168− # generate output filenames
177+ # generate output files
169178 from aubio.slicing import slice_source_at_stamps
170− slice_source_at_stamps(source_file, timestamps,
179+ timestamps_end = None
180+ if options.cut_until_nslices and options.cut_until_nsamples:
181+ print "warning: using cut_until_nslices, but cut_until_nsamples is set"
182+ if options.cut_until_nsamples:
183+ timestamps_end = [t + options.cut_until_nsamples for t in timestamps[1:]]
184+ timestamps_end += [ 1e120 ]
185+ if options.cut_until_nslices:
186+ timestamps_end = [t for t in timestamps[1 + options.cut_until_nslices:]]
187+ timestamps_end += [ 1e120 ] * (options.cut_until_nslices + 1)
188+ slice_source_at_stamps(source_file, timestamps, timestamps_end = timestamps_end,
171189 output_dir = options.output_directory)
172190
173191 # print some info

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