From 03f27b0a9a50cd5bacea17998c0a9c597b33c091 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Thu, 7 Mar 2013 12:23:22 -0500 Subject: [PATCH] python/demos/demo_keyboard.py: indent --- python/demos/demo_keyboard.py | 82 +++++++++++++++++------------------ 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/python/demos/demo_keyboard.py b/python/demos/demo_keyboard.py index 9eb398f1..aebc2951 100755 --- a/python/demos/demo_keyboard.py +++ b/python/demos/demo_keyboard.py @@ -1,39 +1,39 @@ #! /usr/bin/env python def get_keyboard_edges(firstnote = 21, lastnote = 108, y0 = 0, y1 = 1): - octaves = 10 + 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]] + # 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] + 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))] + 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))] + 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,white_height = xw,yw - blacks,black_height = xb,yb + whites,white_height = xw,yw + blacks,black_height = xb,yb - return blacks,whites, 2/3. *scaleb, 1/2. * scalew + return blacks,whites, 2/3. *scaleb, 1/2. * scalew def create_keyboard_patches(firstnote, lastnote, ax = None): import numpy as np @@ -69,17 +69,17 @@ def create_keyboard_patches(firstnote, lastnote, ax = None): if __name__ == '__main__': - if 0: - from aubio.gnuplot import gnuplot_create - import Gnuplot - whites = Gnuplot.Data(blacks, yw,xwdelta,ywdelta,with_ = 'boxxyerrorbars') - blacks = Gnuplot.Data(whites, yb,xbdelta,ybdelta,with_ = 'boxxyerrorbars fill solid') - 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) - else: - import matplotlib.pyplot as plt - create_keyboard_patches(firstnote = 61, lastnote = 108) - plt.show() + if 0: + from aubio.gnuplot import gnuplot_create + import Gnuplot + whites = Gnuplot.Data(blacks, yw,xwdelta,ywdelta,with_ = 'boxxyerrorbars') + blacks = Gnuplot.Data(whites, yb,xbdelta,ybdelta,with_ = 'boxxyerrorbars fill solid') + 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) + else: + import matplotlib.pyplot as plt + create_keyboard_patches(firstnote = 61, lastnote = 108) + plt.show() -- 2.26.2