Mercurial > hg > syncopation-dataset
diff Syncopation models/LHL.py @ 38:cc38b3047ed9
updated syncopation.y to allow output of sync for a bar list
also fixed some problems in models and other modules
author | christopherh <christopher.harte@eecs.qmul.ac.uk> |
---|---|
date | Mon, 13 Apr 2015 23:06:49 +0100 |
parents | f5abd2e8cafe |
children |
line wrap: on
line diff
--- a/Syncopation models/LHL.py Mon Apr 13 22:36:51 2015 +0100 +++ b/Syncopation models/LHL.py Mon Apr 13 23:06:49 2015 +0100 @@ -8,6 +8,8 @@ terminalNodes = [] # Global variable, storing all the terminal nodes from recursive tree structure in time order + + # Each terminnal node contains two properties: its node type (note or rest) and its metrical weight. class Node: def __init__(self,nodeType,metricalWeight): @@ -57,14 +59,16 @@ print 'Error: the given parameters are not valid.' else: # If there is rhythm in previous bar, process its tree structure - if bar.get_previous_bar() != None: - prebarBinarySequence = bar.get_previous_bar().get_binary_sequence() + prevbar = bar.get_previous_bar() + if prevbar != None and not prevbar.is_empty(): + prebarBinarySequence = prevbar.get_binary_sequence() recursive_tree(ceiling(prebarBinarySequence), subdivisionSequence, weightSequence, weightSequence[0],0) - # Only keep the last note-type node - while terminalNodes[-1].nodeType != 'N': - del terminalNodes[-1] - del terminalNodes[0:-1] + if len(terminalNodes)>0: + # Only keep the last note-type node + while terminalNodes[-1].nodeType != 'N': + del terminalNodes[-1] + del terminalNodes[0:-1] # For the rhythm in the current bar, process its tree structure and store the terminal nodes recursive_tree(ceiling(binarySequence), subdivisionSequence, weightSequence, weightSequence[0],0)