Index: python/aubio/plot/keyboard.py
===================================================================
--- python/aubio/plot/keyboard.py	(revision ae3f5afd065d852fd0896363c9bd22113981f0ec)
+++ python/aubio/plot/keyboard.py	(revision ae3f5afd065d852fd0896363c9bd22113981f0ec)
@@ -0,0 +1,46 @@
+
+def draw_keyboard(firstnote = 21, lastnote = 108, y0 = 0, y1 = 1):
+  import Gnuplot
+  octaves = 10
+
+  # build template of white notes
+  scalew  = 12/7.
+  xw_temp = [i*scalew for i in range(0,7)]
+  # build template of black notes
+  scaleb  = 6/7.
+  xb_temp = [i*scaleb for i in [1,3,7,9,11]]
+
+  xb,xw = [],[]
+  for octave in range(octaves-1): 
+    for i in xb_temp:
+      curnote = i+12*octave
+      if  curnote > firstnote-1 and curnote < lastnote+1:
+        xb = xb + [curnote] 
+  for octave in range(octaves-1): 
+    for i in xw_temp:
+      curnote = i+12*octave
+      if  curnote > firstnote-1 and curnote < lastnote+1:
+        xw = xw + [curnote]
+
+  xwdelta = [1/2. * scalew for i in range(len(xw))]
+  yw      = [y0+(y1-y0)*1/2. for i in range(len(xw))]
+  ywdelta = [(y1-y0)*1/2. for i in range(len(xw))]
+
+  xbdelta = [2/3. * scaleb for i in range(len(xb))]
+  yb      = [y0+(y1-y0)*2/3. for i in range(len(xb))]
+  ybdelta = [(y1-y0)*1/3. for i in range(len(xb))]
+
+  whites  = Gnuplot.Data(xw,yw,xwdelta,ywdelta,with = 'boxxyerrorbars')
+  blacks  = Gnuplot.Data(xb,yb,xbdelta,ybdelta,with = 'boxxyerrorbars fill solid')
+
+  return blacks,whites
+
+if __name__ == '__main__':
+  from aubio.gnuplot import gnuplot_create
+  blacks,whites = draw_keyboard(firstnote = 21, lastnote = 108)
+  g = gnuplot_create('','')
+  #g('set style fill solid .5')
+  #g('set xrange [60-.5:72+.5]')
+  #g('set yrange [-0.1:1.1]')
+
+  g.plot(whites,blacks)
Index: python/aubio/plot/notes.py
===================================================================
--- python/aubio/plot/notes.py	(revision ae3f5afd065d852fd0896363c9bd22113981f0ec)
+++ python/aubio/plot/notes.py	(revision ae3f5afd065d852fd0896363c9bd22113981f0ec)
@@ -0,0 +1,93 @@
+"""Copyright (C) 2004 Paul Brossier <piem@altern.org>
+print aubio.__LICENSE__ for the terms of use
+"""
+
+__LICENSE__ = """\
+	 Copyright (C) 2004 Paul Brossier <piem@altern.org>
+
+	 This program is free software; you can redistribute it and/or modify
+	 it under the terms of the GNU General Public License as published by
+	 the Free Software Foundation; either version 2 of the License, or
+	 (at your option) any later version.
+
+	 This program is distributed in the hope that it will be useful,
+	 but WITHOUT ANY WARRANTY; without even the implied warranty of
+	 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	 GNU General Public License for more details.
+
+	 You should have received a copy of the GNU General Public License
+	 along with this program; if not, write to the Free Software
+	 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+"""
+
+def plotnote(la,title=None) :
+	if la[0,:].size() == 3:
+	        d = plotnote_withends(la, plot_title=title)
+	else: 
+	    # scale data if in freq (for REF.txt files)
+	    if max(la[:,1] > 128 ):
+	        print "scaling frequency data to midi range"
+	        la[:,1] /= 6.875
+	        la[:,1] = log(la[:,1])/0.6931
+	        la[:,1] *= 12
+	        la[:,1] -= 3
+	    d = plotnote_withoutends(la, plot_title=title)
+	return d
+
+def plotnote_multi(lalist,title=None,fileout=None) :
+	d=list()
+	for i in range(len(lalist)):
+	    d.append(plotnote(lalist[i], title=title))
+	return d
+       
+
+def plotnote_withends(la,plot_title=None) :
+	import numarray
+	import Gnuplot, Gnuplot.funcutils
+	d=[]
+	x_widths = numarray.array(la[:,1]-la[:,0])/2.
+	d.append(Gnuplot.Data(
+	        la[:,0]+x_widths,               # x centers
+	        la[:,2],                        # y centers
+	        x_widths,                       # x errors
+	        __notesheight*ones(len(la)),    # y errors
+	        title=plot_title,with=('boxxyerrorbars fs 3')))
+	return d
+
+
+def plotnote_withoutends(la,plot_title=None) :
+        """ bug: fails drawing last note """
+	import numarray
+	import Gnuplot, Gnuplot.funcutils
+        d=[]
+        x_widths = numarray.array(la[1:,0]-la[:-1,0])/2;
+        d.append(Gnuplot.Data(
+                la[:-1,0]+x_widths,             # x centers
+                la[:-1,1],                      # y centers
+                x_widths,                       # x errors
+                __notesheight*ones(len(la)-1),  # y errors
+                title=plot_title,with=('boxxyerrorbars fs 3')))
+        return d
+
+def plotnote_do(d,fileout=None):
+    import Gnuplot, Gnuplot.funcutils
+    g = Gnuplot.Gnuplot(debug=1, persist=1)
+    g.gnuplot('set style fill solid border 1; \
+    set size ratio 1/6; \
+    set boxwidth 0.9 relative; \
+    set mxtics 2.5; \
+    set mytics 2.5; \
+    set xtics 5; \
+    set ytics 1; \
+    set grid xtics ytics mxtics mytics')
+
+    g.xlabel('Time (s)')
+    g.ylabel('Midi pitch')
+    # do the plot
+    #g.gnuplot('set multiplot')
+    #for i in d:
+    g.plot(d[0])
+    #g.gnuplot('set nomultiplot') 
+    if fileout != None:
+        g.hardcopy(fileout, enhanced=1, color=0)
+
