Mercurial > hg > syncopation-dataset
diff Syncopation models/LHL.py @ 19:9030967a05f8
Refactored parameter_setter, basic_functions. Halfway fixing parameter argument in LHL model.
author | csong <csong@eecs.qmul.ac.uk> |
---|---|
date | Fri, 03 Apr 2015 22:57:27 +0100 |
parents | 4acddc008048 |
children | b959c2acb927 |
line wrap: on
line diff
--- a/Syncopation models/LHL.py Fri Apr 03 18:38:10 2015 +0100 +++ b/Syncopation models/LHL.py Fri Apr 03 22:57:27 2015 +0100 @@ -30,7 +30,11 @@ for a in range(len(subBinarySequences)): recursive_tree(subBinarySequences[a], subdivisionSequence, weightSequence, subWeightSequences[a], level+1) -def get_syncopation(bar, weightSequence = None, LMax = None): +def are_parameters_valid(parameters): + areValid = False + if 'Lmax' not in parameters : + +def get_syncopation(bar, parameters = None): ''' The get_syncopation function calculates syncopation value . ''' @@ -43,10 +47,17 @@ if get_rhythm_category(binarySequence, subdivisionSequence) == 'poly': print 'Warning: LHL model detects polyrhythms so returning None.' else: - if weightSequence == None: - if LMax == None: - LMax = 5 - weightSequence = range(0,-LMax,-1) + # If the parameters are not given, use the default settings + if parameters == None: + Lmax = 5 + weightSequence = range(0,-Lmax,-1) + else: + if are_parameters_valid(parameters): + Lmax = parameters['Lmax'] + weightSequence = parameters['W'] + else: + pass + #raise InvalidParameterError # If there is rhythm in previous bar, process its tree structure if bar.get_previous_bar() != None: