changeset 33:f5abd2e8cafe

update models
author csong
date Sun, 12 Apr 2015 23:51:05 +0100
parents 273450d5980a
children 82496b4e2f96
files Syncopation models/LHL.py Syncopation models/SG.py Syncopation models/TMC.py Syncopation models/parameter_setter.py
diffstat 4 files changed, 7 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/Syncopation models/LHL.py	Sun Apr 12 23:23:32 2015 +0100
+++ b/Syncopation models/LHL.py	Sun Apr 12 23:51:05 2015 +0100
@@ -45,7 +45,7 @@
 	else:
 		# set defaults
 		Lmax = 5
-		weightSequence = range(0,-Lmax,-1)
+		weightSequence = range(0,-Lmax-1,-1)
 		# if parameters are specified by users, check their validities and update parameters if valid		
 		if parameters!= None:
 			if 'Lmax' in parameters:
--- a/Syncopation models/SG.py	Sun Apr 12 23:23:32 2015 +0100
+++ b/Syncopation models/SG.py	Sun Apr 12 23:51:05 2015 +0100
@@ -31,6 +31,7 @@
 		else:
 			# generate the metrical weights of level Lmax, and upsample(stretch) the velocity sequence to match the length of H
 			H = get_H(weightSequence,subdivisionSequence, Lmax)
+			
 			velocitySequence = upsample_velocity_sequence(velocitySequence, len(H))
 
 			# The ave_dif_neighbours function calculates the (weighted) average of the difference between the note at a certain index and its neighbours in a certain metrical level
--- a/Syncopation models/TMC.py	Sun Apr 12 23:23:32 2015 +0100
+++ b/Syncopation models/TMC.py	Sun Apr 12 23:51:05 2015 +0100
@@ -76,11 +76,10 @@
 				#? generate the metrical weights of the lowest level, 
 				#? using the last matching_level number of elements in the weightSequence, to make sure the last element is 1
 				H = get_H (weightSequence[-(L+1):], subdivisionSequence, L)
-				
 				metricity = get_metricity(binarySequence, H)	# converting to binary sequence then calculate metricity
 				maxMetricity = get_max_metricity(binarySequence, H)
 
 				syncopation = maxMetricity - metricity
-
+				
 	return syncopation
 
--- a/Syncopation models/parameter_setter.py	Sun Apr 12 23:23:32 2015 +0100
+++ b/Syncopation models/parameter_setter.py	Sun Apr 12 23:51:05 2015 +0100
@@ -81,15 +81,13 @@
 	def is_Lmax_valid():
 		isValid = False
 		if isinstance(Lmax,int) and Lmax > 0:
-			if Lmax <= len(subdivisionSequence):
-				if Lmax <= len(weightSequence):
+			if Lmax <= len(subdivisionSequence)-1:
+				if Lmax <= len(weightSequence)-1:
 					isValid = True
 				else:
-					print """Error: Lmax exceeds the length of subdivision-sequence. 
-					Either reduce Lmax, or extend subdivision-sequence through updating time-signature (refer to update_time_signature function). """
+					print 'Error: Lmax exceeds the length of weight-sequence. Either reduce Lmax, or provide a new weight-sequence whose length is greater or equal to Lmax.'
 			else:
-				print """Error: Lmax exceeds the length of weight-sequence. Either reduce Lmax, or provide a new weight-sequence
-				whose length is greater or equal to Lmax."""
+				print 'Error: Lmax exceeds the length of subdivision-sequence. Either reduce Lmax, or extend subdivision-sequence through updating time-signature (refer to update_time_signature function).'
 		else:	
 			print 'Error: Lmax needs to be a positive integer.'
 		return isValid