"""
import sys
-#from aubio.task import *
-
-usage = "usage: %s [options] -i soundfile" % sys.argv[0]
-usage += "\n help: %s -h" % sys.argv[0]
def parse_args():
from optparse import OptionParser
+ usage = "usage: %s [options] -i soundfile" % sys.argv[0]
+ usage += "\n help: %s -h" % sys.argv[0]
parser = OptionParser(usage=usage)
parser.add_option("-i", "--input", action = "store", dest = "source_file",
help="input sound file to analyse", metavar = "<source_file>")
action="store_true", dest="cut", default=False,
help="cut input sound file at detected labels \
best used with option -L")
+
+ # minioi
+ parser.add_option("-M","--minioi",
+ metavar = "<value>", type='string',
+ action="store", dest="minioi", default="12ms",
+ help="minimum inter onset interval [default=12ms]")
+
"""
parser.add_option("-D","--delay",
action = "store", dest = "delay", type = "float",
metavar = "<value>",
action="store", dest="dcthreshold", default=1.,
help="onset peak picking DC component [default=1.]")
- parser.add_option("-M","--mintol",
- metavar = "<value>",
- action="store", dest="mintol", default=0.048,
- help="minimum inter onset interval [default=0.048]")
parser.add_option("-L","--localmin",
action="store_true", dest="localmin", default=False,
help="use local minima after peak detection")
metavar = "<samples>",
action = "store", dest = "cut_until_nsamples", default = None,
help="how many extra samples should be added at the end of each slice")
+ parser.add_option("--cut-every-nslices", type = int,
+ metavar = "<samples>",
+ action = "store", dest = "cut_every_nslices", default = None,
+ help="how many slices should be groupped together at each cut")
parser.add_option("--cut-until-nslices", type = int,
metavar = "<slices>",
action = "store", dest = "cut_until_nslices", default = None,
if len(args) == 1:
options.source_file = args[0]
else:
- print "no file name given\n", usage
+ print ("no file name given\n" + usage)
sys.exit(1)
return options, args
o = tempo(options.onset_method, bufsize, hopsize)
else:
o = onset(options.onset_method, bufsize, hopsize)
+ if options.minioi:
+ if options.minioi.endswith('ms'):
+ o.set_minioi_ms(int(options.minioi[:-2]))
+ elif options.minioi.endswith('s'):
+ o.set_minioi_s(int(options.minioi[:-1]))
+ else:
+ o.set_minioi(int(options.minioi))
o.set_threshold(options.threshold)
timestamps = []
samples, read = s()
if o(samples):
timestamps.append (o.get_last())
- if options.verbose: print "%.4f" % o.get_last_s()
+ if options.verbose: print ("%.4f" % o.get_last_s())
total_frames += read
if read < hopsize: break
del s
# generate output files
from aubio.slicing import slice_source_at_stamps
timestamps_end = None
+ if options.cut_every_nslices:
+ timestamps = timestamps[::options.cut_every_nslices]
+ nstamps = len(timestamps)
if options.cut_until_nslices and options.cut_until_nsamples:
- print "warning: using cut_until_nslices, but cut_until_nsamples is set"
+ print ("warning: using cut_until_nslices, but cut_until_nsamples is set")
if options.cut_until_nsamples:
timestamps_end = [t + options.cut_until_nsamples for t in timestamps[1:]]
timestamps_end += [ 1e120 ]
timestamps_end = [t for t in timestamps[1 + options.cut_until_nslices:]]
timestamps_end += [ 1e120 ] * (options.cut_until_nslices + 1)
slice_source_at_stamps(source_file, timestamps, timestamps_end = timestamps_end,
- output_dir = options.output_directory)
+ output_dir = options.output_directory,
+ samplerate = samplerate)
# print some info
duration = float (total_frames) / float(samplerate)