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):
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):
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
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]')
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')
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,
# 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")
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")