Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -241,7 +241,8 @@ def plot_pitch(filename, pitch, samplerate=44100., hopsize=512, outplot=None): · 240 unmodified lines | |||
| 241 | maxpitch = 100 | 241 | maxpitch = 100 |
| 242 | for i in range(len(pitch)): | 242 | for i in range(len(pitch)): |
| 243 | downtime = (hopsize/samplerate)*numarray.arange(len(pitch[i])) | 243 | downtime = (hopsize/samplerate)*numarray.arange(len(pitch[i])) |
| 244 | d.append(Gnuplot.Data(downtime,pitch[i],with='lines')) | 244 | d.append(Gnuplot.Data(downtime,pitch[i],with='lines', |
| 245 | title=('%d' % i))) | ||
| 245 | maxpitch = max(maxpitch,max(pitch[i][:])*1.1) | 246 | maxpitch = max(maxpitch,max(pitch[i][:])*1.1) |
| 246 | 247 | ||
| 247 | # check if datafile exists truth | 248 | # check if datafile exists truth |
| @@ -251,9 +252,12 @@ def plot_pitch(filename, pitch, samplerate=44100., hopsize=512, outplot=None): · 3 unmodified lines | |||
| 251 | t = Gnuplot.Data(0,0,with='impulses') | 252 | t = Gnuplot.Data(0,0,with='impulses') |
| 252 | else: | 253 | else: |
| 253 | title = "truth file plotting not implemented yet" | 254 | title = "truth file plotting not implemented yet" |
| 254 | t = Gnuplot.Data(0,0,with='impulses') | 255 | values = aubio.txtfile.read_datafile(datafile) |
| 255 | #times,pitch = aubio.txtfile.read_datafile(datafile) | 256 | time, pitch = [], [] |
| 256 | #t = Gnuplot.Data(times,pitch,with='lines') | 257 | for i in range(len(values)): |
| 258 | time.append(values[i][0]) | ||
| 259 | pitch.append(values[i][1]) | ||
| 260 | d.append(Gnuplot.Data(time,pitch,with='lines',title='ground truth')) | ||
| 257 | 261 | ||
| 258 | #orig, missed, merged, expc, bad, doubled = \ | 262 | #orig, missed, merged, expc, bad, doubled = \ |
| 259 | # onset_roc(x2,x1,tol) | 263 | # onset_roc(x2,x1,tol) |
| @@ -300,6 +304,7 @@ def plot_pitch(filename, pitch, samplerate=44100., hopsize=512, outplot=None): · 40 unmodified lines | |||
| 300 | g('set origin 0,0') | 304 | g('set origin 0,0') |
| 301 | g('set xrange [0:%f]' % max(time)) | 305 | g('set xrange [0:%f]' % max(time)) |
| 302 | g('set yrange [40:%f]' % maxpitch) | 306 | g('set yrange [40:%f]' % maxpitch) |
| 307 | g('set key right top') | ||
| 303 | g.xlabel('time') | 308 | g.xlabel('time') |
| 304 | g.ylabel('frequency (Hz)') | 309 | g.ylabel('frequency (Hz)') |
| 305 | g.plot(*d) | 310 | g.plot(*d) |