diff options
| author | Houyhnhnm <hykusb@bitmai.la> | 2018-06-02 22:10:48 +0200 |
|---|---|---|
| committer | Houyhnhnm <hykusb@bitmai.la> | 2018-06-02 22:10:48 +0200 |
| commit | dbd040425b7c066b0803e0f329dd887b11156635 (patch) | |
| tree | 9af2c8ec5522fcec8a6956b04c8cd101ea44e6c1 | |
| parent | 8f2251a175d8d52edd12d62168c7c0e795be6146 (diff) | |
prettier print methods
| -rw-r--r-- | cadence.py | 38 | ||||
| -rw-r--r-- | main.py | 6 | ||||
| -rw-r--r-- | phonology.py | 14 |
3 files changed, 35 insertions, 23 deletions
@@ -2,32 +2,29 @@ from pprint import pprint ''' Cadence - from Latin cadō ("I fall, I cease"), Proto-Indo-European *ḱad- ("to fall"). - Doublet of cadenza and chance. - -The act or state of declining or sinking. - A fall in inflection of a speaker’s voice, such as at the end of a sentence. - A progression of at least two chords which conclude a segment of music; musical punctuation; a clausula. - A move which ends a phrase in dance. - -Rhythmic flow. ("The cadence of life at the front is about to change.") - The measure or beat of movement. - The rhythm and sequence of a series of actions. - The number of steps per unit time. - -The general inflection or modulation of the voice, or of any sound. - -The cadence is that which closes itself by opening - the cork which makes the bottle. + --from Latin cadō ("I fall, I cease"). Doublet of cadenza and chance. + + That which closes - the cork which makes the bottle + Contrast prolongation: that which keeps open + The act or state of declining or sinking. + A fall in inflection of a speaker’s voice, such as at the end of a sentence. + A progression of at least two chords which conclude a segment of music; musical punctuation; a clausula. + A move which ends a phrase in dance. + Rhythmic flow. ("The cadence of life is about to change.") + The measure or beat of movement. + The rhythm and sequence of a series of actions. + The number of steps per unit time. + The general inflection or modulation of the voice, or of any sound. ''' - class Cadence(object): """a musical morpheme bundling rhythmic, gestural and harmonic features""" - def __init__(self, footprint=None, function=None, path=None): + def __init__(self, footprint=None, function=None, path=None, label=''): self.footprint = footprint self.function = function self.path = path + self.label = label # string represention of cadence - note list ? def __str__(self): @@ -47,6 +44,9 @@ class Cadence(object): } return features + def assignLabel(label): + self.label = label + def update(featureDict): if 'footprint' in featureDict: self.footprint = featureDict['footprint'] @@ -61,7 +61,9 @@ class Cadence(object): 'function': self.function, 'path': self.path, } + print("\nCadence", str(self.label)) pprint(features) + print() ''' # example @@ -24,19 +24,19 @@ phonology.addFootprintRule([{ 'foot': [[-1/2, 0, 1/2]], 'step': [[0, 1/2], [0, 1/2], [0, 1/2]], }]) - phonology.addFunctionRule({ 'address': ['A1','B1'], 'transposition': [-1,0,1], }) - phonology.addPathRule({ 'range': [2,3,4], 'figure': ['rampUp', 'rampDown'], 'tilt': ['float', 'dive'], }) -lex = phonology.makeCadence() +phonology.print() + +lex = phonology.makeCadence(label=1) lex.print() syntax = Diagram() diff --git a/phonology.py b/phonology.py index 2e8d978..1853523 100644 --- a/phonology.py +++ b/phonology.py @@ -10,6 +10,16 @@ class Phonology(object): self.functions = functions self.paths = paths + def print(self): + features = { + 'footprints': self.footprints, + 'functions': self.functions, + 'paths': self.paths, + } + print("\nPhonology") + pprint(features) + print() + def addFootprintRule(self, footprintRule, weight=1): self.footprints.append((footprintRule, weight)) @@ -19,9 +29,9 @@ class Phonology(object): def addPathRule(self, pathRule, weight=1): self.paths.append((pathRule, weight)) - def makeCadence(self): # (duration=None, harmonicFilter=None) + def makeCadence(self, label=''): # (duration=None, harmonicFilter=None) """ assemble bundle of features from phonology rules """ - cadence = Cadence() + cadence = Cadence(label=label) cadence.footprint = self.makeFootprint() cadence.function = self.makeFunction() cadence.path = self.makePath() |