changeset 75:0c744fb4c202

updated syncopation.py to include a barRange when calculating syncopation
author christopherh <christopher.harte@eecs.qmul.ac.uk>
date Tue, 12 May 2015 23:10:58 +0100
parents 3954fc89e155
children 90b68f259541
files synpy/syncopation.py
diffstat 1 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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: