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
151 #print 100.*esil/float(osil), 100.*epit/float(opit), 100.*echr/float(opit)151 #print 100.*esil/float(osil), 100.*epit/float(opit), 100.*echr/float(opit)
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,titles,outplot=None):
155 import Gnuplot155 import Gnuplot
156 156
157 time = [ (i+self.params.pitchdelay)*self.params.step for i in range(len(pitch)) ]157 time = [ (i+self.params.pitchdelay)*self.params.step for i in range(len(pitch)) ]
158 pitch = [aubio_freqtomidi(i) for i in pitch]158 pitch = [aubio_freqtomidi(i) for i in pitch]
159 oplots.append(Gnuplot.Data(time,pitch,with='lines',159 oplots.append(Gnuplot.Data(time,pitch,with='lines',
160 title=self.params.pitchmode))160 title=self.params.pitchmode))
161 titles.append(self.params.pitchmode)
161 162
162 163
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):
164 from aubio.gnuplot import gnuplot_init, audio_to_array, make_audio_plot165 from aubio.gnuplot import gnuplot_init, audio_to_array, make_audio_plot
165 import re166 import re
166 import Gnuplot167 import Gnuplot
@@ -169,10 +170,11 @@ class taskpitch(task): · 2 unmodified lines
169 f = make_audio_plot(time,data)170 f = make_audio_plot(time,data)
170 171
171 # check if ground truth exists172 # check if ground truth exists
172 timet,pitcht = self.gettruth()173 if truth:
173 if timet and pitcht:174 timet,pitcht = self.gettruth()
174 oplots = [Gnuplot.Data(timet,pitcht,with='lines',175 if timet and pitcht:
175 title='ground truth')] + oplots176 oplots = [Gnuplot.Data(timet,pitcht,with='lines',
177 title='ground truth')] + oplots
176 178
177 t = Gnuplot.Data(0,0,with='impulses') 179 t = Gnuplot.Data(0,0,with='impulses')
178 180
@@ -180,13 +182,17 @@ class taskpitch(task): · 1 unmodified line
180 g('set title \'%s\'' % (re.sub('.*/','',self.input)))182 g('set title \'%s\'' % (re.sub('.*/','',self.input)))
181 g('set multiplot')183 g('set multiplot')
182 # hack to align left axis184 # hack to align left axis
183 g('set lmargin 15')185 g('set lmargin 4')
186 g('set rmargin 4')
184 # plot waveform and onsets187 # plot waveform and onsets
185 g('set size 1,0.3')188 g('set size 1,0.3')
186 g('set ytics 10')189 g('set ytics 10')
187 g('set origin 0,0.7')190 g('set origin 0,0.7')
188 g('set xrange [0:%f]' % max(time)) 191 g('set xrange [0:%f]' % max(time))
189 g('set yrange [-1:1]') 192 g('set yrange [-1:1]')
193 g('set noytics')
194 g('set y2tics -1,1')
195 g.xlabel('time (s)',offset=(0,0.8))
190 g.ylabel('amplitude')196 g.ylabel('amplitude')
191 g.plot(f)197 g.plot(f)
192 g('unset title')198 g('unset title')
@@ -204,15 +210,20 @@ class taskpitch(task): · 11 unmodified lines
204 else: 210 else:
205 g.ylabel('midi')211 g.ylabel('midi')
206 g('set yrange [%f:%f]' % (aubio_freqtomidi(self.params.pitchmin), aubio_freqtomidi(self.params.pitchmax)))212 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))
207 g('set key right top')214 g('set key right top')
208 g('set noclip one') 215 g('set noclip one')
209 g('set format x ""')216 g('set format x ""')
210 if multiplot:217 if multiplot:
218 g('set tmargin 0')
211 for i in range(len(oplots)):219 for i in range(len(oplots)):
212 # plot onset detection functions220 # plot onset detection functions
213 g('set size 1,%f' % (0.7/(len(oplots))))221 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))))
215 g('set xrange [0:%f]' % max(time))223 g('set xrange [0:%f]' % max(time))
224 g('set nokey')
225 g.ylabel(titles[i])
226 g.xlabel('')
216 g.plot(oplots[i])227 g.plot(oplots[i])
217 else:228 else:
218 g.plot(*oplots)229 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