source: python/aubio/plot/keyboard.py @ 0ab19df

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

last 0.3.0 changes
last 0.3.0 changes

  • Property mode set to 100755
File size: 1.4 KB
Line 
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
33  whites  = Gnuplot.Data(xw,yw,xwdelta,ywdelta,with = 'boxxyerrorbars')
34  blacks  = Gnuplot.Data(xb,yb,xbdelta,ybdelta,with = 'boxxyerrorbars fill solid')
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.