source: python.old/aubio/plot/keyboard.py @ 8f68dfb

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

moved out old python interface

  • Property mode set to 100755
File size: 1.4 KB
RevLine 
[ae3f5af]1
2def draw_keyboard(firstnote = 21, lastnote = 108, y0 = 0, y1 = 1):
3  import Gnuplot
4  octaves = 10
5
6  # build template of white notes
7  scalew  = 12/7.
8  xw_temp = [i*scalew for i in range(0,7)]
9  # build template of black notes
10  scaleb  = 6/7.
11  xb_temp = [i*scaleb for i in [1,3,7,9,11]]
12
13  xb,xw = [],[]
14  for octave in range(octaves-1): 
15    for i in xb_temp:
16      curnote = i+12*octave
17      if  curnote > firstnote-1 and curnote < lastnote+1:
18        xb = xb + [curnote] 
19  for octave in range(octaves-1): 
20    for i in xw_temp:
21      curnote = i+12*octave
22      if  curnote > firstnote-1 and curnote < lastnote+1:
23        xw = xw + [curnote]
24
25  xwdelta = [1/2. * scalew for i in range(len(xw))]
26  yw      = [y0+(y1-y0)*1/2. for i in range(len(xw))]
27  ywdelta = [(y1-y0)*1/2. for i in range(len(xw))]
28
29  xbdelta = [2/3. * scaleb for i in range(len(xb))]
30  yb      = [y0+(y1-y0)*2/3. for i in range(len(xb))]
31  ybdelta = [(y1-y0)*1/3. for i in range(len(xb))]
32
[42515ac]33  whites  = Gnuplot.Data(xw,yw,xwdelta,ywdelta,with_ = 'boxxyerrorbars')
34  blacks  = Gnuplot.Data(xb,yb,xbdelta,ybdelta,with_ = 'boxxyerrorbars fill solid')
[ae3f5af]35
36  return blacks,whites
37
38if __name__ == '__main__':
39  from aubio.gnuplot import gnuplot_create
40  blacks,whites = draw_keyboard(firstnote = 21, lastnote = 108)
41  g = gnuplot_create('','')
42  #g('set style fill solid .5')
43  #g('set xrange [60-.5:72+.5]')
44  #g('set yrange [-0.1:1.1]')
45
46  g.plot(whites,blacks)
Note: See TracBrowser for help on using the repository browser.