Example #1
0
def make_part(
    section,
    sc,
    title="",
    staff_name=None,
    staff_group_name=None,
):

    # print("================================================================")
    # print("================================================================")
    # print(staff_name, len(sc.staves[staff_name]))
    # for i,n in enumerate(sc.staves[staff_name]):
    #     print(i, type(n), getattr(n, "rehearsal_mark_number"))
    #     # calliope.illustrate(seg)

    if staff_name:
        part = PartScore(sc.staves[staff_name]())
    elif staff_group_name:
        part = PartScore(sc.staff_groups[staff_group_name]())
    if section == "intro":
        part.stylesheets += (_settings.IMAGINARY_PATH +
                             "/scores/stylesheets/intro_score.ily", )
        if staff_group_name is not None:
            part.stylesheets += (_settings.IMAGINARY_PATH +
                                 "/scores/stylesheets/intro_group_parts.ily", )
        for seg in part.segments:
            seg.events[0].tag("\\break")

    my_name = staff_name or staff_group_name

    print("Creating part: " + my_name)

    group_name = "CCO" if my_name[:3] == "cco" else "OOA"
    part_name = group_name + " " + part.staves[0].instrument.name

    if staff_name == "ooa_bari_sax":
        part.staves[0].clef = "treble"

    if staff_name in ("ooa_guitar", "ooa_bass_guitar", "cco_bass"):
        transpose_me = False
    else:
        transpose_me = True

    calliope.illustrate(
        part,
        open_pdf=False,
        filename=my_name + "_" + section + "_part",
        title=title,
        transpose_me=transpose_me,
        part_name=part_name,
    )
Example #2
0
        lib.mark_loaded("home")


if __name__ == '__main__':
    lib = Library()
    to_lib(lib)
    test_block = calliope.SegmentBlock(
        lib("home_a_b").sc(0.5).move_t().annotate(
            label=("cells", "phrases")).slur_cells(),
        lib("home_b_aup4").sc(0.5).move_t().annotate(
            label=("cells", "phrases")).slur_cells(),
    )
    # test_block.segments[1].cells[0].insert(0, calliope.Event(beats=0-24))
    calliope.illustrate(
        test_block.to_score(midi_tempo=112, ),
        as_midi=True,
        # open_midi=True,
    )

# _HOME_A = HomeA()
# _HOME_B = HomeB()

# def home_a(**kwargs):
#     return _HOME_A(**kwargs)

# def home_b(**kwargs):
#     return _HOME_B(**kwargs)

# # some common combos:
# def home_a_b():
#     return _HOME_A().ext( _HOME_B() )
Example #3
0
        off_cell.events[-1].tag(">")
        off_cell.note_events.tag("-")

        my_phrase = ImaginaryPhrase(drive_in_cell, off_cell)

        if self.end_downbeat == True:
            end_cell = ImaginaryCell(rhythm=(1, ))
            end_cell.events[0].tag(">", ".")
            my_phrase.append(end_cell)

        return my_phrase


class StrongBrassDrivingOff(instrument_groups.StrongBrassFabric, DrivingOff):
    fabric_staves = ("ooa_trumpet", "cco_trumpet", "ooa_trombone",
                     "cco_trombone")


class SaxDrivingOff(instrument_groups.SaxFabric, DrivingOff):
    pass


if __name__ == "__main__":
    s = SaxDrivingOff(
        calliope.CellBlock(
            calliope.Cell(rhythm=(1, ) * 24, pitches=(0, 2, 4) * 8),
            calliope.Cell(rhythm=(1, ) * 24, pitches=(5, 7, 9) * 8),
            calliope.Cell(rhythm=(1, ) * 24, pitches=(11, 12) * 12),
        ))
    calliope.illustrate(s)
Example #4
0
class DroneLine2(ImaginaryLine, calliope.Factory):
    branch_type = DronePhrase
    twig_type = DroneCell # TO DO: consider this for all factories
    phrase_count = 4
    phrase_rhythm = ((4,4),(4,4),)
    line_pitches = ( (0,), (0,), )

    def get_branches_kwargs(self, *args, **kwargs):
        return [dict(
            rhythm = self.phrase_rhythm[i % len(self.phrase_rhythm)],
            pitch = self.line_pitches[i % len(self.line_pitches)],
            ) for i in range(self.phrase_count)]
    
    def get_branch(self, *args, **kwargs):
        pitch_len = len(kwargs["pitch"])
        rhythm_len = len(kwargs["rhythm"])
        return self.branch_type(
            self.twig_type(
                rhythm = kwargs["rhythm"],
                pitches = [kwargs["pitch"][i % pitch_len] for i in range(rhythm_len)],
                )
            )

if __name__ == '__main__':
    dl = DroneLine2(
        line_pitches=( (0,-12,(-7,5),12), (12,24), ),
        phrase_rhythm=( (3,3,2), )
        )
    calliope.illustrate(dl)

Example #5
0
                pitch = [pitch_lists[l][t] for l in range(chord_size)],
                beats=self.event_beats,
                )
            for t in range(self.times)
        ] 

scale = [0,2,4,5,7,9,11,12,14]

# print(scale[1:4])

# TO DO... this moves up too fast!
cf_line = calliope.Line(
    *[
        ChordsCellFactory1(event_beats=0.25, choose_seq = (
            ( (scale[i],), (-7,0,7) ),
            ( (scale[i+1:i+4]), (-7,0,7) ),
            ( (scale[i+4],), (-7,0,7) , ),
            ),
            times=16,
            seed=(i+1)*3
        )
    for i in range(5)
    ],

)



calliope.illustrate(cf_line, as_midi=True)

Example #6
0
            main_seg.rehearsal_mark_number = 7
            main_seg.compress_full_bar_rests = True

    s.cells.apply(lambda x:x.auto_respell())

    return s

def to_lib(lib):    
    rock.to_lib(lib)
    lib.add(score1,
        namespace="rock")

if __name__ == '__main__':
    lib = library.Library()
    to_lib(lib)
    calliope.illustrate(lib["rock_score1"])



# # TO DO... move this cropping to rock 2 ... 
# lb1 = rock.OstiLineBlock(
#             phrase_count=5,
#             cuts = (
#                 dict(crop=(0,5)),
#                 dict(crop=(0,5)),
#                 dict(crop=(2,0)),
#                 ),
#             slur_cells = True,
#             )
# s.extend_from(melody.Melody(
#         lb1,
Example #7
0
    for staff in s.staves:
        # staff.phrases.transformed(calliope.Label())
        # staff.lines.transformed(calliope.Label())

        # TO DO: WHY DOESN'T THIS WORK?????
        if segs := staff.segments:
            main_seg = segs[0]
            for next_seg in list(segs[1:]):
                main_seg.extend(next_seg)
                next_seg.parent.remove(next_seg)
            main_seg.rehearsal_mark_number = 9
            main_seg.compress_full_bar_rests = True
    s.midi_tempo = 160

    return s


def to_lib(lib):
    rock.to_lib(lib)
    lib.add(score4, namespace="rock")


if __name__ == '__main__':
    lib = library.Library()
    to_lib(lib)
    calliope.illustrate(
        lib["rock_score4"],
        as_midi=True,
        # open_midi=True,
    )
Example #8
0
import abjad, calliope

# class CompositeBlock(calliope.FromSelectableFactory):
#     """
#     Creates a new block by pulling out alternating notes/chords from a block
#     """

#     def get_branches(self, *args, **kwargs):

#         for b in self.selectable

c = calliope.CellBlock(
    calliope.Cell(rhythm=(-1, 3, -1, 3), pitches=(None, 5, None, 0)),
    calliope.Cell(rhythm=(-0.5, 0.5, 1, 2, -2, 2),
                  pitches=(None, 2, 4, 0, None, 2)),
)

my_cell = calliope.CompositeCell(c)

calliope.illustrate(c)
calliope.illustrate(my_cell)

# print(c.cells[0].events[1].beats_before(c.cells[0]))

# print(make_row(c))

# print(c.root)
Example #9
0
    bass.to_lib(lib)
    lib.add(block0, score0, namespace="intro2")


if __name__ == '__main__':
    lib = library.Library()
    intro.to_lib(lib)
    to_lib(lib)
    # calliope.illustrate(lib("intro2_score0"))
    s = lib("intro2_block0").to_score(midi_tempo=112)
    s.staves["melody_line1"].midi_instrument = "flute"
    s.staves["melody_line2"].midi_instrument = "flute"
    s.staves["chords"].midi_instrument = "electric grand"

    calliope.illustrate(s,
        as_midi=True,
        open_midi=True,
        )


# intro_blocks[0].lines[0].note_events

# n_0 = intro_blocks[1].lines.note_events

# for l in intro_blocks[0].lines:
#     # l.bookend_pad(3)
#     for e in l.note_events:
#         if e.beats < 1:
#             e.beats = e.beats / 2
#         else:
#             e.beats = e.beats * 2
# intro_blocks[0].lines[0].bookend_pad(4)
Example #10
0
R3_INTRACATE_LINE_BLOCK_A = R3_INTRACATE_CELL_BLOCK_A.to_rhythm_line_block(4)

R3_INTRACATE_CELL_BLOCK_B1 = RhythmCellBlock(
    (0.25, 0.25, -0.25, 0.25, -0.5, 0.5, -0.5, 0.5, -0.5, -0.25,
     0.25),  # hi hat 1
)

R3_INTRACATE_CELL_BLOCK_B2 = RhythmCellBlock(
    (0.25, 0.25, -0.25, 0.25, -0.5, 0.5, -0.5, 0.5, -0.5, -0.25, 0.25),

    # THIS ONE IS BEST:
    (0.25, 0.25, -0.25, 0.25, 0.25, 0.25, -0.5, -0.5, 0.25, 0.25, 1),
    (
        -0.25,
        0.25,
        -0.25,
        0.25,
        1,
        -0.5,
        0.25,
        0.25,
        0.25,
        0.25,
        -0.5,
    ),
)

calliope.illustrate(R3_INTRACATE_LINE_BLOCK_A.to_rhythmic_staves(),
                    as_midi=True)
Example #11
0
    return b2

def score2(lib):
    return intro.block_to_score(lib, "intro1_block2")

# # =========================================================================
# # =========================================================================

def to_lib(lib):    
    intro.to_lib(lib)
    lib.add(block2, score2, namespace="intro1")

if __name__ == '__main__':
    lib = library.Library()
    to_lib(lib)
    calliope.illustrate(lib("intro1_score2"))
    
    # # FOR TEMP TESTING ONLY:
    # import intro1_0, intro1_1
    # intro1_0.to_lib(lib)
    # intro1_1.to_lib(lib)
    # sc = lib("intro1_score0"
    #     ).extend_from(lib("intro1_score1")
    #     ).extend_from(lib("intro1_score2")
    #     )
    # calliope.illustrate(sc)

# =========================================================================
# BAR 2
# =========================================================================
Example #12
0
    block_type = calliope.Line


class RhythmCellBlock(RhythmBlock, calliope.CellBlock):
    block_type = calliope.Cell

    def to_rhythm_line_block(self, times=1):
        my_line_block = RhythmLineBlock()

        for c in self:
            my_line_block.append(calliope.Line(*[c() for i in range(times)]))

        return my_line_block


measure = RhythmCellBlock(
    (-1, 0.5, 0.5),  # snare
    (-1, 0.5, 0.5),  # quad 1
    (0.5, 0.5, -1),  # bass
)

calliope.illustrate(measure.to_rhythmic_staves())

# print(measure.ly())

# c = calliope.Cell(rhythm=(1,2,1), pitches=(None,2,None))
# c.rhythm = (-1,2,1,4)

# c.logical_ties[0].beats=-1
# calliope.illustrate(c)
Example #13
0
                block1,
                block2,
                block3,
                score_short,
                namespace="lyrical")
        lib.mark_loaded("lyrical")


if __name__ == '__main__':
    lib = library.Library()
    to_lib(lib)
    sc = lib["lyrical_score_short"]
    sc.midi_tempo = 96
    calliope.illustrate(
        sc,
        as_midi=True,
        open_midi=True,
        open_pdf=False,
    )

# sb = calliope.SegmentBlock(
#     home.HOME_A_B_FAST.t(7).ext( home.HOME_A_B_FAST().t(12) ).move_t(),
#     home.HOME_B_UP4A_FAST.t(7).ext( home.HOME_B_UP4A_FAST().t(12) ).move_t(),
#     home.HOME_A_B().move_t(),
#     home.HOME_B_UP4A().move_t(),
#     counter.LINE_A_B().move_t(),
#     calliope.Line(name="drone_1",
#         rhythm = (4,)*32,
#         pitches =
#             ((-1,16),)*4 +
#             ((-3,16),)*4 +
#             ((-3,14),)*4 +
Example #14
0
    s.midi_tempo = 96
    return s

def to_lib(lib):    
    lyrical.to_lib(lib)
    lib.add(score0, namespace="lyrical")

if __name__ == '__main__':
    lib = library.Library()
    to_lib(lib)
    score=lib["lyrical_score0"]
    score.remove(score.staff_groups["short_score"])
    calliope.illustrate(
        score,#.only_staves("ooa_flute","ooa_clarinet"),
        as_midi=True,
        # open_midi = True
        )


# TO DO: CONSIDER RE-ADDING
# swell2 = lyrical.CcoWindsSwell(
#     mask_staves=("cco_clarinet1", "cco_clarinet2"),
#     swell_duration = 7,
#     bookend_beats = (1,0),
#     )

# # =======================================================


Example #15
0
#     )

# prick1.events[0].tag(r"\improvisationOn")

# prick_faster.events[0].tag(r"\improvisationOff")

# seg = StringSegment(
#     prick1(),
#     prick_faster(),
#     # prick1(),
#     # prick2(),
#     # prick1(),
#     # c(),
#     string_def_event = prick_strings.PRICK_STRING_HIGHEST
#     )

# seg1 = StringSegment(
#     prick2(),
#     string_def_event = DEF_2
#     )

# op.staff_groups[1].add_segment(seg1)
# op.staff_groups[1].add_segment(seg1)

# op.events[0].tag(r"\startScore")

# op.staves[1].pop()
# op.staves[2].pop()

calliope.illustrate(op)
Example #16
0
                                0: RIFF_DICT_A,
                                1: RIFF_DICT_D,
                                2: RIFF_DICT_B,
                                2: {
                                    **RIFF_DICT_A,
                                    **{
                                        "inversions": (0, 1, 2, 1, 2)
                                    }
                                },
                                3: RIFF_DICT_B,
                                4: RIFF_DICT_C,
                                5: RIFF_DICT_B,
                            })
    calliope.illustrate(
        calliope.LineBlock(RIFF, RIFF_CHORDS).to_score(midi_tempo=120),
        as_midi=True,
        # open_midi=True
        # open_pdf = False,
    )

# class SusCell(ImaginaryCell):
#     # TO DO: WARNING.. ORDER OF SETTING CAN CAUSE ISSUES
#     # init_sus = (4,)
#     # init_inversions = (0,)
#     # init_rhythm = (1,1,1,1)
#     # init_chord_roots = (0,) # can't use "root" as attr name since it's for tree root
#     sort_init_attrs = calliope.Cell.sort_init_attrs + ("chord_roots", "inversions", "sus")

#     _sus = (4,)
#     _inversions = (0,)
#     _chord_roots = (0,)
#     _pitches_set = False
Example #17
0
        return [
            calliope.Phrase(*[
                calliope.Cell(rhythm=c, pitches=self.get_pitches(c, o))
                for c in self.cell_rhythms
            ]) for o in self.octaves
        ]

    def get_pitches(self, rhythm, octave):
        return [(self.pitch_class + (12 * octave) if r > 0 else None)
                for r in rhythm]

    # def get_branches_kwargs(self, *args, **kwargs):

    #     # should return an iterable of dictionaries
    #     return (

    #     ) # e.g. return (dict(rhythm=(1,2), pitches=(2,1)), dict(...),)

    # def get_branch(self, *args, **kwargs):
    #     return self.branch_type(**kwargs)


T10_HOLD = T10_Hold(pitch_class=-5,
                    octaves=(-1, -2),
                    cell_rhythms=(
                        (-1, 6, -1),
                        (-1, 6, -1),
                    ))

calliope.illustrate(T10_HOLD)
Example #18
0
                      pitches=(
                          (-5, 9),
                          (9, -8),
                          (-5, 9, 2),
                          (9, -8),
                          (-5, 9),
                          (9, 4, -8),
                          2,
                          (-5, 9, 2),
                          (9, -8),
                      ))
    c.events[1, 3, 5, 8].tag("note_head:0:cross")
    c.events[0, 1, 2, 3, 4, 5, 7, 8].tag("note_head:-1:cross")
    return c


def to_lib(lib):
    if not lib.is_loaded("drum"):
        lib.add(drum_off_short, drum_du_du, drum_on_off, drum_quick_off,
                drum_rock_out, drum_quick_off2, drum_dark, drum_hits)
        lib.mark_loaded("drum")


if __name__ == '__main__':
    lib = library.Library()
    to_lib(lib)
    calliope.illustrate(
        calliope.Staff(lib("drum_hits") * 8, clef="percussion"),
        as_midi=True,
        open_midi=True,
    )
Example #19
0
        "R",
        9,(-8,9),
        (-5,2,5),-8,
        2,
        )
    ).eps(
    1,2,4, "note_head:0:cross")(
    2, "note_head:1:cross"
    )()

seg.append(c1)
seg.append(c2)


calliope.illustrate(calliope.Staff(
    seg,
    clef="percussion"
    ))



# def test1(times=10000):
#     for i in range(times):
#         my_cell = ImaginaryCell(rhythm=(4,-4,2,2), pitches=(2,"R",0,-1))
#         my_cell.events[0].tag("p")
#     return my_cell

# def test2(times=10000):
#     def cell_test(lib):
#         return ImaginaryCell(rhythm=(4,)*4)
#     lib = library.Library()
#     lib.add(cell_test, namespace="testing")
Example #20
0
# # =========================================================================
# # =========================================================================


def score(lib):
    sc = lib("intro0_score0")
    sc.extend_from(
        lib("intro0_score1"),
        lib("intro0_score2"),
    )
    return sc


def to_lib(lib):
    intro.to_lib(lib)
    lib.add(block0,
            score0,
            block1,
            score1,
            block2,
            score2,
            score,
            namespace="intro0")


if __name__ == '__main__':
    lib = library.Library()
    to_lib(lib)
    calliope.illustrate(lib("intro0_score"))
Example #21
0
    sc.extend_from(lib["integrate1_score1"])
    sc.extend_from(lib["integrate2_score2"])
    sc.extend_from(lib["integrate3_score3"])
    sc.extend_from(lib["integrate4_score4"])
    # sc.extend_from(lib["integrate5_score5"])
    sc.midi_tempo = 96
    return sc


def to_lib(lib):
    integrate0.to_lib(lib)
    integrate1.to_lib(lib)
    integrate2.to_lib(lib)
    integrate3.to_lib(lib)
    integrate4.to_lib(lib)
    integrate5.to_lib(lib)
    lib.add(integrate_score)


if __name__ == '__main__':
    lib = library.Library()
    to_lib(lib)
    score = lib["integrate_score"]
    score.remove(score.staff_groups["short_score"])

    calliope.illustrate(
        score,
        title="Memory Bubbles IV.",
        as_midi=True,
        open_midi=True,
    )
Example #22
0

def bass_flat2(lib):
    return lib("bass_line").flat2()


def to_lib(lib):
    if not lib.is_loaded("bass"):
        lib.add(bass_line, bass_trunc, bass_short, bass_flat1, bass_flat2)
        lib.mark_loaded("bass")


if __name__ == '__main__':
    lib = library.Library()
    to_lib(lib)
    calliope.illustrate(calliope.Staff(lib("bass_line"), clef="bass"))

# l5_aflat = l5()
# for e in l5_aflat.note_events:
#     if e.pitch % 12 == 9:
#         e.pitch += -1

# l5_dflat = l5_aflat()
# for e in l5_dflat.note_events:
#     if e.pitch % 12 == 2:
#         e.pitch += -1

# s5 = calliope.Segment(
#     l5(),
#     l5(),
#     l5_aflat(),
Example #23
0
        # staff.lines.transformed(calliope.Label())

        # TO DO: WHY DOESN'T THIS WORK?????
        if segs := staff.segments:
            main_seg = segs[0]
            for next_seg in list(segs[1:]):
                main_seg.extend(next_seg)
                next_seg.parent.remove(next_seg)
            main_seg.rehearsal_mark_number = 11
            main_seg.compress_full_bar_rests = True
    s.midi_tempo = 96

    return s


def to_lib(lib):
    integrate.to_lib(lib)
    lib.add(tenor_sax_half_counter_score, score1, namespace="integrate1")


if __name__ == '__main__':
    lib = library.Library()
    to_lib(lib)

    calliope.illustrate(
        lib["integrate1_score1"],
        as_midi=True,
        open_midi=True,
        # open_pdf=False,
    )
Example #24
0
import abjad
import calliope

from imaginary.libraries.z_rhythm_block import RhythmCellBlock, RhythmLineBlock


R5_ANGULAR_CELL_BLOCK = RhythmCellBlock(
#   (----,----,----,----|----,----,----,----|----,----,----,----|----,----,----,----)
    (
    -1,                  1,                  -0.75,         0.25,-1,     
    -0.25,0.25,-0.5,     1,                  -0.75,         0.25,-0.5,     0.5,     
    -1,                 -0.25,0.25,-0.5,     -0.25,0.25,-0.5,    -1,               
    -1,                 -0.25,0.25,-0.5,     -0.25,0.25,-0.5,    -1,                   
    ),
    


    )



calliope.illustrate(
    R5_ANGULAR_CELL_BLOCK.to_rhythmic_staves(),
    as_midi=True
    )
Example #25
0
#   (----,----,----,----|----,----,----,----|----,----,----,----|----,----,----,----)
    (-1,                 0.25,-0.5,     0.25,0.25,0.25,-0.5,     -1,                ),
    (-1,                 -1,                -0.5,      0.25,0.25,-1,                ),
    (-1,                 -1,                -1,                  -1,                ),
    )

R4_POUNDING_CELL_BLOCK_B = RhythmCellBlock(
#   (----,----,----,----|----,----,----,----|----,----,----,----|----,----,----,----)

    (-1,                 0.5,     -0.5,      0.25,0.25,0.5,     -1,                 
     -0.5,     0.25,0.25,0.25,0.25,-0.5,    -1,                 -1,                 ),
    
    (-0.5,     0.5,     -0.5,      0.5,     -1,                 -1,                 
     -1,                -0.5,      0.25,0.25,0.25,0.25,-0.5,    -1,                 ),
    
    (-1,                -1,                 -1,                  0.25,0.25,-0.5,    
     -1,                -1,                 -0.5,      0.25,0.25,-1,                ),

    )



R4_POUNDING_LINE_BLOCK_A = R4_POUNDING_CELL_BLOCK_A.to_rhythm_line_block(4)

R4_POUNDING_LINE_BLOCK_B = R4_POUNDING_CELL_BLOCK_B.to_rhythm_line_block(4)


calliope.illustrate(
    R4_POUNDING_CELL_BLOCK_B.to_rhythmic_staves(),
    as_midi=True
    )
Example #26
0
    for staff in s.staves:
        if segs := staff.segments:
            main_seg = segs[0]
            for next_seg in list(segs[1:]):
                main_seg.extend(next_seg)
                next_seg.parent.remove(next_seg)
            main_seg.rehearsal_mark_number = 4
            main_seg.auto_respell()
            main_seg.compress_full_bar_rests = True

    s.midi_tempo = 96
    return s


def to_lib(lib):
    lyrical.to_lib(lib)
    lib.add(score2, namespace="lyrical")


if __name__ == '__main__':
    lib = library.Library()
    to_lib(lib)
    score = lib["lyrical_score2"]
    # score.remove(score.staff_groups["short_score"])
    calliope.illustrate(
        score,
        as_midi=True,
        # open_midi=True
    )
Example #27
0
    ),
    (
        1,
        1,
        0.5,
        0.5,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        0.5,
        0.5,
        1,
        1,
        0.5,
        0.5,
        -1,
        -1,
    ),
)

# the simplest one!
R6_BEAT_CELL_BLOCK_D = RhythmCellBlock((1, ) * 4)

R6_BEAT_LINE_BLOCK_C = R6_BEAT_CELL_BLOCK_C.to_rhythm_line_block(4)

calliope.illustrate(R6_BEAT_LINE_BLOCK_C.to_rhythmic_staves(), as_midi=True)
Example #28
0
                            events_dict[ticks_counter] = [my_tuple]

                    ticks_counter += e.ticks
                    note_index += 1           

            for t, tl in sorted(events_dict.items()):

                sorted_tl = sorted(tl, key=lambda x: (x[2][1]+x[2][0])/2 )
                my_ticks = selectable_start_beat*calliope.MACHINE_TICKS_PER_BEAT + t
                # print(my_ticks, my_ticks/calliope.MACHINE_TICKS_PER_BEAT)
                selectable_pitches = selectable.pitch_analyzer.pitches_at_ticks(my_ticks)
                if len(selectable_pitches) > 0:
                    for i, tu in enumerate(sorted_tl):
                        fabric_event = tu[0]
                        fabric_event.pitch = selectable_pitches[ round((i+1)/len(tl) * (len(selectable_pitches)-1))]
                else:
                    self.warn("attempting to set to pitches but no pitches at this beat in the selectable")

            for staff in staves:
                calliope.SmartRanges(smart_ranges=staves_ranges[staff.name]
                    )(staff)


if __name__ == "__main__":
    score = ImaginaryScore()
    for staff in score.staves:
        staff.append(calliope.Cell(rhythm=(-4,)))
    calliope.illustrate(score)


Example #29
0
):
    my_line = ImaginaryLine()
    for i in range(times):
        my_cell = ImaginaryCell(
            rhythm=rhythm,
            pitches=[center_pitch if r > 0 else "R" for r in rhythm])
        if instruction and i == 0:
            my_cell.events[0].tag(instruction)
        else:
            my_cell.events[0].tag("(%s)" % (i + 1))
        if pitches and i == 0:
            my_cell.note_events[0].pitch = pitches
            my_cell.note_events[0].tag("\\once \\hide Stem")
            my_cell.note_events[1:].tag("note_head:0:slash")
            my_cell.note_events[1].tag(
                "\\once \\override Accidental #'stencil = ##f ")
        else:
            my_cell.note_events.tag("note_head:0:slash")
        my_line.append(my_cell)

    # FOR LISTENING ONLY:
    # my_line.note_events[1:].setattrs(pitch="R")

    return my_line


calliope.illustrate(get_improv_line(pitches=(0, 5),
                                    rhythm=(1, -1, 1, -1),
                                    center_pitch=11),
                    times=2)
Example #30
0
import abjad
import calliope

from imaginary.libraries.z_texture_block import TexturePhraseBlock


class T9_Riff(TexturePhraseBlock):
    class RiffPhrase(calliope.Phrase):
        class CellA(calliope.Cell):
            init_rhythm = (0.5, ) * 4
            init_pitches = (2, 4, 9, 11)

        class CellB(calliope.Cell):
            init_rhythm = (0.5, ) * 4
            init_pitches = (0, 4, 9, 5)

        class CellC(calliope.Cell):
            init_rhythm = (0.5, ) * 4
            init_pitches = (12, 9, 11, 12)

        class CellD(calliope.Cell):
            init_rhythm = (0.5, ) * 4
            init_pitches = (14, 11, 7, 4)


# T9_RIFF = T9_Riff()

T9_RIFF = T9_Riff(add_intervals=(5, ))

calliope.illustrate(T9_RIFF)