Changeset 03f27b0


Ignore:
Timestamp:
Mar 7, 2013, 6:23:22 PM (12 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
5caf474
Parents:
18a0552
Message:

python/demos/demo_keyboard.py: indent

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/demos/demo_keyboard.py

    r18a0552 r03f27b0  
    22
    33def get_keyboard_edges(firstnote = 21, lastnote = 108, y0 = 0, y1 = 1):
    4   octaves = 10
     4    octaves = 10
    55
    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]]
     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]]
    1212
    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]
     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]
    2424
    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))]
     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))]
    2828
    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))]
     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))]
    3232
    33   whites,white_height = xw,yw
    34   blacks,black_height = xb,yb
     33    whites,white_height = xw,yw
     34    blacks,black_height = xb,yb
    3535
    36   return blacks,whites, 2/3. *scaleb, 1/2. * scalew
     36    return blacks,whites, 2/3. *scaleb, 1/2. * scalew
    3737
    3838def create_keyboard_patches(firstnote, lastnote, ax = None):
     
    7070if __name__ == '__main__':
    7171
    72   if 0:
    73     from aubio.gnuplot import gnuplot_create
    74     import Gnuplot
    75     whites  = Gnuplot.Data(blacks, yw,xwdelta,ywdelta,with_ = 'boxxyerrorbars')
    76     blacks  = Gnuplot.Data(whites, yb,xbdelta,ybdelta,with_ = 'boxxyerrorbars fill solid')
    77     g = gnuplot_create('','')
    78     #g('set style fill solid .5')
    79     #g('set xrange [60-.5:72+.5]')
    80     #g('set yrange [-0.1:1.1]')
    81     g.plot(whites,blacks)
    82   else:
    83     import matplotlib.pyplot as plt
    84     create_keyboard_patches(firstnote = 61, lastnote = 108)
    85     plt.show()
     72    if 0:
     73        from aubio.gnuplot import gnuplot_create
     74        import Gnuplot
     75        whites  = Gnuplot.Data(blacks, yw,xwdelta,ywdelta,with_ = 'boxxyerrorbars')
     76        blacks  = Gnuplot.Data(whites, yb,xbdelta,ybdelta,with_ = 'boxxyerrorbars fill solid')
     77        g = gnuplot_create('','')
     78        #g('set style fill solid .5')
     79        #g('set xrange [60-.5:72+.5]')
     80        #g('set yrange [-0.1:1.1]')
     81        g.plot(whites,blacks)
     82    else:
     83        import matplotlib.pyplot as plt
     84        create_keyboard_patches(firstnote = 61, lastnote = 108)
     85        plt.show()
Note: See TracChangeset for help on using the changeset viewer.