History

update pitch plot update pitch plot

Paul Brossier committed 20 years ago

Commit fb8bde71 parent fe4f78a1 file · +19 −8Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/aubio/task/pitch.py+19−8
@@ -151,16 +151,17 @@ class taskpitch(task): · 150 unmodified lines
151151 #print 100.*esil/float(osil), 100.*epit/float(opit), 100.*echr/float(opit)
152152 return osil, esil, opit, epit, echr
153153
154− def plot(self,pitch,wplot,oplots,outplot=None):
154+ def plot(self,pitch,wplot,oplots,titles,outplot=None):
155155 import Gnuplot
156156
157157 time = [ (i+self.params.pitchdelay)*self.params.step for i in range(len(pitch)) ]
158158 pitch = [aubio_freqtomidi(i) for i in pitch]
159159 oplots.append(Gnuplot.Data(time,pitch,with='lines',
160160 title=self.params.pitchmode))
161+ titles.append(self.params.pitchmode)
161162
162163
163− def plotplot(self,wplot,oplots,outplot=None,multiplot = 1, midi = 1):
164+ def plotplot(self,wplot,oplots,titles,outplot=None,multiplot = 1, midi = 1, truth = 1):
164165 from aubio.gnuplot import gnuplot_init, audio_to_array, make_audio_plot
165166 import re
166167 import Gnuplot
@@ -169,10 +170,11 @@ class taskpitch(task): · 2 unmodified lines
169170 f = make_audio_plot(time,data)
170171
171172 # check if ground truth exists
172− timet,pitcht = self.gettruth()
173− if timet and pitcht:
174− oplots = [Gnuplot.Data(timet,pitcht,with='lines',
175− title='ground truth')] + oplots
173+ if truth:
174+ timet,pitcht = self.gettruth()
175+ if timet and pitcht:
176+ oplots = [Gnuplot.Data(timet,pitcht,with='lines',
177+ title='ground truth')] + oplots
176178
177179 t = Gnuplot.Data(0,0,with='impulses')
178180
@@ -180,13 +182,17 @@ class taskpitch(task): · 1 unmodified line
180182 g('set title \'%s\'' % (re.sub('.*/','',self.input)))
181183 g('set multiplot')
182184 # hack to align left axis
183− g('set lmargin 15')
185+ g('set lmargin 4')
186+ g('set rmargin 4')
184187 # plot waveform and onsets
185188 g('set size 1,0.3')
186189 g('set ytics 10')
187190 g('set origin 0,0.7')
188191 g('set xrange [0:%f]' % max(time))
189192 g('set yrange [-1:1]')
193+ g('set noytics')
194+ g('set y2tics -1,1')
195+ g.xlabel('time (s)',offset=(0,0.8))
190196 g.ylabel('amplitude')
191197 g.plot(f)
192198 g('unset title')
@@ -204,15 +210,20 @@ class taskpitch(task): · 11 unmodified lines
204210 else:
205211 g.ylabel('midi')
206212 g('set yrange [%f:%f]' % (aubio_freqtomidi(self.params.pitchmin), aubio_freqtomidi(self.params.pitchmax)))
213+ g('set y2tics %f,%f' % (round(aubio_freqtomidi(self.params.pitchmin)+.5),12))
207214 g('set key right top')
208215 g('set noclip one')
209216 g('set format x ""')
210217 if multiplot:
218+ g('set tmargin 0')
211219 for i in range(len(oplots)):
212220 # plot onset detection functions
213221 g('set size 1,%f' % (0.7/(len(oplots))))
214− g('set origin 0,%f' % (float(i)*0.7/(len(oplots))))
222+ g('set origin 0,%f' % ((len(oplots)-float(i)-1)*0.7/(len(oplots))))
215223 g('set xrange [0:%f]' % max(time))
224+ g('set nokey')
225+ g.ylabel(titles[i])
226+ g.xlabel('')
216227 g.plot(oplots[i])
217228 else:
218229 g.plot(*oplots)

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