changeset 32:273450d5980a

tested parameter setting.
author csong <csong@eecs.qmul.ac.uk>
date Sun, 12 Apr 2015 23:23:32 +0100
parents d9ac6e0d1daf
children f5abd2e8cafe
files Syncopation models/KTH.py Syncopation models/SG.py Syncopation models/basic_functions.py Syncopation models/parameter_setter.py
diffstat 4 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/Syncopation models/KTH.py	Sun Apr 12 22:43:55 2015 +0100
+++ b/Syncopation models/KTH.py	Sun Apr 12 23:23:32 2015 +0100
@@ -4,7 +4,7 @@
 
 '''
 
-from basic_functions import get_note_indices, repeat, note_sequence_to_min_timespan, velocity_sequence_to_min_timespan
+from basic_functions import get_note_indices, repeat, velocity_sequence_to_min_timespan
 
 # To find the nearest power of 2 equal to or less than the given number
 def round_down_power_2(number):
--- a/Syncopation models/SG.py	Sun Apr 12 22:43:55 2015 +0100
+++ b/Syncopation models/SG.py	Sun Apr 12 23:23:32 2015 +0100
@@ -5,6 +5,7 @@
 '''
 
 from basic_functions import get_H, velocity_sequence_to_min_timespan, get_rhythm_category, upsample_velocity_sequence
+from parameter_setter import are_parameters_valid
 
 def get_syncopation(bar, parameters = None):
 	syncopation = None
@@ -81,5 +82,6 @@
 						potential = 1 - pow(0.5,h)
 						level = h 		# Metrical weight is equal to its metrical level
 						syncopation += min(ave_dif_neighbours(index, level))*potential
-			
+			else:
+				print 'Try giving a bigger Lmax so that the rhythm sequence can be measured by the matching metrical weights sequence (H).'
 	return syncopation
--- a/Syncopation models/basic_functions.py	Sun Apr 12 22:43:55 2015 +0100
+++ b/Syncopation models/basic_functions.py	Sun Apr 12 23:23:32 2015 +0100
@@ -82,8 +82,10 @@
 # upsample a velocity sequence to certain length, e.g. [1,1] to [1,0,0,0,1,0,0,0]
 def upsample_velocity_sequence(velocitySequence, length):
 	upsampledVelocitySequence = None
-	if length%len(velocitySequence) != 0:
-		print 'Error: the velocity sequence can only be upsampled to the interger times of its length.'
+	if length < len(velocitySequence):
+		print 'Error: the requested upsampling length needs to be longer than velocity sequence.'
+	elif length % len(velocitySequence) != 0:
+		print 'Error: velocity sequence can only be upsampled to a interger times of its own length.'
 	else:
 		upsampledVelocitySequence = [0]*length
 		scalingFactor = length/len(velocitySequence)
--- a/Syncopation models/parameter_setter.py	Sun Apr 12 22:43:55 2015 +0100
+++ b/Syncopation models/parameter_setter.py	Sun Apr 12 23:23:32 2015 +0100
@@ -109,7 +109,7 @@
 		return isValid
 
 
-	if is_Lmax_valid() and is_weight_sequence_valid():
+	if is_weight_sequence_valid() and is_Lmax_valid():
 		return True
 	else:
 		return False