From c97ae7e887a3d3b3ebe2a899a5415c9b9904878e Mon Sep 17 00:00:00 2001 From: Jackson Moore Date: Thu, 14 Mar 2019 13:54:43 +0100 Subject: clean up --- .gitignore | 0 cadence.py | 0 function.py | 0 grammar.py | 0 harmony.py | 0 lexicon.py | 0 main.py | 6 +-- passage.py | 0 path.py | 0 render.py | 17 +++++--- rhythm.py | 0 spec.py | 139 ++++++++++++++++++++++++------------------------------------ utils.py | 0 13 files changed, 68 insertions(+), 94 deletions(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 cadence.py mode change 100644 => 100755 function.py mode change 100644 => 100755 grammar.py mode change 100644 => 100755 harmony.py mode change 100644 => 100755 lexicon.py mode change 100644 => 100755 main.py mode change 100644 => 100755 passage.py mode change 100644 => 100755 path.py mode change 100644 => 100755 render.py mode change 100644 => 100755 rhythm.py mode change 100644 => 100755 spec.py mode change 100644 => 100755 utils.py diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/cadence.py b/cadence.py old mode 100644 new mode 100755 diff --git a/function.py b/function.py old mode 100644 new mode 100755 diff --git a/grammar.py b/grammar.py old mode 100644 new mode 100755 diff --git a/harmony.py b/harmony.py old mode 100644 new mode 100755 diff --git a/lexicon.py b/lexicon.py old mode 100644 new mode 100755 diff --git a/main.py b/main.py old mode 100644 new mode 100755 index 92ee0e8..e143676 --- a/main.py +++ b/main.py @@ -27,12 +27,12 @@ render.py list of n passages rendered to music21 score object # g.morphology.print() lexicon = Lexicon() -lexicon.populate(g, 5) +lexicon.populate(g, 4) lexicon.print() print("\n-----------\n-----------\n") -passage = Passage(height=5) +passage = Passage(height=8) passage.spellout(lexicon) @@ -42,7 +42,7 @@ print(passage.tree) print() renderer = Renderer() -renderer.render(passage, 'viola') +renderer.render(passage, 'flute') # todo # working with multiple voices diff --git a/passage.py b/passage.py old mode 100644 new mode 100755 diff --git a/path.py b/path.py old mode 100644 new mode 100755 diff --git a/render.py b/render.py old mode 100644 new mode 100755 index 145f787..8baa3f0 --- a/render.py +++ b/render.py @@ -31,6 +31,7 @@ class Renderer(object): splitLexemes = [] shift = 72 for i, lexeme in enumerate(passage.spelling): + # print("\n--",i,lexeme.realization['height']) pickup = { '_label': lexeme.label, '_offsets': [offset for offset in lexeme.realization['feet'][0] if offset < 0], @@ -97,7 +98,7 @@ class Renderer(object): # calculate duration of last note accurately noteEndpoints.append(increment['_nextOffset']) durations = [ fl(x-y) for y, x in zip(noteEndpoints[:-1], noteEndpoints[1:]) ] - measure.insert(internalOffset, labels[0]) + # measure.insert(internalOffset, labels[0]) # subtract from end of increment to find offsets internalOffset += abs(increment['_duration']) # special case for pickup bar - use duration including hidden leading rest @@ -111,6 +112,7 @@ class Renderer(object): noteOffset = internalOffset+increment['_offsets'][k] # measure.append(n) measure.insert(noteOffset, n) + # if duration is positive, is station if increment['_duration'] > 0: noteEndpoints = copy(increment['_offsets']) @@ -118,7 +120,7 @@ class Renderer(object): noteEndpoints.append(abs(increment['_duration'])) durations = [ fl(x-y) for y, x in zip(noteEndpoints[:-1], noteEndpoints[1:]) ] # add to beginning of increment to find offsets - measure.insert(internalOffset, labels[1]) + # measure.insert(internalOffset, labels[1]) for k, duration in enumerate(durations): n = m21.note.Note() n.quarterLength = duration @@ -165,12 +167,13 @@ class Renderer(object): word_site = "http://svnweb.freebsd.org/csrg/share/dict/words?view=co&content-type=text/plain" response = requests.get(word_site) words = response.content.splitlines() - title = choice(words).decode("utf-8").capitalize() + # title = choice(words).decode("utf-8").capitalize() + title = '' return (timestamp, title, date) def writeLog(self,passage,heading): """ write log file """ - f = open("/Users/home/Documents/top/shelf/composition/framework/_log/"+heading[0]+"-"+heading[1]+".txt", 'w') + f = open("/Users/home/Documents/top/projects/precarity/framework/_log/"+heading[0]+"-"+heading[1]+".txt", 'w') f.write(str(passage.lexicon)) f.write("\n\n") f.write(str(passage.tree)) @@ -282,7 +285,7 @@ instruments = { instrumentRanges = { - 'violin': 32, + 'violin': 30, 'viola': 30, 'cello': 32, 'double bass': 39, @@ -294,7 +297,7 @@ instrumentRanges = { 'trombone': 32, 'trumpet': 27, 'piccolo': 26, - 'flute': 32, + 'flute': 20, 'alto_flute': 36, 'oboe': 30, 'cor_anglais': 29, @@ -309,7 +312,7 @@ instrumentRanges = { 'baritone': 32, 'tenor': 32, 'alto': 32, - 'soprano': 32, + 'soprano': 22, 'glockenspiel': 29, 'xylophone': 43, 'vibraphone': 36, diff --git a/rhythm.py b/rhythm.py old mode 100644 new mode 100755 diff --git a/spec.py b/spec.py old mode 100644 new mode 100755 index 05d95aa..d2be4c3 --- a/spec.py +++ b/spec.py @@ -1,59 +1,41 @@ from grammar import * ligatureRules = [ + # [{ + # 'span': [2.0], + # 'gait': ['double'], + # 'foot': [[0, 1/2], [0, 1/2], [0, 1/2], [0, 1/2], [0, 1/2], [0, 1/2], [0, 1/2], [0, 1/2]], + # 'sync': [[0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0]], + # }], + # [{ + # 'span': [3.0, 5.0, 6.0], + # 'gait': ['trip_sl', 'trip_ls', 'double'], + # 'foot': [[0, 1/2], [0]], + # 'sync': [[0]], + # }], [{ - 'span': [0.5, 1.0, 1.5], - 'gait': ['double'], - 'foot': [[0, 1/2], [0, 1/2], [0, 1/2], [0, 1/2], [0, 1/2], [0, 1/2], [0, 1/2], [0, 1/2]], - 'sync': [[0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0]], - }], - [{ - 'span': [0.5, 1.5], - 'gait': ['double'], - 'foot': [[0, 1/2], [0, 1/2], [0, 1/2], [0, 1/2]], - 'sync': [[0], [0], [0], [0], [0], [0], [0], [0]], - }], - [{ - 'span': [0.5, 1.5], - 'gait': ['double'], - 'foot': [[0, 1/2], [0, 1/2], [0, 1/2], [0, 1/2], [0, 1/2], [0, 1/2], [0, 1/2], [0, 1/2], [0, 1/2], [0, 1/2]], - 'sync': [[0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0]], - }], - [{ - 'span': [0.5, 1.5], - 'gait': ['double'], - 'foot': [[0, 1/2], [0, 1/2], [0, 1/2], [0, 1/2], [0, 1/2], [0, 1/2], [0], [0]], - 'sync': [[0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [1/2], [1/2]], - }], - [{ - 'span': [0.5, 1.5], - 'gait': ['double'], - 'foot': [[-1/2, 0], [-1/2, 0], [-1/2, 0], [-1/2, 0], [-1/2, 0], [-1/2, 0], [-1/2, 0], [-1/2, 0]], - 'sync': [[0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0]], + 'span': [3.0, 5.0], + 'gait': ['double','trip_sl'], + 'foot': [[0]], + 'sync': [[0]], }], [{ 'span': [0.5, 1.0], - 'gait': ['double'], - 'foot': [[-1/2, 0], [-1/2, 0], [-1/2, 0], [-1/2, 0]], - 'sync': [[0], [0], [0], [0], [0], [0], [0], [0]], + 'gait': ['double','trip_sl'], + 'foot': [[-1/2, 0, 1/2], [0, 1/2], [0, 1/2], [0, 1/2]], + 'sync': [[0]], }], [{ 'span': [0.5, 1.0], - 'gait': ['double'], - 'foot': [[-1/2, 0], [-1/2, 0], [-1/2, 0], [0, 1/2], [0, 1/2]], - 'sync': [[0], [0], [0], [0], [0], [0], [0], [0], [0], [0]], + 'gait': ['double','trip_sl'], + 'foot': [[-1/2, 0, 1/2], [0, 1/2]], + 'sync': [[0]], }], [{ 'span': [0.5, 1.0], - 'gait': ['double'], - 'foot': [[-1/2, 0], [-1/2, 0], [-1/2, 0], [-1/2, 0]], - 'sync': [[0], [0], [0], [0], [0], [0], [0], [0]], - }], - [{ - 'span': [2.0, 3.0], - 'gait': ['double'], - 'foot': [[0],[0]], - 'sync': [[0,1/2],[0,1/2]], + 'gait': ['double','trip_sl'], + 'foot': [[-1/2, 0, 1/2], [0, 1/2], [0, 1/2]], + 'sync': [[0]], }], ] @@ -85,59 +67,51 @@ functionRules = [ # pathRules = [ + # { + # 'range': [1,2,3], + # 'figure': ['saddleDown','spikeDown'], + # 'direction': [5], + # }, { - 'range': [1,2,3], - 'figure': ['saddleUp','spikeUp'], - 'direction': [-7], + 'range': [5,6,7], + 'figure': ['decDown','decUp'], + 'direction': [0,1,2], }, { 'range': [1,2,3], - 'figure': ['saddleDown','spikeDown'], - 'direction': [5], + 'figure': ['sawtooth1Up','sawtooth2Up','sawtooth3Up','sawtooth1Down','sawtooth2Down','sawtooth3Down'], + 'direction': [0,1], }, { - 'range': [2,3], - 'figure': ['rampUp','accUp','decUp'], - 'direction': [-7], - }, - { - 'range': [2,3], - 'figure': ['rampDown','accDown','decDown'], - 'direction': [5], - }, - { - 'range': [1,3,4,7,11,18], - 'figure': ['sawtooth2Up','sawtooth2Down','sawtooth3Up','sawtooth3Down','zigZagUp','zigZagDown'], - 'direction': [-1], + 'range': [1,2,4,5], + 'figure': ['zigZagUp','zigZagDown'], + 'direction': [0,1], }, ] + anticipationRules = [ + # ['transposition', 'ligature'], + ['address','address'], ['transposition', 'ligature'], - ['address', 'direction'], - ['range', 'figure'], - ['figure', 'address'], - ['direction', 'transposition'], - ['ligature'], + ['transposition', 'span'], + ['gait','transposition'], + ['figure'], ] - - - prolongationRules = [ - ['transposition', 'ligature'], - ['address', 'transposition'], - ['range', 'figure'], - ['figure', 'range'], - ['direction', 'direction'], - ['ligature', 'address'], - ['direction', 'ligature'], - ['transposition', 'figure'], - ['figure', 'direction'], - ['ligature', 'transposition'], - ['address', 'address'], - ['ligature'], + ['transposition', 'transposition'], + ['gait', 'gait'], + ['gait', 'ligature'], + ['transposition', 'span'], + ['sync'], + # ['ligature', 'address'], + # ['direction', 'ligature'], + # ['transposition', 'figure'], + # ['figure', 'figure'], + # ['ligature', 'transposition'], + # ['figure'], ] # as patient - (yield, check, ask) # ([default] adopt given features, refuse given features, request features @@ -147,8 +121,6 @@ prolongationRules = [ ''' # need something like projectionRules = { - - # produces less uniformity 'check': [], # produces local uniformity (inflection) @@ -157,7 +129,6 @@ projectionRules = { # produces global uniformity 'project': [], 'inject': [], - } ''' diff --git a/utils.py b/utils.py old mode 100644 new mode 100755 -- cgit v1.2.3