Changeset d9101a5 for python/aubiopitch


Ignore:
Timestamp:
Feb 15, 2006, 11:36:09 AM (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:
660c1d82
Parents:
e8d0c06
Message:

move aubiopitch to new tasks, comment out old task versions
move aubiopitch to new tasks, comment out old task versions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/aubiopitch

    re8d0c06 rd9101a5  
    1717                          action="store", dest="filename",
    1818                          help="input sound file")
    19         parser.add_option("-m","--mode", action="callback",
    20                           callback=check_pitch_mode, dest="mode",
    21                           default=[aubio_pitch_mcomb],
     19        parser.add_option("-m","--mode",
     20                          action="store", dest="mode", default='mcomb',
    2221                          help="pitch detection mode [default=mcomb] \
    2322                          mcomb|yin|fcomb|schmitt")
     
    8685
    8786filename   = options.filename
    88 samplerate = float(sndfile(filename).samplerate())
    89 hopsize    = int(options.hopsize)
    90 bufsize    = int(options.bufsize)
    91 step       = float(samplerate)/float(hopsize)
    92 threshold  = float(options.threshold)
    93 silence    = float(options.silence)
    94 mode       = options.mode
     87params = taskparams()
     88#params.samplerate = float(sndfile(filename).samplerate())
     89params.hopsize    = int(options.hopsize)
     90params.bufsize    = int(options.bufsize)
     91#params.step       = float(samplerate)/float(hopsize)
     92params.threshold  = float(options.threshold)
     93params.silence    = float(options.silence)
    9594#mintol     = float(options.mintol)*step
    9695# default take back system delay
    9796if options.delay: delay = float(options.delay)
    98 else:             delay = 2./step
     97else:             delay = 2./params.step
    9998
    10099if options.note:
    101100        exit("not implemented yet")
    102 else:
    103         pitch = []
    104         for i in range(len(mode)):
    105                 pitch.append(getpitch(filename, #threshold,
    106                         mode=mode[i],
    107                         omode=options.omode,
    108                         bufsize=bufsize,hopsize=hopsize,
    109                         silence=silence))
    110                 for j in range(len(pitch[i])):
    111                         if pitch[i][j] > 1500 or pitch[i][j] < 40:
    112                                 pitch[i][j] = 0.;
    113101
    114 ## take back system delay
    115 #if delay != 0:
    116 #        for i in range(len(onsets)):
    117 #                onsets[i] -= delay*step
    118 #
    119 ## prune doubled
    120 #if mintol > 0:
    121 #        last = -2*mintol
    122 #        newonsets = []
    123 #        for new in onsets:
    124 #                if (new - last > mintol):
    125 #                        newonsets.append(new)
    126 #                last = new
    127 #        onsets = newonsets
    128102
    129 # print times in second
    130 if options.verbose:
    131         for j in range(len(pitch[0])):
    132                 print "%f\t" % (j/step),
    133                 for i in range(len(pitch)):
    134                         print "%f\t" % pitch[i][j],
    135                 print
     103pitch = []
     104modes = options.mode.split(',')
     105for i in range(len(modes)):
     106        params.pitchmode  = modes[i]
     107        dotask = taskpitch
     108        #pitch.append(getpitch(filename, #threshold,
     109        #       mode=mode[i],
     110        #       omode=options.omode,
     111        #       bufsize=bufsize,hopsize=hopsize,
     112        #       silence=silence))
     113        filetask = dotask(filename,params=params)
     114        pitch.append(filetask.compute_all())
     115        for j in range(len(pitch[i])):
     116                if pitch[i][j] > 10000 or pitch[i][j] < 40:
     117                        pitch[i][j] = 0.;
    136118
    137 if options.plot:
    138         from aubio.gnuplot import plot_pitch
    139         plot_pitch(filename, pitch,
    140                 samplerate=samplerate, hopsize=hopsize, outplot=options.outplot)
     119        if options.verbose:
     120                for j in range(len(pitch[i])):
     121                        print "%f\t" % (j/params.step),
     122                        print "%f\t" % pitch[i][j],
     123                        print
     124
     125        if options.plot:
     126                filetask.plot(pitch,outplot=options.outplot)
Note: See TracChangeset for help on using the changeset viewer.