# HG changeset patch # User csong # Date 1428879065 -3600 # Node ID f5abd2e8cafe629dcf15702cad1f02adec092469 # Parent 273450d5980ad5191cc0f125bc30e99065661e46 update models diff -r 273450d5980a -r f5abd2e8cafe Syncopation models/LHL.py --- 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: diff -r 273450d5980a -r f5abd2e8cafe Syncopation models/SG.py --- 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 diff -r 273450d5980a -r f5abd2e8cafe Syncopation models/TMC.py --- 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 diff -r 273450d5980a -r f5abd2e8cafe Syncopation models/parameter_setter.py --- 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