示例#1
0
文件: music.py 项目: sabo/steven
def extend_track(track, length):
    """Repeats the bars of a track until it reaches the given length."""
    new_track = Track()
    while len(new_track) < length:
        for i in track:
            new_track.add_bar(i)
            if len(new_track) == length:
                return new_track
    return new_track
示例#2
0
def extend_track(track, length):
    """Repeats the bars of a track until it reaches the given length."""
    new_track = Track()
    while len(new_track) < length:
        for i in track:
            new_track.add_bar(i)
            if len(new_track) == length:
                return new_track
    return new_track
示例#3
0
def rebuild_composition(old, xylo, cutoff):
    lowest = Note.__int__(Note('C', 8))
    highest = Note.__int__(Note('C', 0))
    new = Composition()
    for i in old.selected_tracks:
        t = Track()
        t.instrument = xylo
        for bar in old[i]:
            b = Bar()
            b.key.name = bar.key.name
            b.set_meter(bar.meter)
            # note value per beat == the denominator in time signature
            dem = b.meter[1]
            for lst in bar:
                value = lst[1]
                if (is_garbage(value, dem, cutoff[old.selected_tracks.index(i)])):
                    continue
                # do not include lists without notes
                if (not lst[2]):
                    continue
                nc = NoteContainer()
                for note in lst[2]:
                    if (Note.__int__(note) < lowest): lowest = Note.__int__(note)
                    if (Note.__int__(note) > highest): highest = Note.__int__(note)
                    nc + note
                b.place_notes(nc, value)
            t.add_bar(b)
        new.add_track(t)
    # can't do the transposing until all notes in all tracks have been
    # compared against lowest and highest, which is why it is done here
    n1 = Note()
    n2 = Note()
    low = n1.from_int(lowest)
    high = n2.from_int(highest)
    # print("lowest and highest notes:", low, high)
    if (not xylo.notes_in_range([low, high])):
        new = transposer(new, lowest, highest, xylo)
    return new
示例#4
0
def from_Bar(bar):
    c = Composition()
    t = Track()
    t.add_bar(bar)
    c.add_track(t)
    return _composition2musicxml(c).toprettyxml()
示例#5
0
文件: music.py 项目: sabo/steven
def sum_tracks(tracks):
    new_track = Track()
    for track in tracks:
        for bar in track:
            new_track.add_bar(bar)
    return new_track
示例#6
0
def from_Bar(bar):
    c = Composition()
    t = Track()
    t.add_bar(bar)
    c.add_track(t)
    return _composition2musicxml(c).toprettyxml()
示例#7
0
def sum_tracks(tracks):
    new_track = Track()
    for track in tracks:
        for bar in track:
            new_track.add_bar(bar)
    return new_track