source: python.old/tests_demo_bench/pitch/bench-pitch-plot-isolated @ c52b483

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since c52b483 was bea5389, checked in by Paul Brossier <piem@piem.org>, 12 years ago

moved old python stuff out of tests/

  • Property mode set to 100755
File size: 1.9 KB
Line 
1#! /usr/bin/python
2
3if __name__ == '__main__':
4  import sys, Gnuplot
5  from aubio.gnuplot import gnuplot_create
6  from aubio.txtfile import read_datafile
7  from aubio.plot.keyboard import draw_keyboard
8  lines = []
9  titles = []
10  for file in range(len(sys.argv)-1):
11    l = read_datafile(sys.argv[file+1])
12    notes, score = [],[]
13    for i in range(len(l)):
14      notes.append(l[i][0])
15      score.append(l[i][2])
16    lines.append(Gnuplot.Data(notes,score,
17      with='linespoints',
18      title=sys.argv[file+1].split('.')[-1]))
19    titles.append(sys.argv[file+1].split('.')[-1])
20  blacks,whites = draw_keyboard(firstnote = notes[0], lastnote = notes[-1],
21    y0= 40, y1 = 50)
22
23  g = gnuplot_create(sys.argv[file+1].split('.')[-3],'ps')
24  #g = gnuplot_create('','')
25  #g = gnuplot_create('/tmp/test','eps')
26  g('set yrange [40:100]')
27  #g('set xrange [%f:%f]' % (notes[0],notes[-1]+60))
28  g('set size 0.5')
29  g('set key outside')
30
31  g('set border 3')
32  g('set xtics nomirror')
33  g('set ytics nomirror')
34  multiplot = 1
35  oplots = lines
36  g('set size 1,2')
37  if multiplot:
38    height = 2.
39    g('set lmargin 10')
40    #g('set rmargin 15')
41    g('set multiplot')
42    g('set yrange [50:100]')
43    g('set xrange [%f:%f]' % (notes[0],notes[-1]))
44    g('set xtics %f,12' % notes[0])
45    g('set nokey')
46    for i in range(len(oplots)):
47      g.ylabel(titles[i])
48      g('set size %f,%f' % (1.,height*.85/float(len(oplots))))
49      g('set origin 0,%f' % (height*(.15+.85*float(len(oplots)-i-1)/float(len(oplots)))))
50      g.plot(oplots[i])
51    g('set title "Raw pitch accuracy (%) against midi note numbers"')
52    g('set noxtics')
53    g('set noytics')
54    g('set size %f,%f' % (1.,.15*height))
55    g('set origin 0,%f' % 0)
56    g('set yrange [40:50]')
57    g('set xrange [%f:%f]' % (notes[0],notes[-1]))
58    g.xlabel('')
59    g.ylabel('')
60    g.plot(whites,blacks)
61    g('unset multiplot')
62  else:
63    g.plot(whites,blacks,*lines)
Note: See TracBrowser for help on using the repository browser.