Changeset 83ff0ab for python/aubiocut


Ignore:
Timestamp:
Feb 26, 2006, 6:35:16 PM (19 years ago)
Author:
Paul Brossier <piem@altern.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
d3efa4e
Parents:
84e80a1
Message:

updated aubiocut to new tasks, added option to print and plot only functions
updated aubiocut to new tasks, added option to print and plot only functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/aubiocut

    r84e80a1 r83ff0ab  
    2929                          action="store", dest="threshold", default=0.650,
    3030                          help="onset peak picking threshold [default=0.650]")
     31        parser.add_option("-C","--dcthreshold",
     32                          action="store", dest="dcthreshold", default=-1.,
     33                          help="onset peak picking DC component [default=-1.]")
    3134        parser.add_option("-s","--silence",
    3235                          action="store", dest="silence", default=-70,
     
    5962                          action="store_true", dest="plot", default=False,
    6063                          help="draw plot")
     64        parser.add_option("-f","--function",
     65                          action="store_true", dest="func", default=False,
     66                          help="print detection function")
     67        parser.add_option("-n","--no-onsets",
     68                          action="store_true", dest="nplot", default=False,
     69                          help="plot only detection functions")
    6170        parser.add_option("-O","--outplot",
    6271                          action="store", dest="outplot", default=None,
     
    8594params.bufsize    = int(options.bufsize)
    8695params.threshold  = float(options.threshold)
     96params.dcthreshold = float(options.dcthreshold)
    8797params.zerothres  = float(options.zerothres)
    8898params.silence    = float(options.silence)
    8999params.mintol     = float(options.mintol)
     100params.verbose    = options.verbose
    90101# default take back system delay
    91 if options.delay: delay = float(options.delay)
    92 else:             delay = 3./params.step
     102if options.delay: params.delay = int(float(options.delay)/params.step)
    93103
     104dotask = taskonset
     105if options.beat:
     106        dotask = taskbeat
     107elif options.silencecut:
     108        dotask = tasksilence
     109elif options.plot or options.func:
     110        params.storefunc=True
     111else:             
     112        params.storefunc=False
    94113
    95114lonsets, lofunc = [], []
     115wplot,oplots = [],[]
    96116modes = options.mode.split(',')
    97117for i in range(len(modes)):
    98 
    99118        params.onsetmode = modes[i]
    100         dotask = taskonset
    101         if options.beat:
    102                 dotask = taskbeat
    103         elif options.silencecut:
    104                 dotask = tasksilence
    105         elif options.plot:
    106                 params.storefunc=True
    107         else:             
    108                 params.storefunc=False
    109119        filetask = dotask(filename,params=params)
    110120        onsets = filetask.compute_all()
     121
     122        #lonsets.append(onsets)
    111123        if not options.silencecut:
    112124                ofunc = filetask.ofunc
    113         #onsets, ofunc = getonsets(filename,threshold,silence,
    114         #        mode=mode[i],localmin=options.localmin,
    115         #        derivate=options.derivate,
    116         #        bufsize=bufsize,hopsize=hopsize,storefunc=True)
    117 
    118         # take back system delay
    119         if delay != 0:
    120                 for each in range(len(onsets)):
    121                         onsets[each] = onsets[each][0] - delay*params.step
    122 
    123         # prune doubled
    124         params.mintol *= params.step
    125         if params.mintol > 0:
    126                 last = -2*params.mintol
    127                 newonsets = []
    128                 for new in onsets:
    129                         if (new - last > params.mintol):
    130                                 newonsets.append(new)
    131                         last = new
    132                 onsets = newonsets
    133 
    134         lonsets.append(onsets)
    135         if not options.silencecut:
    136125                lofunc.append(ofunc)
    137126
    138         # print times in second
    139         if options.verbose:
    140                 #print modes[i]
    141                 for i in range(len(onsets)):
    142                                 print onsets[i]*params.step
     127        if options.plot: filetask.plot(onsets, ofunc, wplot, oplots, nplot=options.nplot)
    143128
    144         if options.plot:
    145                 filetask.plot(onsets, ofunc)
    146                 filetask.plotplot(outplot=options.outplot)
     129        if options.func:
     130                for i in ofunc:
     131                        print i
     132
     133if options.plot: filetask.plotplot(wplot, oplots, outplot=options.outplot)
    147134
    148135if options.cut:
Note: See TracChangeset for help on using the changeset viewer.