# HG changeset patch # User csong # Date 1428877412 -3600 # Node ID 273450d5980ad5191cc0f125bc30e99065661e46 # Parent d9ac6e0d1daff098541eaf5f0ce7b2a94b9efd50 tested parameter setting. diff -r d9ac6e0d1daf -r 273450d5980a Syncopation models/KTH.py --- 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): diff -r d9ac6e0d1daf -r 273450d5980a Syncopation models/SG.py --- 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 diff -r d9ac6e0d1daf -r 273450d5980a Syncopation models/basic_functions.py --- 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) diff -r d9ac6e0d1daf -r 273450d5980a Syncopation models/parameter_setter.py --- 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