Changeset f8c75aa for python


Ignore:
Timestamp:
Nov 5, 2018, 2:01:41 PM (13 months ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master
Children:
dc74f69
Parents:
a3e152a
Message:

[py] [style] add space after , in cut.py

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/lib/aubio/cut.py

    ra3e152a rf8c75aa  
    66
    77import sys
     8import warnings
    89from aubio.cmd import AubioArgumentParser
     10from aubio.slicing import slice_source_at_stamps
     11
    912
    1013def aubio_cut_parser():
    1114    parser = AubioArgumentParser()
    1215    parser.add_input()
    13     parser.add_argument("-O","--onset-method",
     16    parser.add_argument("-O", "--onset-method",
    1417            action="store", dest="onset_method", default='default',
    1518            metavar = "<onset_method>",
     
    1720                    complexdomain|hfc|phase|specdiff|energy|kl|mkl")
    1821    # cutting methods
    19     parser.add_argument("-b","--beat",
     22    parser.add_argument("-b", "--beat",
    2023            action="store_true", dest="beat", default=False,
    2124            help="slice at beat locations")
    2225    """
    23     parser.add_argument("-S","--silencecut",
     26    parser.add_argument("-S", "--silencecut",
    2427            action="store_true", dest="silencecut", default=False,
    2528            help="use silence locations")
    26     parser.add_argument("-s","--silence",
     29    parser.add_argument("-s", "--silence",
    2730            metavar = "<value>",
    2831            action="store", dest="silence", default=-70,
     
    3134    # algorithm parameters
    3235    parser.add_buf_hop_size()
    33     parser.add_argument("-t","--threshold", "--onset-threshold",
     36    parser.add_argument("-t", "--threshold", "--onset-threshold",
    3437            metavar = "<threshold>", type=float,
    3538            action="store", dest="threshold", default=0.3,
    3639            help="onset peak picking threshold [default=0.3]")
    37     parser.add_argument("-c","--cut",
     40    parser.add_argument("-c", "--cut",
    3841            action="store_true", dest="cut", default=False,
    3942            help="cut input sound file at detected labels")
     
    4144
    4245    """
    43     parser.add_argument("-D","--delay",
     46    parser.add_argument("-D", "--delay",
    4447            action = "store", dest = "delay", type = float,
    4548            metavar = "<seconds>", default=0,
    4649            help="number of seconds to take back [default=system]\
    4750                    default system delay is 3*hopsize/samplerate")
    48     parser.add_argument("-C","--dcthreshold",
     51    parser.add_argument("-C", "--dcthreshold",
    4952            metavar = "<value>",
    5053            action="store", dest="dcthreshold", default=1.,
    5154            help="onset peak picking DC component [default=1.]")
    52     parser.add_argument("-L","--localmin",
     55    parser.add_argument("-L", "--localmin",
    5356            action="store_true", dest="localmin", default=False,
    5457            help="use local minima after peak detection")
    55     parser.add_argument("-d","--derivate",
     58    parser.add_argument("-d", "--derivate",
    5659            action="store_true", dest="derivate", default=False,
    5760            help="derivate onset detection function")
    58     parser.add_argument("-z","--zerocross",
     61    parser.add_argument("-z", "--zerocross",
    5962            metavar = "<value>",
    6063            action="store", dest="zerothres", default=0.008,
    6164            help="zero-crossing threshold for slicing [default=0.00008]")
    6265    # plotting functions
    63     parser.add_argument("-p","--plot",
     66    parser.add_argument("-p", "--plot",
    6467            action="store_true", dest="plot", default=False,
    6568            help="draw plot")
    66     parser.add_argument("-x","--xsize",
     69    parser.add_argument("-x", "--xsize",
    6770            metavar = "<size>",
    6871            action="store", dest="xsize", default=1.,
    6972            type=float, help="define xsize for plot")
    70     parser.add_argument("-y","--ysize",
     73    parser.add_argument("-y", "--ysize",
    7174            metavar = "<size>",
    7275            action="store", dest="ysize", default=1.,
    7376            type=float, help="define ysize for plot")
    74     parser.add_argument("-f","--function",
     77    parser.add_argument("-f", "--function",
    7578            action="store_true", dest="func", default=False,
    7679            help="print detection function")
    77     parser.add_argument("-n","--no-onsets",
     80    parser.add_argument("-n", "--no-onsets",
    7881            action="store_true", dest="nplot", default=False,
    7982            help="do not plot detected onsets")
    80     parser.add_argument("-O","--outplot",
     83    parser.add_argument("-O", "--outplot",
    8184            metavar = "<output_image>",
    8285            action="store", dest="outplot", default=None,
    8386            help="save plot to output.{ps,png}")
    84     parser.add_argument("-F","--spectrogram",
     87    parser.add_argument("-F", "--spectrogram",
    8588            action="store_true", dest="spectro", default=False,
    8689            help="add spectrogram to the plot")
     
    106109
    107110    if options.beat:
    108         o = tempo(options.onset_method, bufsize, hopsize, samplerate=samplerate)
     111        o = tempo(options.onset_method, bufsize, hopsize,
     112                samplerate=samplerate)
    109113    else:
    110         o = onset(options.onset_method, bufsize, hopsize, samplerate=samplerate)
     114        o = onset(options.onset_method, bufsize, hopsize,
     115                samplerate=samplerate)
    111116        if options.minioi:
    112117            if options.minioi.endswith('ms'):
     
    123128        samples, read = s()
    124129        if o(samples):
    125             timestamps.append (o.get_last())
    126             if options.verbose: print ("%.4f" % o.get_last_s())
     130            timestamps.append(o.get_last())
     131            if options.verbose:
     132                print("%.4f" % o.get_last_s())
    127133        total_frames += read
    128         if read < hopsize: break
     134        if read < hopsize:
     135            break
    129136    del s
    130137    return timestamps, total_frames
     138
    131139
    132140def _cut_slice(options, timestamps):
     
    135143    if nstamps > 0:
    136144        # generate output files
    137         from aubio.slicing import slice_source_at_stamps
    138145        timestamps_end = None
    139146        if options.cut_every_nslices:
     
    141148            nstamps = len(timestamps)
    142149        if options.cut_until_nslices and options.cut_until_nsamples:
    143             print ("warning: using cut_until_nslices, but cut_until_nsamples is set")
     150            msg = "using cut_until_nslices, but cut_until_nsamples is set"
     151            warnings.warn(msg)
    144152        if options.cut_until_nsamples:
    145             timestamps_end = [t + options.cut_until_nsamples for t in timestamps[1:]]
    146             timestamps_end += [ 1e120 ]
     153            lag = options.cut_until_nsamples
     154            timestamps_end = [t + lag for t in timestamps[1:]]
     155            timestamps_end += [1e120]
    147156        if options.cut_until_nslices:
    148             timestamps_end = [t for t in timestamps[1 + options.cut_until_nslices:]]
    149             timestamps_end += [ 1e120 ] * (options.cut_until_nslices + 1)
     157            slice_lag = options.cut_until_nslices
     158            timestamps_end = [t for t in timestamps[1 + slice_lag:]]
     159            timestamps_end += [1e120] * (options.cut_until_nslices + 1)
    150160        slice_source_at_stamps(options.source_uri,
    151161                timestamps, timestamps_end = timestamps_end,
     
    168178
    169179    # print some info
    170     duration = float (total_frames) / float(options.samplerate)
     180    duration = float(total_frames) / float(options.samplerate)
    171181    base_info = '%(source_uri)s' % {'source_uri': options.source_uri}
    172182    base_info += ' (total %(duration).2fs at %(samplerate)dHz)\n' % \
Note: See TracChangeset for help on using the changeset viewer.