# HG changeset patch # User christopherh # Date 1431468658 -3600 # Node ID 0c744fb4c202a29829548573bdc2b32bbfd34bec # Parent 3954fc89e155cd20ac5079f7e7b58e046a28b48e updated syncopation.py to include a barRange when calculating syncopation diff -r 3954fc89e155 -r 0c744fb4c202 synpy/syncopation.py --- a/synpy/syncopation.py Tue May 12 22:12:29 2015 +0100 +++ b/synpy/syncopation.py Tue May 12 23:10:58 2015 +0100 @@ -10,7 +10,7 @@ def sync_perbar_permodel (model, bar, parameters=None): return model.get_syncopation(bar, parameters) -def calculate_syncopation(model, source, parameters=None, outfile=None): +def calculate_syncopation(model, source, parameters=None, outfile=None, barRange=None): total = 0.0 barResults = [] numberOfNotes = 0 @@ -47,7 +47,16 @@ if barlist!=None: - for bar in barlist: + + if barRange==None: + barstart=0 + barend=len(barlist) + else: + barstart = barRange[0] + barend = barRange[1] + + + for bar in barlist[barstart:barend]: print 'processing bar %d' % (barlist.index(bar)+1) barSyncopation = sync_perbar_permodel(model, bar, parameters) @@ -72,7 +81,7 @@ import WNBD if model is WNBD: total = total / numberOfNotes - + if len(barResults)>barsDiscarded: average = total / (len(barResults)-barsDiscarded) else: