diff options
| author | Jackson Moore <jacksonmoore@tuta.io> | 2018-06-07 18:26:09 +0200 |
|---|---|---|
| committer | Jackson Moore <jacksonmoore@tuta.io> | 2018-06-07 18:26:09 +0200 |
| commit | a0efc27ca686603e79d302e4414cb9b59b56baf6 (patch) | |
| tree | 2229e3b216e3ba292fd9a636b46333da6c537f8f /passage.py | |
| parent | 789e7c10bc8765d498ba9f1e4c3eac35b64b41e7 (diff) | |
render pitch height to score
Diffstat (limited to 'passage.py')
| -rw-r--r-- | passage.py | 33 |
1 files changed, 23 insertions, 10 deletions
@@ -1,9 +1,11 @@ -import rhythm from binarytree import * from utils import * from math import ceil, floor from copy import copy, deepcopy from pprint import pprint +import rhythm +import path +import harmony class Passage(object): """represents a syntactic structure (wrapper for binary tree)""" @@ -80,19 +82,33 @@ class Passage(object): spellout = [] # now read out nodes into list, with prolonged features replacing lexical features for node in self.tree.inorder: - next_lexeme = deepcopy(node.lexeme) + next_lexeme = node.lexeme # deepcopy(node.lexeme) for feat in node.unify.keys(): if feat == 'ligature': next_lexeme.cadence.ligature = node.unify[feat] if feat in ['address', 'transposition']: next_lexeme.cadence.function[feat] = node.unify[feat] - if feat in ['range','figure','tilt']: + if feat in ['range','figure','direction']: next_lexeme.cadence.path[feat] = node.unify[feat] spellout.append(next_lexeme) self.spelling = spellout self.setMeter() + self.setFigure() + # self.setHarmony() return spellout + def setFigure(self): + print("\nsetFigure\n---------") + for i, node in enumerate(self.tree.levelorder): + if i == 0: + node.lexeme.realization['height'] = 0 + if node.left: + leadingDirection = node.left.lexeme.cadence.path['direction'] + node.left.lexeme.realization['height'] = node.lexeme.realization['height'] - leadingDirection + if node.right: + trailingDirection = node.right.lexeme.cadence.path['direction'] + node.right.lexeme.realization['height'] = node.lexeme.realization['height'] + trailingDirection + node.lexeme.realization['outline'] = path.makeOutline(node.lexeme.cadence.path, node.lexeme.realization) def setMeter(self): durations = self.getDurations(self.spelling) @@ -165,10 +181,6 @@ class Passage(object): return bars, removedIndices, prolongedIndices - def consolidate(self, bars): - # [[[3.0, [2.5, 2.5, [5.0, 4.5]]], [2.5, [5.0, 7.0], [7.0, 4.5]]], [3.0, [5.0, [4.5, 5.0, 7.0, 5.0]], [5.0, [[4.5, 5.0], [7.0, 7.0, 4.5]], 2.0]]] - for component in bars: - pass def partition(self, bars, syntaxTree): @@ -210,10 +222,11 @@ class Passage(object): return newBars - def getDurations(self, realization): + + def getDurations(self, spelling): durations = [] anacruses = [] - for lexeme in realization: + for lexeme in spelling: # special extra bit before barline anacrusis = 0.0 boundaryEvents = [] @@ -286,4 +299,4 @@ class Passage(object): >>> root.postorder [Node(4), Node(5), Node(2), Node(3), Node(1)] -''' +'''
\ No newline at end of file |