1 """Copyright (C) 2004 Paul Brossier <piem@altern.org>
2 print aubio.__LICENSE__ for the terms of use
6 Copyright (C) 2004 Paul Brossier <piem@altern.org>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 from numarray import *
27 import Gnuplot, Gnuplot.funcutils
29 def plotnote(la,title=None) :
30 if la[0,:].size() == 3:
31 d = plotnote_withends(la, plot_title=title)
33 # scale data if in freq (for REF.txt files)
34 if max(la[:,1] > 128 ):
35 print "scaling frequency data to midi range"
37 la[:,1] = log(la[:,1])/0.6931
40 d = plotnote_withoutends(la, plot_title=title)
43 def plotnote_multi(lalist,title=None,fileout=None) :
45 for i in range(len(lalist)):
46 d.append(plotnote(lalist[i], title=title))
50 def plotnote_withends(la,plot_title=None) :
53 x_widths = array(la[:,1]-la[:,0])/2.
55 d.append(Gnuplot.Data(
56 la[:,0]+x_widths, # x centers
59 __notesheight*ones(len(la) # y errors
61 title=plot_title,with=('boxxyerrorbars fs 3')))
66 def plotnote_withoutends(la,plot_title=None) :
67 """ bug: fails drawing last note """
70 x_widths = array(la[1:,0]-la[:-1,0])/2;
72 d.append(Gnuplot.Data(
73 la[:-1,0]+x_widths, # x centers
74 la[:-1,1], # y centers
76 __notesheight*ones(len(la)-1 # y errors
78 title=plot_title,with=('boxxyerrorbars fs 3')))
82 def plotnote_do(d,fileout=None):
83 g = Gnuplot.Gnuplot(debug=1, persist=1)
84 g.gnuplot('set style fill solid border 1; \
86 set boxwidth 0.9 relative; \
91 set grid xtics ytics mxtics mytics')
94 g.ylabel('Midi pitch')
96 #g.gnuplot('set multiplot')
99 #g.gnuplot('set nomultiplot')
101 g.hardcopy(fileout, enhanced=1, color=0)