Example #1
0
def spackle(m, grid, mask):
    '''Creates subdivision grid under m;
    subdivides sections in mask.
    '''

    grid = baca.tools.helianthate(grid, 1, 1)
    grid = sequencetools.repeat_to_length(grid, len(m.leaves))

    positions = [range(x[0], x[1] + 1) for x in mask]
    sequencetools.flatten_sequence(positions)
    positions = [
        pair[-1] if pair[0] in positions else 0
        for pair in enumerate(grid)
        ]
    #sekka.etc.transforms.subdivide(m, positions)
    baca.tools.abjad_subdivide(m, positions)
Example #2
0
from subruns import truncate_note_subruns


source = [10, 0, 2, 6, 8, 7, 5, 3, 1, 9, 4, 11]
source = [scoretools.Note(n, (1, 4)) for n in source]
for x in source:
    x.history['tag'] = '0'

assert len(source) == 12

#intercalations = [1, 2, 2, 3, 1, 2, 3, 3, 1, 1, 2, 3]
#intercalations = [1, 2, 5, 6]
intercalations = [1, 5, 2, 6]

indices = range(len(source))
counts = sequencetools.repeat_to_length(intercalations, len(source))
counts = [[count] for count in counts]
specification = zip(indices, counts)

assert specification == [(0, [1]), (1, [5]), (2, [2]), (3, [6]), (4, [1]), (5, [5]), (6, [2]), (7, [6]), (8, [1]), (9, [5]), (10, [2]), (11, [6])]

pitchtools.insert_transposed_pc_subruns(source, specification)

for i, j in sequencetools.pairwise(source):
    if isinstance(j, list):
        assert isinstance(i, scoretools.Note)
        for note in j:
            note.history['tag'] = i.history['tag'] + '1'

source = sequencetools.flatten_sequence(source)
Example #3
0
end     = 231
lengths = sequencetools.difference_series(starts + [end])
l       = len(lengths)
cuts    = zip(starts, lengths)

first  = H([[1], [2, 3, 4], [5, 6]])
second = H([[7], [8], [9, 10, 11]])
#third  = H([[12], [13, 14], [15, 16, 17]])
third  = H([[12], [4, 17], [1, 8, 9]])
third[15 - 1] = 16

#v1, v2 = (tools.read(first,  0, l), tools.read(first,  l, l))
#f1, f2 = (tools.read(second, 0, l), tools.read(second, l, l))
#p1, p2 = (tools.read(third,  0, l), tools.read(third,  l, l))

v1 = sequencetools.repeat_to_length(first, l, start = 0)
v2 = sequencetools.repeat_to_length(first, l, start = l)

f1 = sequencetools.repeat_to_length(second, l, start = 0)
f2 = sequencetools.repeat_to_length(second, l, start = l)

p1 = sequencetools.repeat_to_length(third, l, start = 0)
p2 = sequencetools.repeat_to_length(third, l, start = l)

# use lines with rests
for part in [v1, f1, p1, p2]:
   for i, x in enumerate(part):
      part[i] = 2 * x - 1

# use filled-in lines
for part in [v2, f2]: