Changeset 4f4a8a4 for python/aubiocut


Ignore:
Timestamp:
Dec 19, 2005, 10:25:51 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:
f2adb86
Parents:
7c9ad74
Message:

move to new nodes and tasks
move to new nodes and tasks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/aubiocut

    r7c9ad74 r4f4a8a4  
    1616                          action="store", dest="filename",
    1717                          help="input sound file")
    18         parser.add_option("-m","--mode", action="callback",
    19                           callback=check_onset_mode, dest="mode", default=['dual'],
     18        parser.add_option("-m","--mode",
     19                          action="store", dest="mode", default=['dual'],
    2020                          help="onset detection mode [default=dual] \
    2121                          complexdomain|hfc|phase|specdiff|energy|kl|mkl|dual")
     
    8181
    8282filename   = options.filename
    83 samplerate = float(sndfile(filename).samplerate())
    84 hopsize    = int(options.hopsize)
    85 bufsize    = int(options.bufsize)
    86 step       = float(samplerate)/float(hopsize)
    87 threshold  = float(options.threshold)
    88 zerothres  = float(options.zerothres)
    89 silence    = float(options.silence)
    90 mintol     = float(options.mintol)*step
    91 mode       = options.mode
     83params = taskparams()
     84params.hopsize    = int(options.hopsize)
     85params.bufsize    = int(options.bufsize)
     86params.threshold  = float(options.threshold)
     87params.zerothres  = float(options.zerothres)
     88params.silence    = float(options.silence)
     89params.mintol     = float(options.mintol)
    9290# default take back system delay
    9391if options.delay: delay = float(options.delay)
    94 else:             delay = 3./step
     92else:             delay = 3./params.step
    9593
    9694if options.beat:
     
    9997elif options.silencecut:
    10098        onsets = getsilences(filename,hopsize=hopsize,silence=silence)
    101 elif options.plot: storefunc=True
    102 else:              storefunc=False
     99elif options.plot: params.storefunc=True
     100else:              params.storefunc=False
    103101
    104102lonsets, lofunc = [], []
    105 for i in range(len(mode)):
    106         onsets, ofunc = getonsets(filename,threshold,silence,
    107                 mode=mode[i],localmin=options.localmin,
    108                 derivate=options.derivate,
    109                 bufsize=bufsize,hopsize=hopsize,storefunc=True)
     103modes = options.mode.split(',')
     104for i in range(len(modes)):
     105
     106        params.onsetmode = modes[i]
     107        filetask = taskonset(filename,params=params)
     108        onsets = filetask.compute_all()
     109        ofunc = filetask.ofunc
     110        #onsets, ofunc = getonsets(filename,threshold,silence,
     111        #        mode=mode[i],localmin=options.localmin,
     112        #        derivate=options.derivate,
     113        #        bufsize=bufsize,hopsize=hopsize,storefunc=True)
    110114
    111115        # take back system delay
    112116        if delay != 0:
    113                 for i in range(len(onsets)):
    114                         onsets[i] -= delay*step
     117                for each in range(len(onsets)):
     118                        onsets[each] = onsets[each][0] - delay*params.step
    115119
    116120        # prune doubled
    117         if mintol > 0:
    118                 last = -2*mintol
     121        params.mintol *= params.step
     122        if params.mintol > 0:
     123                last = -2*params.mintol
    119124                newonsets = []
    120125                for new in onsets:
    121                         if (new - last > mintol):
     126                        if (new - last > params.mintol):
    122127                                newonsets.append(new)
    123128                        last = new
     
    127132        lofunc.append(ofunc)
    128133
    129 # print times in second
    130 if options.verbose:
    131         maxonset = 0
    132         for j in range(len(mode)):
    133                 for i in range(len(lonsets[j])):
    134                         print lonsets[j][i]/step
     134        # print times in second
     135        if options.verbose:
     136                print modes[i]
     137                maxonset = 0
     138                for i in range(len(onsets)):
     139                                print onsets[i]*params.step
    135140
    136 if options.plot:
    137         from aubio.gnuplot import plot_onsets
    138         plot_onsets(filename, lonsets, lofunc,
    139                 samplerate=samplerate, hopsize=hopsize, outplot=options.outplot)
     141        if options.plot:
     142                filetask.plot(onsets, ofunc)
     143                filetask.plotplot(outplot=options.outplot)
    140144
    141145if options.cut:
    142         cutfile(filename,onsets,zerothres=zerothres,bufsize=bufsize,hopsize=hopsize)
     146        a = taskcut(filename,onsets,params=params)
     147        a.compute_all()
Note: See TracChangeset for help on using the changeset viewer.