From 4798fdf068bb6b3c8d6eb5529c5628a6505fa564 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Thu, 20 Apr 2006 12:46:42 +0000 Subject: [PATCH] update params and pitch update params and pitch --- python/aubio/task/params.py | 3 ++- python/aubio/task/pitch.py | 14 +++++++------- python/aubiopitch | 31 +++++++++++++++++-------------- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/python/aubio/task/params.py b/python/aubio/task/params.py index ef8f9610..8907da03 100644 --- a/python/aubio/task/params.py +++ b/python/aubio/task/params.py @@ -25,8 +25,9 @@ class taskparams(object): # also best param for yinfft polyphonic Mirex04 self.yinfftthresh = 0.85 self.pitchsmooth = 0 - self.pitchmin=10. + self.pitchmin=20. self.pitchmax=20000. + self.pitchdelay = -0.5 self.dcthreshold = -1. self.omode = aubio_pitchm_freq self.verbose = False diff --git a/python/aubio/task/pitch.py b/python/aubio/task/pitch.py index f2e8312a..242b80e4 100644 --- a/python/aubio/task/pitch.py +++ b/python/aubio/task/pitch.py @@ -78,7 +78,7 @@ class taskpitch(task): pitch.append(self.truth) else: pitch.append(-1.) - return time,pitch #0,aubio_miditofreq(float(floatpit)) + return time,pitch except ValueError: # FIXME very weak check if not os.path.isfile(datafile): @@ -120,7 +120,7 @@ class taskpitch(task): for i in range(len(pitch)): if pitch[i] == "nan" or pitch[i] == -1: pitch[i] = -1 - time = [ i*self.params.step for i in range(len(pitch)) ] + time = [ (i+self.params.pitchdelay)*self.params.step for i in range(len(pitch)) ] #print len(timet),len(pitcht) #print len(time),len(pitch) if len(timet) != len(time): @@ -152,16 +152,15 @@ class taskpitch(task): return osil, esil, opit, epit, echr def plot(self,pitch,wplot,oplots,outplot=None): - import numarray import Gnuplot - downtime = self.params.step*numarray.arange(len(pitch)) + time = [ (i+self.params.pitchdelay)*self.params.step for i in range(len(pitch)) ] pitch = [aubio_freqtomidi(i) for i in pitch] - oplots.append(Gnuplot.Data(downtime,pitch,with='lines', + oplots.append(Gnuplot.Data(time,pitch,with='lines', title=self.params.pitchmode)) - def plotplot(self,wplot,oplots,outplot=None,multiplot = 0, midi = 1): + def plotplot(self,wplot,oplots,outplot=None,multiplot = 1, midi = 1): from aubio.gnuplot import gnuplot_init, audio_to_array, make_audio_plot import re import Gnuplot @@ -184,6 +183,7 @@ class taskpitch(task): g('set lmargin 15') # plot waveform and onsets g('set size 1,0.3') + g('set ytics 10') g('set origin 0,0.7') g('set xrange [0:%f]' % max(time)) g('set yrange [-1:1]') @@ -202,7 +202,7 @@ class taskpitch(task): g.ylabel('f0 (Hz)') g('set yrange [100:%f]' % self.params.pitchmax) else: - g.ylabel('pitch (midi)') + g.ylabel('midi') g('set yrange [%f:%f]' % (aubio_freqtomidi(self.params.pitchmin), aubio_freqtomidi(self.params.pitchmax))) g('set key right top') g('set noclip one') diff --git a/python/aubiopitch b/python/aubiopitch index 7d3cbecc..e6852cb2 100755 --- a/python/aubiopitch +++ b/python/aubiopitch @@ -39,15 +39,16 @@ def parse_args(): help="silence threshold [default=-70]") parser.add_option("-D","--delay", action="store", dest="delay", - help="number of seconds to take back [default=system]\ - default system delay is 2*hopsize/samplerate") - parser.add_option("-L","--localmin", - action="store_true", dest="localmin", default=False, - help="use local minima after peak detection") - parser.add_option("-c","--cut", - action="store_true", dest="cut", default=False, - help="cut input sound file at detected labels \ - best used with option -L") + help="number of seconds frames to take back [default=0]") + parser.add_option("-S","--smoothing", + action="store", dest="smoothing", default=False, + help="use a median filter of N frames [default=0]") + parser.add_option("-M","--maximum", + action="store", dest="pitchmax", default=False, + help="maximum pitch value to look for (Hz) [default=20000]") + parser.add_option("-l","--minimum", + action="store", dest="pitchmin", default=False, + help="minimum pitch value to look for (Hz) [default=20]") # to be implemented parser.add_option("-n","--note", action="store_true", dest="note", default=False, @@ -55,13 +56,13 @@ def parse_args(): # plotting functions parser.add_option("-p","--plot", action="store_true", dest="plot", default=False, - help="NOT IMPLEMENTED draw plot") + help="draw plot of the pitch track") parser.add_option("-O","--outplot", action="store", dest="outplot", default=None, - help="NOT IMPLEMENTED save plot to output.{ps,png}") + help="save the plot to output.{ps,png,svg} instead of displaying it") parser.add_option("-v","--verbose", action="store_true", dest="verbose", default=False, - help="make lots of noise [default]") + help="make lots of noise") parser.add_option("-q","--quiet", action="store_false", dest="verbose", default=False, help="be quiet") @@ -92,10 +93,12 @@ params.step = params.samplerate/float(params.hopsize) params.yinthresh = float(options.threshold) params.silence = float(options.silence) params.verbose = options.verbose +if options.smoothing: params.pitchsmooth = int(options.smoothing) +if options.pitchmax: params.pitchmax = int(options.pitchmax) +if options.pitchmin: params.pitchmin = int(options.pitchmin) #mintol = float(options.mintol)*step # default take back system delay -if options.delay: delay = float(options.delay) -else: delay = 2./params.step +if options.delay: params.pitchdelay = float(options.delay) if options.note: exit("not implemented yet") -- 2.26.2