summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lexicon.py3
-rw-r--r--main.py18
-rw-r--r--passage.py76
-rw-r--r--render.py227
-rw-r--r--rhythm.py43
-rw-r--r--spec.py148
-rw-r--r--utils.py2
7 files changed, 397 insertions, 120 deletions
diff --git a/lexicon.py b/lexicon.py
index 26488f2..a2da32e 100644
--- a/lexicon.py
+++ b/lexicon.py
@@ -1,5 +1,6 @@
from grammar import *
from numpy.random import choice, seed
+from copy import deepcopy
class Lexicon(object):
@@ -30,7 +31,7 @@ class Lexicon(object):
lexeme = choice(self.categories)
else:
lexeme = self.categories[index]
- return lexeme
+ return deepcopy(lexeme)
def nextLabel(self):
nextLabel = 0
diff --git a/main.py b/main.py
index 82de491..e62a21b 100644
--- 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, 13)
+lexicon.populate(g, 5)
lexicon.print()
print("\n-----------\n-----------\n")
-passage = Passage(height=6)
+passage = Passage(height=5)
passage.spellout(lexicon)
passage.print()
@@ -41,18 +41,22 @@ print(passage.tree)
print()
renderer = Renderer()
-renderer.render(passage)
+renderer.render(passage, 'viola')
# todo
# working with multiple voices at once
+# a: make rule groups in spec sheet
+# b: work out feature track spellout
+# wrap solution; stretch solution
+# c: leave space; strecht solution
# label events on score
-# record phonology/agreement, spellout to log, label it and score with unix time
+# record phonology/agreement, spellout to log, label it and score with timestamp
# rests after constituents, corresponding to depth
-# lexemes with opacity to certain features - or: local agreement...
# pruning algorithm for shorter sentences over taller trees - remove random/weighted leaves from larger tree
-# fit to instrument range - octave break optimization (score *constituent* boundaries using 2017 codebase metric?)
-# convince m21 to break durations into tied notes on the beat
# add discovered lexemes, pairwise dependencies to lexicon pre-population, iteratively
# spec bundles which can be selected and unified (merge-mask) until a full lexeme is obtained (allowing all feature correlations)
+# convince m21 to break durations into tied notes on the beat
+# other types of agreement / non-agreement / feature-checking
+# pitch plug-in / new transposition logic: exact transposition/register of lexeme given; transposition of lens depends thereon
diff --git a/passage.py b/passage.py
index 8a409b4..b10a1e9 100644
--- a/passage.py
+++ b/passage.py
@@ -148,7 +148,7 @@ class Passage(object):
# i = targets.index(True)
targets = []
for b, bar in enumerate(bars):
- if bar > 0 and bar < 2.5:
+ if bar > 0 and bar < 2.0:
targets.append(self.tree.inorder[b].size)
else:
targets.append(0)
@@ -162,17 +162,25 @@ class Passage(object):
next += 1
scores = [node.size for node in self.tree.inorder]
- if bars[i] < 2.5:
+ if bars[i] < 2.0:
right = False
if i == 0 or prev < 0:
right = True
elif i == len(bars)-1 or next > len(bars)-1:
right = False
else:
+ if bars[i]+bars[next] <= 4.0 and bars[i]+bars[prev] > 4.0:
+ right = True
+ elif bars[i]+bars[next] > 4.0 and bars[i]+bars[prev] <= 4.0:
+ right = False
if bars[i]+bars[next] <= 5.0 and bars[i]+bars[prev] > 5.0:
right = True
elif bars[i]+bars[next] > 5.0 and bars[i]+bars[prev] <= 5.0:
right = False
+ if bars[i]+bars[next] <= 6.0 and bars[i]+bars[prev] > 6.0:
+ right = True
+ elif bars[i]+bars[next] > 6.0 and bars[i]+bars[prev] <= 6.0:
+ right = False
else:
if (scores[i] > scores[prev]) and (next not in prolongedIndices):
right = True
@@ -253,20 +261,20 @@ class Passage(object):
leadingBoundary = 0
if firstAttack < 0:
- leadingBoundary = floor((firstAttack*2)) / 2
+ leadingBoundary = floor((firstAttack*4)) / 4
# leadingBoundary = floor(firstAttack) # use this version for whole-beat measures (1 of 3)
trailingBoundary = 0
if lastAttack > 0:
- trailingBoundary = ceil((lastAttack*2)) / 2
+ trailingBoundary = ceil((lastAttack*4)) / 4
# trailingBoundary = ceil(lastAttack) # use this version for whole-beat measures (2 of 3)
# give last note some time to sustain
if lastAttack - floor(lastAttack) == 0:
- trailingBoundary += 1
+ trailingBoundary += 0.25
# comment below out in case of whole-beat measures (3 of 3)
- if lastAttack - floor(lastAttack) == 0.5:
- trailingBoundary += 0.5
+ if lastAttack - floor(lastAttack) == 0.25:
+ trailingBoundary += 0.25
# pad out to minimum duration
if trailingBoundary < foot['span']:
@@ -286,27 +294,33 @@ class Passage(object):
self.stations = [sum(self.durations[i]) + self.anacruses[i] for i in range(len(durations))]
return durations
-
-'''
-
->>> print(root)
-
- __1
- / \
- 2 3
- / \
-4 5
-
->>> root.inorder - linear order of lexemes
-[Node(4), Node(2), Node(5), Node(1), Node(3)]
-
->>> root.levelorder
-[Node(1), Node(2), Node(3), Node(4), Node(5)]
-
->>> root.preorder
-[Node(1), Node(2), Node(4), Node(5), Node(3)]
-
->>> root.postorder
-[Node(4), Node(5), Node(2), Node(3), Node(1)]
-
-''' \ No newline at end of file
+ def fitToInstrument(self, instrument):
+ floor, ceiling = (instrument.lowestNote.ps, instrument.highestNote.ps)
+ self.fitConstituent(self.tree, floor, ceiling)
+
+ def fitConstituent(self, constituent, floor, ceiling):
+ pitches = []
+ for node in constituent.inorder:
+ for i, target in enumerate(node.lexeme.realization['outline']):
+ pitches.append(target + node.lexeme.realization['lens'][i])
+ pitchReference = deepcopy(pitches)
+ shift = 0
+ print(pitchReference)
+ while min(pitchReference) > floor+12:
+ pitchReference = [pitch-12 for pitch in pitchReference]
+ print(pitchReference)
+ shift -= 12
+ while min(pitchReference) < floor:
+ pitchReference = [pitch+12 for pitch in pitchReference]
+ print(pitchReference)
+ shift += 12
+ if max(pitchReference) > ceiling and constituent.left and constituent.right: # and constituent.left.min_leaf_depth>1 and constituent.right.min_leaf_depth>1:
+ self.fitConstituent(constituent.left, floor, ceiling)
+ self.fitConstituent(constituent.right, floor, ceiling)
+ else:
+ print(constituent)
+ print(min(pitchReference), floor, max(pitchReference), ceiling)
+ print(constituent.left)
+ print(constituent.right)
+ for node in constituent.inorder:
+ node.lexeme.realization['shift'] = shift
diff --git a/render.py b/render.py
index fa6994c..8ef01e7 100644
--- a/render.py
+++ b/render.py
@@ -1,15 +1,20 @@
import music21 as m21
-from utils import *
+import datetime
+import requests
+from random import choice
from pprint import pprint
from copy import copy, deepcopy
+from utils import *
class Renderer(object):
""" turns feature spellout into score object, with processing """
- def render(self, passage):
+ def render(self, passage, instrument):
part = m21.stream.Part()
- # cl = instrument.Clarinet()
- # p.insert(0, cl)
+ inst = deepcopy(instruments[instrument])
+ part.insert(0, inst)
+ part.clef = inst.clef
+ passage.fitToInstrument(inst)
for barDuration in passage.bars:
m = m21.stream.Measure()
@@ -24,6 +29,7 @@ class Renderer(object):
# split each lexeme in anacrusis and station, put them in a flat list
splitLexemes = []
+ shift = 72
for i, lexeme in enumerate(passage.spelling):
pickup = {
'_label': lexeme.label,
@@ -43,6 +49,12 @@ class Renderer(object):
station['_pitches'] = lexeme.realization['outline'][len(pickup['_offsets']):]
pickup['_lens'] = lexeme.realization['lens'][:len(pickup['_offsets'])]
station['_lens'] = lexeme.realization['lens'][len(pickup['_offsets']):]
+ if 'shift' in lexeme.realization:
+ pickup['_shift'] = lexeme.realization['shift']
+ station['_shift'] = lexeme.realization['shift']
+ shift = lexeme.realization['shift']
+ else:
+ pickup['_shift'] = station['_shift'] = shift
# for ligatures with multiple feet, add remaining feet, with internal offset
if len(lexeme.realization['feet']) > 1:
for index in range(1, len(lexeme.realization['feet'])):
@@ -78,12 +90,14 @@ class Renderer(object):
measureOffsets = []
internalOffset = 0.0
for j, increment in enumerate(measureGroup):
+ labels = self.makeLabels(str(increment['parent'].label))
# if duration is negative, is pickup
if increment['_duration'] < 0:
noteEndpoints = copy(increment['_offsets'])
# 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])
# subtract from end of increment to find offsets
internalOffset += abs(increment['_duration'])
# special case for pickup bar - use duration including hidden leading rest
@@ -93,7 +107,7 @@ class Renderer(object):
n = m21.note.Note()
n.quarterLength = duration
n.pitch = m21.pitch.Pitch()
- n.pitch.ps = 72.0 + increment['_pitches'][k] + increment['_lens'][k]
+ n.pitch.ps = increment['_pitches'][k] + increment['_lens'][k] + increment['_shift']
noteOffset = internalOffset+increment['_offsets'][k]
# measure.append(n)
measure.insert(noteOffset, n)
@@ -104,11 +118,12 @@ 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])
for k, duration in enumerate(durations):
n = m21.note.Note()
n.quarterLength = duration
n.pitch = m21.pitch.Pitch()
- n.pitch.ps = 72.0 + increment['_pitches'][k] + increment['_lens'][k]
+ n.pitch.ps = increment['_pitches'][k] + increment['_lens'][k] + increment['_shift']
noteOffset = internalOffset+increment['_offsets'][k]
# measure.append(n)
measure.insert(noteOffset, n)
@@ -117,22 +132,64 @@ class Renderer(object):
measure.padAsAnacrusis()
measure.makeRests(fillGaps=True, timeRangeFromBarDuration=True)
measure.timeSignature = measure.bestTimeSignature()
- measures.show()
+
+ heading = self.makeHeading()
+ part.insert(0, m21.metadata.Metadata())
+ part.metadata.title = heading[0]
+ part.metadata.composer = heading[1]
+ part.show()
# measures.show('lily')
+ def makeLabels(self, text):
+ pickup_label = m21.expressions.TextExpression( '\'' ) # ( "·"+text )
+ down_label = m21.expressions.TextExpression( text )
+ down_label.style.fontSize = pickup_label.style.fontSize = 7.0
+ down_label.style.absoluteY = pickup_label.style.absoluteY = 62
+ down_label.style.fontStyle = pickup_label.style.fontStyle = 'italic'
+ down_label.style.fontWeight = 'normal'
+ pickup_label.style.fontWeight = 'normal'
+ return (pickup_label, down_label)
+
+ def makeHeading(self):
+ # date in 'composer' slot
+ now = datetime.datetime.now()
+ timestamp = str(now.timestamp()).split('.')[0]
+ date = now.strftime('%B %d, %Y ')+str(int(now.strftime('%I')))+now.strftime(':%M%p').lower()
+
+ # timestamp serial and mnemonic random word in 'title' slot
+ 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()
+ word = choice(words).capitalize()
+ title = word.decode("utf-8")+" · "+str(timestamp)
+ return (title, date)
+
timeSignatures = {
+ 1.25: m21.meter.TimeSignature('5/16'),
1.5: m21.meter.TimeSignature('3/8'),
+ 1.75: m21.meter.TimeSignature('7/16'),
2.0: m21.meter.TimeSignature('2/4'),
+ 2.25: m21.meter.TimeSignature('9/16'),
2.5: m21.meter.TimeSignature('5/8'),
+ 2.75: m21.meter.TimeSignature('11/16'),
3.0: m21.meter.TimeSignature('3/4'),
+ 3.25: m21.meter.TimeSignature('13/16'),
3.5: m21.meter.TimeSignature('7/8'),
+ 3.75: m21.meter.TimeSignature('15/16'),
4.0: m21.meter.TimeSignature('4/4'),
+ 4.25: m21.meter.TimeSignature('17/16'),
4.5: m21.meter.TimeSignature('9/8'),
+ 4.75: m21.meter.TimeSignature('19/16'),
5.0: m21.meter.TimeSignature('5/4'),
+ 5.25: m21.meter.TimeSignature('21/16'),
5.5: m21.meter.TimeSignature('11/8'),
+ 5.75: m21.meter.TimeSignature('23/16'),
6.0: m21.meter.TimeSignature('6/4'),
+ 6.25: m21.meter.TimeSignature('25/16'),
6.5: m21.meter.TimeSignature('13/8'),
+ 6.75: m21.meter.TimeSignature('27/16'),
7.0: m21.meter.TimeSignature('7/4'),
+ 7.25: m21.meter.TimeSignature('29/16'),
7.5: m21.meter.TimeSignature('15/8'),
8.0: m21.meter.TimeSignature('8/4'),
8.5: m21.meter.TimeSignature('17/8'),
@@ -165,3 +222,159 @@ timeSignatures[5.0].beamSequence[1] = timeSignatures[5.0].beamSequence[1].subdiv
# timeSignatures[5.0].beamSequence.partition(['2/4', '3/4'])
# timeSignatures[5.0].beamSequence[0] = timeSignatures[5.0].beamSequence[1].subdivide(['1/4', '1/4'])
# timeSignatures[5.0].beamSequence[1] = timeSignatures[5.0].beamSequence[0].subdivide(['1/4', '1/4', '1/4'])
+
+
+
+instruments = {
+ 'violin': m21.instrument.Violin(),
+ 'viola': m21.instrument.Viola(),
+ 'cello': m21.instrument.Violoncello(),
+ 'double bass': m21.instrument.Contrabass(),
+ 'bass guitar': m21.instrument.ElectricBass(),
+ 'acoustic guitar': m21.instrument.ElectricGuitar(),
+ 'tuba': m21.instrument.Tuba(),
+ 'bass_trombone': m21.instrument.BassTrombone(),
+ 'french_horn': m21.instrument.Horn(),
+ 'trombone': m21.instrument.Trombone(),
+ 'trumpet': m21.instrument.Trumpet(),
+ 'piccolo': m21.instrument.Piccolo(),
+ 'flute': m21.instrument.Flute(),
+ 'alto_flute': m21.instrument.Flute(),
+ 'oboe': m21.instrument.Oboe(),
+ 'cor_anglais': m21.instrument.EnglishHorn(),
+ 'bassoon': m21.instrument.Bassoon(),
+ 'contrabassoon': m21.instrument.Bassoon(),
+ 'clarinet': m21.instrument.Clarinet(),
+ 'bass_clarinet': m21.instrument.BassClarinet(),
+ 'soprano_recorder': m21.instrument.Recorder(),
+ 'alto_recorder': m21.instrument.Recorder(),
+ 'tenor_recorder': m21.instrument.Recorder(),
+ 'bass_recorder': m21.instrument.Recorder(),
+ 'baritone': m21.instrument.BaritoneSaxophone(),
+ 'tenor': m21.instrument.TenorSaxophone(),
+ 'alto': m21.instrument.AltoSaxophone(),
+ 'soprano': m21.instrument.SopranoSaxophone(),
+ 'glockenspiel': m21.instrument.Glockenspiel(),
+ # 'xylophone': m21.instrument.Xylophone(),
+ 'vibraphone': m21.instrument.Vibraphone(),
+ 'marimba': m21.instrument.Marimba(),
+ 'bass_marimba': m21.instrument.Marimba(),
+ 'celesta': m21.instrument.Celesta(),
+ 'tubular_bells': m21.instrument.TubularBells(),
+ 'timpani': m21.instrument.Timpani(),
+ 'harpsichord': m21.instrument.Harpsichord(),
+ 'harp': m21.instrument.Harp(),
+}
+
+
+instrumentRanges = {
+ 'violin': 32,
+ 'viola': 30,
+ 'cello': 32,
+ 'double bass': 39,
+ 'bass guitar': 39,
+ 'acoustic guitar': 48,
+ 'tuba': 30,
+ 'bass_trombone': 33,
+ 'french_horn': 43,
+ 'trombone': 32,
+ 'trumpet': 27,
+ 'piccolo': 26,
+ 'flute': 32,
+ 'alto_flute': 36,
+ 'oboe': 30,
+ 'cor_anglais': 29,
+ 'bassoon': 41,
+ 'contrabassoon': 31,
+ 'clarinet': 40,
+ 'bass_clarinet': 39,
+ 'soprano_recorder': 26,
+ 'alto_recorder': 26,
+ 'tenor_recorder': 26,
+ 'bass_recorder': 26,
+ 'baritone': 32,
+ 'tenor': 32,
+ 'alto': 32,
+ 'soprano': 32,
+ 'glockenspiel': 29,
+ 'xylophone': 43,
+ 'vibraphone': 36,
+ 'marimba': 51,
+ 'bass_marimba': 48,
+ 'celesta': 48,
+ 'tubular_bells': 17,
+ 'timpani': 15,
+ 'harpsichord': 60,
+ 'harp': 79,
+}
+
+instrumentClefs = {
+ 'violin': m21.clef.TrebleClef(),
+ 'viola': m21.clef.AltoClef(),
+ 'cello': m21.clef.BassClef(), # or tenor
+ 'double bass': m21.clef.BassClef(),
+ 'bass guitar': m21.clef.BassClef(),
+ 'acoustic guitar': m21.clef.TrebleClef(),
+ 'tuba': m21.clef.BassClef(),
+ 'bass_trombone': m21.clef.BassClef(),
+ 'french_horn': m21.clef.TrebleClef(), # or bass
+ 'trombone': m21.clef.BassClef(),
+ 'trumpet': m21.clef.TrebleClef(),
+ 'piccolo': 'treble^8',
+ 'flute': m21.clef.TrebleClef(),
+ 'alto_flute': m21.clef.TrebleClef(),
+ 'oboe': m21.clef.TrebleClef(),
+ 'cor_anglais': m21.clef.TrebleClef(),
+ 'bassoon': m21.clef.BassClef(), # tenor
+ 'contrabassoon': m21.clef.BassClef(),
+ 'clarinet': m21.clef.TrebleClef(),
+ 'bass_clarinet': m21.clef.TrebleClef(), # or bass
+ 'soprano_recorder': m21.clef.TrebleClef(),
+ 'alto_recorder': m21.clef.TrebleClef(),
+ 'tenor_recorder': m21.clef.TrebleClef(),
+ 'bass_recorder': m21.clef.BassClef(),
+ 'baritone': m21.clef.TrebleClef(),
+ 'tenor': m21.clef.TrebleClef(),
+ 'alto': m21.clef.TrebleClef(),
+ 'soprano': m21.clef.TrebleClef(),
+ # todo: engrave voice to grand staff
+ 'glockenspiel': m21.clef.TrebleClef(),
+ # 'xylophone': m21.clef.TrebleClef(),
+ 'vibraphone': m21.clef.TrebleClef(),
+ 'marimba': m21.clef.TrebleClef(),
+ 'bass_marimba': m21.clef.TrebleClef(),
+ 'celesta': m21.clef.TrebleClef(),
+ 'tubular_bells': m21.clef.TrebleClef(),
+ 'timpani': m21.clef.TrebleClef(),
+ 'harpsichord': m21.clef.TrebleClef(),
+ 'harp': m21.clef.TrebleClef(),
+}
+
+def initializeInstruments():
+ # add highestNote, clef, ...
+ for name in instruments:
+ inst = instruments[name]
+ inst.name = name
+ print(name)
+ inst.highestNote = m21.pitch.Pitch()
+ if name in ['glockenspiel','vibraphone','marimba','bass_marimba','celesta','tubular_bells','timpani']:
+ inst.lowestNote = m21.pitch.Pitch()
+ if name == 'glockenspiel' or name == 'vibraphone':
+ inst.lowestNote.ps = 65
+ if name == 'marimba':
+ inst.lowestNote.ps = 60
+ if name == 'bass_marimba':
+ inst.lowestNote.ps = 48
+ if name == 'bass_marimba':
+ inst.lowestNote.ps = 48
+ if name == 'celesta' or name == 'tubular_bells':
+ inst.lowestNote.ps = 72
+ if name == 'timpani':
+ inst.lowestNote.ps = 50
+ inst.highestNote.ps = inst.lowestNote.ps + instrumentRanges[name]
+ inst.clef = instrumentClefs[name]
+
+initializeInstruments()
+
+def inst(inst_name):
+ return copy(instruments[inst_name]) \ No newline at end of file
diff --git a/rhythm.py b/rhythm.py
index eba19fc..a17d171 100644
--- a/rhythm.py
+++ b/rhythm.py
@@ -111,3 +111,46 @@ def getFinalOffset(offset, refraction, scale):
# [0.0, 0.5, 0.25, 0.125, 0.0625, 0.03125, 0.015625]
+'''
+
+Number line: -0.5 <—0—> +0.5
+level -1 -2 -3 0 3 2 1
+ratio -0.5 -0.25 -0.125 0.0 +0.125 +0.25 +0.5
+1/4 8th 16th 32nd 32nd 16th 8th
+4/4 half quarter eighth eighth quarter half
+
+
+refraction table key
+
+index 0 6 5 4 3 2 1
+duple 0.0 0.015625 0.03125 0.0625 0.125 .25 0.5
+quint_ls 0.0 0.025 0.05 0.1 0.2 0.4 0.6
+quint_sl 0.0 0.0125 0.025 0.05 0.1 0.2 0.4
+quint_half 0.0 0.025 0.05 0.1 0.2 0.3 0.5
+trip_ls 0.0 0.02083 0.0416 0.083 0.166 0.33 0.66
+trip_sl 0.0 0.010416 0.02083 0.0416 0.083 0.166 0.33
+trip_half 0.0 0.02083 0.0416 0.083 0.166 0.33 0.5
+
+
+refraction table - through level 4 (= 16th notes for duple measure level object)
+
+duple quint_ls quint_sl trip_ls trip_sl trip_ll trip_ss quint_ll quint_ss quint2_ls quint2_sl trip2_ls trip2_sl
+0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
+0.0625 0.1 0.05 0.08333 0.04167 0.08333 0.04167 0.1 0.05 0.1 0.05 0.08333 0.04167
+0.125 0.2 0.1 0.16667 0.08333 0.16667 0.08333 0.2 0.1 0.2 0.1 0.16667 0.08333
+0.1875 0.3 0.15 0.25 0.125 0.25 0.125 0.3 0.15 0.25 0.15 0.25 0.125
+0.25 0.4 0.2 0.33333 0.16667 0.33333 0.16667 0.4 0.2 0.3 0.2 0.33333 0.16667
+0.3125 0.45 0.25 0.41667 0.20833 0.41667 0.20833 0.5 0.25 0.35 0.25 0.375 0.25
+0.375 0.5 0.3 0.5 0.25 0.5 0.25 0.6 0.30 0.4 0.3 0.41667 0.33333
+0.4375 0.55 0.35 0.58333 0.29167 0.58333 0.29167 0.7 0.35 0.45 0.4 0.45833 0.41667
+0.5 0.6 0.4 0.66667 0.33333 0.66667 0.33333 0.8 0.4 0.5 0.5 0.5 0.5
+0.5625 0.65 0.45 0.70833 0.41667 0.75 0.375 0.9 0.45 0.6 0.55 0.58333 0.54167
+0.625 0.7 0.5 0.75 0.5 0.83333 0.41667 1.0 0.5 0.7 0.6 0.66667 0.58333
+0.6875 0.75 0.55 0.79167 0.58333 0.91667 0.45833 1.1 0.55 0.75 0.65 0.75 0.625
+0.75 0.8 0.6 0.83333 0.66667 1.0 0.5 1.2 0.60 0.8 0.7 0.83333 0.66667
+0.8125 0.85 0.7 0.875 0.75 1.08333 0.54167 1.3 0.65 0.85 0.75 0.875 0.75
+0.875 0.9 0.8 0.91667 0.83333 1.16667 0.58333 1.4 0.70 0.9 0.8 0.91667 0.83333
+0.9375 0.95 0.9 0.95833 0.91667 1.25 0.625 1.5 0.75 0.95 0.9 0.95833 0.91667
+
+
+'''
diff --git a/spec.py b/spec.py
index 726e0a7..05d95aa 100644
--- a/spec.py
+++ b/spec.py
@@ -2,89 +2,77 @@ from grammar import *
ligatureRules = [
[{
- 'span': [1],
+ 'span': [0.5, 1.0, 1.5],
'gait': ['double'],
- 'foot': [[-1/2, 0, 1/2], [-1/2, 0, 1/2]],
- 'sync': [[0], [0], [-1/2], [0], [0], [-1/2]],
+ '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': [1],
+ 'span': [0.5, 1.5],
'gait': ['double'],
- 'foot': [[-1/2, 0, 1/2], [-1/2, 0], [-1/2, 0]],
- 'sync': [[0], [0], [0], [0], [0, 1/2], [0], [0, 1/2]], #
+ 'foot': [[0, 1/2], [0, 1/2], [0, 1/2], [0, 1/2]],
+ 'sync': [[0], [0], [0], [0], [0], [0], [0], [0]],
}],
[{
- 'span': [2],
- 'gait': ['quint_ss', 'trip_ss'],
- 'foot': [[1/2, 0, 1/2], [-1/2, 0, 1/2]],
- 'sync': [[0], [0], [0], [0], [0], [0]],
- }],
- [{
- 'span': [1],
+ 'span': [0.5, 1.5],
'gait': ['double'],
- 'foot': [[-1/2, 0], [-1/2, 0, 1/2]],
- 'sync': [[0, 1/2], [0], [0], [0], [0]],
- }],
- [{
- 'span': [1],
- 'gait': ['trip_ss'],
- 'foot': [[-1/2, 0, 1/2], [-1/2, 0, 1/2]],
- 'sync': [[0], [0], [0], [0], [0], [0]],
+ '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': [1],
- 'gait': ['trip_ss'],
- 'foot': [[-1/2, 0, 1/2], [-1/2, 0, 1/2]],
- 'sync': [[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': [1],
- 'gait': ['quint_ss','trip_ss', 'double'],
- 'foot': [[0, 1/2], [0], [0, 1/2]],
- 'sync': [[0], [0], [0], [0], [0]],
+ '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': [1],
- 'gait': ['quint_ss','trip_ss', 'double'],
- 'foot': [[-1/2, 0], [0], [1/2, 0]],
- 'sync': [[0], [0], [0], [0], [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,4],
- 'gait': ['trip_ss','quint_ss','double'],
- 'foot': [[-1/2, 0],[-1/2, 0],[-1/2, 0],[0]],
- 'sync': [[0], [0], [0], [0], [0], [0], [-1/2]],
+ '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]],
}],
[{
- 'span': [2,4],
- 'gait': ['trip_ss','quint_ss'],
- 'foot': [[-1/2, -1/4, 0, 1/2]],
- 'sync': [[0], [0], [0], [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': [1,4],
+ 'span': [2.0, 3.0],
'gait': ['double'],
- 'foot': [[-1/2, -1/4, 0, 1/4]],
- 'sync': [[0, 1/2], [0], [0], [0]],
+ 'foot': [[0],[0]],
+ 'sync': [[0,1/2],[0,1/2]],
}],
]
functionRules = [
{
'address': ['A1','B1'],
- 'transposition': [-1,0,1],
+ 'transposition': [0],
},
{
'address': ['C1','D1'],
- 'transposition': [-1,0,1],
+ 'transposition': [0],
},
{
'address': ['D2','C2'],
- 'transposition': [-1,0,1],
+ 'transposition': [0],
},
{
'address': ['E1','E2'],
- 'transposition': [-1,0,1],
+ 'transposition': [0],
},
]
@@ -98,44 +86,58 @@ functionRules = [
pathRules = [
{
- 'range': [9,10,11],
+ 'range': [1,2,3],
'figure': ['saddleUp','spikeUp'],
- 'direction': [1],
+ 'direction': [-7],
},
{
- 'range': [6,7,8],
+ 'range': [1,2,3],
'figure': ['saddleDown','spikeDown'],
- 'direction': [-1],
+ 'direction': [5],
},
- # {
- # 'range': [2,3,4],
- # 'figure': ['rampUp','accUp','decUp'],
- # 'direction': [1],
- # },
- # {
- # 'range': [5,6,7],
- # 'figure': ['rampDown','accDown','decDown'],
- # 'direction': [-1],
- # },
{
- 'range': [2,3,4,10,11,12],
+ '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': [0],
+ 'direction': [-1],
},
]
anticipationRules = [
- ['transposition','askldfjds'],
- ['address'],
- ['direction'],
- [],
+ ['transposition', 'ligature'],
+ ['address', 'direction'],
+ ['range', 'figure'],
+ ['figure', 'address'],
+ ['direction', 'transposition'],
+ ['ligature'],
]
-
+
+
+
+
+
prolongationRules = [
- ['transposition','sdfsdf'],
- ['address'],
- ['direction'],
- [],
+ ['transposition', 'ligature'],
+ ['address', 'transposition'],
+ ['range', 'figure'],
+ ['figure', 'range'],
+ ['direction', 'direction'],
+ ['ligature', 'address'],
+ ['direction', 'ligature'],
+ ['transposition', 'figure'],
+ ['figure', 'direction'],
+ ['ligature', 'transposition'],
+ ['address', 'address'],
+ ['ligature'],
]
# as patient - (yield, check, ask) # ([default] adopt given features, refuse given features, request features
diff --git a/utils.py b/utils.py
index e78efe7..ac98f8a 100644
--- a/utils.py
+++ b/utils.py
@@ -25,7 +25,7 @@ def flatten(pool):
return res
def isOversliced(bars):
- targets = [bar > 0 and bar < 2.5 for bar in bars]
+ targets = [bar > 0 and bar < 2.0 for bar in bars]
return (True in targets)
def firstNonNegative(lst):