History

update params and pitch update params and pitch

Paul Brossier committed 20 years ago

Commit 4798fdf1 parent 650e39b3 files · +26 −22Browse files

Showing the changes to python (3 of 3 files). Show all

Unified · Split

3 files
  1. python/aubio/task/params.py +2 −1
  2. python/aubio/task/pitch.py +7 −7
  3. python/aubiopitch +17 −14
python/aubio/task/params.py+2−1
@@ -25,8 +25,9 @@ class taskparams(object): · 24 unmodified lines
25 # also best param for yinfft polyphonic Mirex0425 # also best param for yinfft polyphonic Mirex04
26 self.yinfftthresh = 0.85 26 self.yinfftthresh = 0.85
27 self.pitchsmooth = 027 self.pitchsmooth = 0
28 self.pitchmin=10.28 self.pitchmin=20.
29 self.pitchmax=20000.29 self.pitchmax=20000.
30 self.pitchdelay = -0.5
30 self.dcthreshold = -1.31 self.dcthreshold = -1.
31 self.omode = aubio_pitchm_freq32 self.omode = aubio_pitchm_freq
32 self.verbose = False33 self.verbose = False
python/aubio/task/pitch.py+7−7
@@ -78,7 +78,7 @@ class taskpitch(task): · 77 unmodified lines
78 pitch.append(self.truth)78 pitch.append(self.truth)
79 else:79 else:
80 pitch.append(-1.)80 pitch.append(-1.)
81 return time,pitch #0,aubio_miditofreq(float(floatpit))81 return time,pitch
82 except ValueError:82 except ValueError:
83 # FIXME very weak check83 # FIXME very weak check
84 if not os.path.isfile(datafile):84 if not os.path.isfile(datafile):
@@ -120,7 +120,7 @@ class taskpitch(task): · 35 unmodified lines
120 for i in range(len(pitch)):120 for i in range(len(pitch)):
121 if pitch[i] == "nan" or pitch[i] == -1:121 if pitch[i] == "nan" or pitch[i] == -1:
122 pitch[i] = -1122 pitch[i] = -1
123 time = [ i*self.params.step for i in range(len(pitch)) ]123 time = [ (i+self.params.pitchdelay)*self.params.step for i in range(len(pitch)) ]
124 #print len(timet),len(pitcht)124 #print len(timet),len(pitcht)
125 #print len(time),len(pitch)125 #print len(time),len(pitch)
126 if len(timet) != len(time):126 if len(timet) != len(time):
@@ -152,16 +152,15 @@ class taskpitch(task): · 25 unmodified lines
152 return osil, esil, opit, epit, echr152 return osil, esil, opit, epit, echr
153 153
154 def plot(self,pitch,wplot,oplots,outplot=None):154 def plot(self,pitch,wplot,oplots,outplot=None):
155 import numarray
156 import Gnuplot155 import Gnuplot
157 156
158 downtime = self.params.step*numarray.arange(len(pitch))157 time = [ (i+self.params.pitchdelay)*self.params.step for i in range(len(pitch)) ]
159 pitch = [aubio_freqtomidi(i) for i in pitch]158 pitch = [aubio_freqtomidi(i) for i in pitch]
160 oplots.append(Gnuplot.Data(downtime,pitch,with='lines',159 oplots.append(Gnuplot.Data(time,pitch,with='lines',
161 title=self.params.pitchmode))160 title=self.params.pitchmode))
162 161
163 162
164 def plotplot(self,wplot,oplots,outplot=None,multiplot = 0, midi = 1):163 def plotplot(self,wplot,oplots,outplot=None,multiplot = 1, midi = 1):
165 from aubio.gnuplot import gnuplot_init, audio_to_array, make_audio_plot164 from aubio.gnuplot import gnuplot_init, audio_to_array, make_audio_plot
166 import re165 import re
167 import Gnuplot166 import Gnuplot
@@ -184,6 +183,7 @@ class taskpitch(task): · 16 unmodified lines
184 g('set lmargin 15')183 g('set lmargin 15')
185 # plot waveform and onsets184 # plot waveform and onsets
186 g('set size 1,0.3')185 g('set size 1,0.3')
186 g('set ytics 10')
187 g('set origin 0,0.7')187 g('set origin 0,0.7')
188 g('set xrange [0:%f]' % max(time)) 188 g('set xrange [0:%f]' % max(time))
189 g('set yrange [-1:1]') 189 g('set yrange [-1:1]')
@@ -202,7 +202,7 @@ class taskpitch(task): · 12 unmodified lines
202 g.ylabel('f0 (Hz)')202 g.ylabel('f0 (Hz)')
203 g('set yrange [100:%f]' % self.params.pitchmax) 203 g('set yrange [100:%f]' % self.params.pitchmax)
204 else: 204 else:
205 g.ylabel('pitch (midi)')205 g.ylabel('midi')
206 g('set yrange [%f:%f]' % (aubio_freqtomidi(self.params.pitchmin), aubio_freqtomidi(self.params.pitchmax)))206 g('set yrange [%f:%f]' % (aubio_freqtomidi(self.params.pitchmin), aubio_freqtomidi(self.params.pitchmax)))
207 g('set key right top')207 g('set key right top')
208 g('set noclip one') 208 g('set noclip one')
python/aubiopitch+17−14
@@ -39,15 +39,16 @@ def parse_args(): · 38 unmodified lines
39 help="silence threshold [default=-70]")39 help="silence threshold [default=-70]")
40 parser.add_option("-D","--delay",40 parser.add_option("-D","--delay",
41 action="store", dest="delay", 41 action="store", dest="delay",
42 help="number of seconds to take back [default=system]\42 help="number of seconds frames to take back [default=0]")
43 default system delay is 2*hopsize/samplerate")43 parser.add_option("-S","--smoothing",
44 parser.add_option("-L","--localmin",44 action="store", dest="smoothing", default=False,
45 action="store_true", dest="localmin", default=False, 45 help="use a median filter of N frames [default=0]")
46 help="use local minima after peak detection")46 parser.add_option("-M","--maximum",
47 parser.add_option("-c","--cut",47 action="store", dest="pitchmax", default=False,
48 action="store_true", dest="cut", default=False,48 help="maximum pitch value to look for (Hz) [default=20000]")
49 help="cut input sound file at detected labels \49 parser.add_option("-l","--minimum",
50 best used with option -L")50 action="store", dest="pitchmin", default=False,
51 help="minimum pitch value to look for (Hz) [default=20]")
51 # to be implemented52 # to be implemented
52 parser.add_option("-n","--note",53 parser.add_option("-n","--note",
53 action="store_true", dest="note", default=False,54 action="store_true", dest="note", default=False,
@@ -55,13 +56,13 @@ def parse_args(): · 1 unmodified line
55 # plotting functions56 # plotting functions
56 parser.add_option("-p","--plot",57 parser.add_option("-p","--plot",
57 action="store_true", dest="plot", default=False, 58 action="store_true", dest="plot", default=False,
58 help="NOT IMPLEMENTED draw plot")59 help="draw plot of the pitch track")
59 parser.add_option("-O","--outplot",60 parser.add_option("-O","--outplot",
60 action="store", dest="outplot", default=None, 61 action="store", dest="outplot", default=None,
61 help="NOT IMPLEMENTED save plot to output.{ps,png}")62 help="save the plot to output.{ps,png,svg} instead of displaying it")
62 parser.add_option("-v","--verbose",63 parser.add_option("-v","--verbose",
63 action="store_true", dest="verbose", default=False,64 action="store_true", dest="verbose", default=False,
64 help="make lots of noise [default]")65 help="make lots of noise")
65 parser.add_option("-q","--quiet",66 parser.add_option("-q","--quiet",
66 action="store_false", dest="verbose", default=False, 67 action="store_false", dest="verbose", default=False,
67 help="be quiet")68 help="be quiet")
@@ -92,10 +93,12 @@ params.step = params.samplerate/float(params.hopsize) · 24 unmodified lines
92params.yinthresh = float(options.threshold)93params.yinthresh = float(options.threshold)
93params.silence = float(options.silence)94params.silence = float(options.silence)
94params.verbose = options.verbose95params.verbose = options.verbose
96if options.smoothing: params.pitchsmooth = int(options.smoothing)
97if options.pitchmax: params.pitchmax = int(options.pitchmax)
98if options.pitchmin: params.pitchmin = int(options.pitchmin)
95#mintol = float(options.mintol)*step99#mintol = float(options.mintol)*step
96# default take back system delay100# default take back system delay
97if options.delay: delay = float(options.delay)101if options.delay: params.pitchdelay = float(options.delay)
98else: delay = 2./params.step
99 102
100if options.note:103if options.note:
101 exit("not implemented yet")104 exit("not implemented yet")

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t