History

python/demos/demo_keyboard.py: moved to numpy

Paul Brossier committed 13 years ago

Commit 18a05521 parent 129b2692 files · +85 −46Browse files

Showing the changes to python.old/aubio (1 of 2 files). Show all

Unified · Split

python.old/aubio/plot/keyboard.py+0−46
@@ -1,46 +0,0 @@
1−
2−def 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−
38−if __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)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t