Ejemplo n.º 1
0
def score1(lib):
    s = score.ImaginaryScore()
    sb = lib("integrate_block1")

    s = sb().annotate(slur_cells=True, label=(
        "phrases",
        "cells",
    )).to_score(s)

    # drum_off_cell.note_events[1].tag("brushes")
    # drum_on_off_cell.note_events.tag("note_head:0:cross")
    # drum_on_off_cell.note_events.tag("note_head:1:cross")

    drum_set = ImaginarySegment(
        lib("drum_on_off"),
        get_improv_line(rhythm=(1, ) * 8, times=7).ops("cells")(6, "\\<")(),
        get_improv_line(instruction="improv, solo",
                        rhythm=(0.5, ) * 8,
                        times=1).eps(0, "mf")(),
    )
    s.staves["ooa_drum_set"].append(drum_set)

    string_staves = (
        "ooa_violin1",
        "ooa_violin2",
        "ooa_cello1",
        "ooa_cello2",
        "cco_violin_i",
        "cco_violin_ii",
        "cco_viola",
        "cco_cello",
    )

    s.extend_from(
        pulse_on_off_beat.PulseOnOffBeat(
            sb,
            fabric_staves=string_staves,
            phrase_beats=(8, ) * 8,
            ranges=pitch_ranges.LOW_TO_HIGHISH_RANGES,
        ), )

    # CCO cello and viola come in first ... then
    for st in s.staves["ooa_cello1", "ooa_cello2"]:
        st.segments[0].mask("cells", 0, 1)
    for st in s.staves["cco_violin_i", "cco_violin_ii", ]:
        st.segments[0].mask(
            "cells",
            0,
            1,
            2,
            3,
        )
    for st in s.staves["ooa_violin1", "ooa_violin2"]:
        st.segments[0].mask("cells", 0, 1, 2, 3, 4, 5)

    timp_seg = s.staves["cco_cello"].segments[0]()
    for n in timp_seg.note_events:
        if not n.pitch in (-22, -15, -10):
            n.pitch = "R"
    timp_seg.cells[12, 13].note_events.tag(">")
    timp_seg.transformed(calliope.StandardDurations()).eps(
        0, "\\timpStaff", "timpani", "p")()
    s.staves["cco_percussion"].append(timp_seg)

    for st in s.staves[string_staves]:
        st.note_events[0].tag("arco", "p")
        st.phrases[3].e_smear_after(0, cover_notes=True,
                                    extend_beats=3.5).eps(0, "\\<")()
        st.cells[7].tag("mf")
        st.cells[13].e_smear_after(0, extend_beats=2.5,
                                   cover_notes=True).eps(0, "\\mp", "\\<")()()
        st.cells[13].eps(1, "mf", ">", ".")()
        st.cells[14].eps(0, ">", ".")()

    bass_seg = s.staves["cco_cello"].segments[0]()
    for n in bass_seg.cells[4:].note_events:
        n.pitch = sb.pitches_at(n.beats_before(bass_seg))[0] + 12
    for c in bass_seg.cells[14:]:
        c.t(1)
    s.staves["cco_bass"].append(bass_seg)

    s.extend_from(
        lambda_segment.LambdaSegments(
            sb.with_only("bass_line", ),
            fabric_staves=("ooa_bassoon", "cco_bassoon"),
            funcs=(
                lambda x: x.crop_chords(indices=(0, 1)).crop("cells", 0, 1),
                lambda x: x.crop_chords(indices=(1, 0)).crop("cells", 0, 1),
            ),
            tag_all_note_events=("-", )))
    s.extend_from(
        lambda_segment.LambdaSegments(
            sb.with_only("melody_line1"),
            fabric_staves=("harp1", "harp2"),
            funcs=(
                lambda x: x.crop_chords(indices=(1, )).ops("note_events")
                (0, "mp")(),
                lambda x: x.crop_chords(indices=(0, )).t(-12),
            ),
        ))

    # s.extend_from(
    #     lambda_segment.LambdaSegments(
    #         sb.with_only("counter_line"),
    #         # assign_pitches_from_selectable = True,
    #         fabric_staves = ("piano1","piano2"),
    #         func = lambda x: x.transformed(
    #                 calliope.StandardDurations(
    #                     min_duration=0.25,
    #                     standard_duration=0.5,)
    #                 ).e_smear_after(4, cover_notes=True, extend_beats=1
    #                 ).e_smear_after(6, cover_notes=True, extend_beats=0.5
    #                 ).e_smear_after(8, cover_notes=True, extend_beats=0.5
    #                 ).e_smear_after(10, cover_notes=True, extend_beats=0.5
    #                 ).e_smear_after(16, cover_notes=True, extend_beats=0.5
    #                 ).e_smear_after(19, cover_notes=True, extend_beats=0.5
    #                 ).e_smear_after(22, cover_notes=True, extend_beats=0.5
    #                 ).e_smear_after(29, cover_notes=True, extend_beats=0.5
    #                 ).e_smear_after(33, cover_notes=True, extend_beats=0.5
    #                 ).e_smear_after(35, cover_notes=True, extend_beats=0.5
    #                 ).e_smear_after(46, cover_notes=True, extend_beats=0.5
    #                 ).e_smear_after(86, cover_notes=True, extend_beats=0.5
    #                 ).mask("events",24,25,27,31
    #                 ).mask("cells",26,27,29,31).slur_cells(#).label("events","cells"
    #                 ),
    #         funcs = (
    #             lambda x: x.crop_chords(indices=(1,)).transformed(
    #                 calliope.SmartRange(
    #                     smart_range = (12,26),
    #                     )
    #                 ),
    #             lambda x: x.crop_chords(indices=(0,)).t(-12).transformed(
    #             ),
    #         )
    #         )
    #     )
    # harp_piano_combo = calliope.CompositeChordsLine(
    #     calliope.LineBlock(
    #         ImaginaryLine(*s.staves["harp2"].cells.copy()),
    #         ImaginaryLine(*s.staves["piano2"].cells.copy())),
    #     ).transformed(artics.GroupByBeats())
    # s.staves["ooa_mallets"].append(ImaginarySegment(harp_piano_combo))

    # s.extend_from(
    #     lambda_segment.LambdaSegments(
    #         sb.with_only("melody_line2"),
    #         fabric_staves = ("piano1","piano2"),
    #         funcs = (
    #             lambda x: x.crop_chords(indices=(1,)),
    #             lambda x: x.crop_chords(indices=(0,)).t(-12),
    #             ),
    #         )
    #     )
    guitars = osti.Osti(
        sb.with_only("bass_drones"),
        fabric_staves=(
            "ooa_bass_guitar",
            "ooa_guitar",
        ),
        ranges=pitch_ranges.MID_RANGES,
        osti_pulse_duration=1,
        osti_cell_length=16,
        osti_cell_count=4,
    )
    s.extend_from(
        staggered_swell.StaggeredSwells(
            sb.with_only("high_drones"),
            fabric_staves=("ooa_flute", "cco_flute1", "cco_flute2"),
            low_dynamic="p",
            swell_dynamic="mf",
            swell_duration=8,
            cell_count=2,
            phrase_count=4,
        ),
        guitars,
    )

    harp_lh = s.staves["harp2"].segments[0]
    for n in harp_lh.note_events:
        pitches_at_sb = sb.pitches_at(n.beats_before(harp_lh))
        n.pitch = (pitches_at_sb[1], pitches_at_sb[-4])
    harp_lh.smart_ranges([(-14, 4)])
    # now remove dupes
    for n in harp_lh.note_events:
        n.pitch = set(n.pitch)
    for c in harp_lh.cells:
        c.mask("note_events", -1, -2)
    harp_lh.transformed(calliope.StandardDurations())

    piano_rh = ImaginarySegment(
        ImaginaryLine(
            ImaginaryCell(rhythm=(-4, )),
            ImaginaryPhrase(
                ImaginaryCell(rhythm=(0.25, 1.75) * 2),
                ImaginaryCell(rhythm=(2, ) * 4),
            ) * 4,
        ))
    piano_lh = harp_lh()

    mallets = piano_rh()
    for n in mallets.note_events:
        n.pitch = sb.pitches_at(n.beats_before(mallets))[-3]
    s.staves["ooa_mallets"].append(mallets)
    mallets.eps(1, "mp")(8, 16, 22, 24, 30, ":32")()

    for n in piano_rh.note_events:
        if n.beats == 0.25:
            n.pitch = sb.pitches_at(n.beats_before(piano_rh))[-2]
            n.tag("(")
        elif n.beats == 1.75:
            n.pitch = sb.pitches_at(n.beats_before(piano_rh))[-1]
            n.tag(")")
        else:
            n.pitch = set(sb.pitches_at(n.beats_before(piano_rh))[-2:])
    for n in piano_lh.note_events:
        n.pitch = sb.pitches_at(n.beats_before(piano_lh))[1]
    piano_lh.fuse().slur_cells()
    for n in piano_lh.note_events:
        n.pitch = set(sb.pitches_at(n.beats_before(piano_lh))[1:3])

    s.staves["piano1"].append(piano_rh)
    s.staves["piano2"].append(piano_lh)

    s.fill_rests(beats=15 * 4)
    final_swell_sax_brass = swell_hit.SwellHit(
        sb.with_only("chords"),
        fabric_staves=instrument_groups.get_instruments(
            "sax",
            "brass",
        ),
        ranges=pitch_ranges.HIGHISH_RANGES,
        selectable_start_beat=15 * 4,
        low_dynamic="p",
        hit_dynamic="mf",
        swell_duration=7,
        hit_duration=1,
        hit_rest=0,
        hit_articulations=("-", ))
    s.extend_from(final_swell_sax_brass)

    s.fill_rests(beats=16 * 4)
    final_swell_winds_strings = swell_hit.SwellHit(
        sb.with_only("chords"),
        fabric_staves=instrument_groups.get_instruments(
            "winds",
            "strings",
        ),
        ranges=pitch_ranges.HIGHISH_RANGES,
        selectable_start_beat=16 * 4,
        low_dynamic="mp",
        hit_dynamic="f",
        swell_duration=3,
        hit_duration=1,
        hit_rest=0,
        hit_articulations=("-", ))
    s.extend_from(final_swell_winds_strings)

    # s.extend_from(final_block)

    s.fill_rests(fill_to="cco_violin_i")

    # s.only_staves("piano1", "piano2")
    # s.as_rhythm_and_short()

    # s.only_staves(*instrument_groups.get_instruments("cco_strings"))

    s.fill_rests()
    s.remove(s.staff_groups["short_score"])

    # s.lines.apply(lambda x:x.auto_respell())
    # s.phrases.apply(lambda x:x.auto_respell())

    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 = 11
            main_seg.compress_full_bar_rests = True
Ejemplo n.º 2
0
def score4(lib):
    s = score.ImaginaryScore()
    sb = lib("integrate_block4")
    s = sb().annotate(slur_cells=True, label=("phrases", "cells")).to_score(s)

    drum_set = ImaginarySegment(
        get_improv_line(instruction="improv", rhythm=(0.5, ) * 8,
                        times=16).eps(0, "f")(), )
    s.staves["ooa_drum_set"].append(drum_set)

    string_pulses = pulse_on_off_beat.PulseOnOffBeat(
        sb,
        fabric_staves=("ooa_violin1", "ooa_violin2", "ooa_cello1",
                       "ooa_cello2", "cco_violin_i", "cco_violin_ii",
                       "cco_viola", "cco_cello", "cco_bass"),
        after_func=lambda x: x.eps(0, "f")(),
        phrase_beats=(4, ) * 16,
        ranges=pitch_ranges.HILL_DOWN_RANGES,
    )
    string_pulses.staves["cco_bass"].phrases[0].t(-12)
    string_pulses.staves["cco_bass"].phrases[1].t(-12)
    s.extend_from(string_pulses)

    guitars = osti.Osti(sb.with_only("bass_drones"),
                        fabric_staves=(
                            "ooa_bass_guitar",
                            "ooa_guitar",
                        ),
                        ranges=pitch_ranges.BOTTOM_RANGES,
                        osti_pulse_duration=1,
                        osti_cell_length=16,
                        osti_cell_count=3,
                        after_func=lambda x: x.eps(0, "fat fx", "f")())
    for seg in guitars.segments:
        seg.stack_p([(0, 7)])
    guitars_end = osti.Osti(sb.with_only("bass_drones"),
                            fabric_staves=(
                                "ooa_bass_guitar",
                                "ooa_guitar",
                            ),
                            ranges=pitch_ranges.BOTTOM_RANGES,
                            osti_pulse_duration=4,
                            osti_cell_length=1,
                            osti_cell_count=4,
                            after_func=lambda x: x.eps(0, "distorted")
                            (2, "\\>")())
    for seg in guitars_end.segments:
        seg.stack_p([(0, 7)])
    guitars_end.cells.setattrs(respell="sharps")
    trombones = lambda_segment.LambdaSegment(
        sb.with_only("bass_line"),
        fabric_staves=("ooa_trombone", "cco_trombone"),
        func=lambda x: x.eps(1, "ff")(),
        # func = lambda x: x.only_first("cells",8)
    )

    timp_seg = trombones.staves["cco_trombone"].segments[0]().crop(
        "cells", 0, 1)
    for n in timp_seg.note_events:
        if not n.pitch in (-23, -21, -16, -11, -9, -4):
            n.pitch = "R"
    timp_seg.transformed(calliope.StandardDurations()).ops("note_events")(
        0, "ff")()
    timp_seg.smart_ranges([(-17, -5)])
    timp_seg.note_events.tag(">")
    timp_seg.append(
        ImaginaryCell(rhythm=(2, 2), ).eps(0, "\\percStaff",
                                           "sus. cym. (timp beaters)", "mp",
                                           "\\<", ":32")(1, "f", ":32")())

    s.staves["cco_percussion"].append(timp_seg)

    trombones.staves["ooa_trombone"].note_events[-9].tag("\\>")
    trombones.staves["cco_trombone"].note_events[-9].tag("\\>")
    trombones.staves["ooa_trombone"].note_events[-1].tag("mf")
    trombones.staves["cco_trombone"].note_events[-1].tag("p")
    s.extend_from(guitars, trombones)

    sax_melody = lambda_segment.LambdaSegment(
        sb.with_only("high_drones"),
        fabric_staves=instrument_groups.get_instruments(
            "ooa_winds",
            "sax",
        ) + ("ooa_horn", "ooa_trumpet"),
        func=lambda x: x.only_first("cells", 4).slur_cells().ops("note_events")
        (0, "f")(),
        funcs=(
            lambda x: x.t(12),  #fl
            lambda x: x,  #cl
            lambda x: x.t(-24),  #bsn
            lambda x: x,  #as
            lambda x: x.t(-5),  #as
            lambda x: x.t(-12),  #ts
            lambda x: x.t(-24),  #bs
            lambda x: x.t(-12),  #hn
            lambda x: x.t(-12),  #tpt
        ))

    cco_melody = lambda_segment.LambdaSegment(
        sb.with_only("mid_drones"),
        fabric_staves=instrument_groups.get_instruments("cco_winds", ) +
        ("cco_horn", "cco_trumpet"),
        func=lambda x: x.only_first("cells", 4).slur_cells().ops("note_events")
        (0, "f")(),
        funcs=(
            lambda x: x.t(12),  #fl
            lambda x: x.t(12),  #fl
            lambda x: x.t(12),  #ob
            lambda x: x.t(12),  #ob
            lambda x: x,  #cl
            lambda x: x,  #cl
            lambda x: x.t(-24),  #bsn
            lambda x: x.t(-12),  #hn
            lambda x: x.t(0),  #tpt
        ))

    altos1 = lambda_segment.LambdaSegments(
        sb.with_only("counter_line"),
        fabric_staves=("ooa_alto_sax2", "ooa_alto_sax1"),
        funcs=(
            lambda x: x.with_only("cells", 16, 17, 18, 19).poke("cells", 0, 2).
            smear_after(fill=True, gap_beats=1).slur_cells().eps(0, "f")(),
            lambda x: x.with_only("cells", 16, 17, 18, 19).poke("cells", 1, 3).
            smear_after(fill=True, gap_beats=1).slur_cells().eps(2, "f")(),
        ))
    altos2 = lambda_segment.LambdaSegments(
        sb.with_only("melody_line1", "melody_line2"),
        fabric_staves=("ooa_alto_sax1", "ooa_alto_sax2"),
        funcs=(
            lambda x: x.with_only("cells", 10, 11).slur_cells().eps()(),
            lambda x: x.with_only("cells", 10, 11).slur_cells().eps()(),
        ))

    end_doves = x = dovetail.Dovetail(
        sb,
        fabric_staves=("cco_horn", "cco_trumpet", "cco_trombone",
                       "cco_bassoon"),
        ranges=pitch_ranges.LOW_TO_HIGH_RANGES,
        selectable_start_beat=10 * 4,
        tag_all_note_events=("."),
        # dove_count = 4,
        # dove_event_count = 4,
        # tail_event_count = 1,
        dovetail_duration=24,
        # event_duration = 0.5,
        offset=3,
        after_func=lambda x: x.ops("note_events")(0, "f")())

    horns_end = lambda_segment.LambdaSegments(
        sb.with_only("bass_line"),
        fabric_staves=("ooa_horn", "cco_horn"),
        bookend_beats=(4 * 4, 0),
        funcs=(
            lambda x: x.with_only("cells", 12, 13, 14, 15).t(12).eps(0, "f")
            (0, 3, 6, "(")(1, 5, 7, ")")(8, 9, 10, 11, 12, 13, 14, 15, 16, "-")
            (
                8,
                "\\>",
            )(16, "mf")(),
            lambda x: x.with_only("cells", 12, 13, 14, 15).eps(0, "f")
            (0, 3, 6, "(")(1, 5, 7, ")")(8, 9, 10, 11, 12, 13, 14, 15, 16, "-")
            (
                8,
                "\\>",
            )(16, "p")(),
        )
        # func = lambda x: x.only_first("cells",8)
    )

    end_piano_harp = osti.Osti(sb,
                               fabric_staves=("harp1", "harp2", "piano1",
                                              "piano2"),
                               ranges=pitch_ranges.HIGHISH_TO_MID_RANGES,
                               osti_pulse_duration=0.5,
                               osti_cell_length=8,
                               osti_cell_count=12,
                               tag_all_note_events=(">"),
                               after_funcs=(
                                   lambda x: x.eps(0, "f")(),
                                   lambda x: x,
                                   lambda x: x.eps(0, "f")(),
                                   lambda x: x,
                               ))
    end_piano_harp.staves["piano2"].segments[0].t(-12)

    end_roll = pad.Pad(
        sb.with_only("bass_drones"),
        fabric_staves=("ooa_mallets", ),
        ranges=pitch_ranges.HIGHISH_RANGES,
        pad_durations=(4, ) * 16,
        tag_all_note_events=(":32", ),
    )

    s.extend_from(sax_melody, cco_melody, altos1, altos2, horns_end,
                  end_piano_harp, end_roll, guitars_end)

    s.fill_rests(beats=12 * 4)
    # # ================================================
    # # LAST 4 BARS
    improv_tenor_bari_bsn_end = improv.Improv(sb,
                                              fabric_staves=("ooa_tenor_sax",
                                                             "ooa_bari_sax",
                                                             "ooa_bassoon"),
                                              improv_times=4,
                                              selectable_start_beat=12 * 4,
                                              ranges=pitch_ranges.MID_RANGES,
                                              pitch_selectable_indices=((
                                                  1,
                                                  3,
                                                  4,
                                              ), (
                                                  1,
                                                  4,
                                                  5,
                                              ), (
                                                  2,
                                                  3,
                                                  5,
                                              )),
                                              dynamic="mf")
    s.extend_from(improv_tenor_bari_bsn_end, )

    s.fill_rests(beats=14 * 4)
    # # ================================================
    # # LAST 2 BARS

    trumpets_end = lambda_segment.LambdaSegments(
        sb.with_only("melody_line1", "melody_line2"),
        fabric_staves=("ooa_trumpet", "cco_trumpet"),
        # bookend_beats=(6*4,0),
        funcs=(lambda x: x.with_only("cells", 14, 15).eps(1, "mf", "\\>")
               (8, "mp")
               (), lambda x: x.with_only("cells", 14, 15).eps(1, "mf", "\\>")
               (7, "p")()),
        tag_all_note_events=("-", ),
        # func = lambda x: x.only_first("cells",8)
    )
    flutes_end = lambda_segment.LambdaSegment(
        sb.with_only("counter_line"),
        fabric_staves=("ooa_flute", "cco_flute1", "cco_flute2"),
        func=lambda x: x.with_only("cells", 28, 29, 30, 31),
        funcs=(
            lambda x: x.eps(1, "f", "\\>")(15, "mf")(),
            lambda x: x.eps(1, "f", "\\>")(15, "p")(),
            lambda x: x.eps(1, "f", "\\>")(15, "p")(),
        ),
        tag_all_note_events=("-", ),
        # func = lambda x: x.only_first("cells",8)
    )

    improv_cl_alto_end = improv.Improv(sb,
                                       fabric_staves=("ooa_clarinet",
                                                      "ooa_alto_sax1",
                                                      "ooa_alto_sax2"),
                                       improv_times=2,
                                       selectable_start_beat=4 * 14,
                                       ranges=pitch_ranges.HIGHISH_RANGES,
                                       pitch_selectable_indices=(
                                           (1, 3, 4),
                                           (1, 2, 3),
                                           (1, 2, 3),
                                       ),
                                       dynamic="mf")

    s.extend_from(trumpets_end, flutes_end, improv_cl_alto_end)

    s.staves["cco_violin_i"].segments[-1].mask("cells", -1, -2, -3, -4)
    s.staves["cco_violin_ii"].segments[-1].mask("cells", -1, -2)
    s.staves["cco_cello"].segments[-1].mask("cells", -1, -2)
    # s.staves["ooa_cello2"].segments[-1].mask("cells",-1,-2)
    # s.staves["ooa_violin2"].segments[-1].mask("cells",-1,-2)

    # s.staves["cco_flute2"].segments[0].mask("cells",-1,)
    # s.staves["cco_flute2"].note_events[-4].tag("\\>")
    # s.staves["cco_flute2"].note_events[-1].tag("p")

    e0 = free_segment.AlocFreeSegmentBlock(
        tempo_command=""" freely, aprox 30''  """)

    s.staves["ooa_flute"].events[-7].tag("\\>")
    s.staves["ooa_flute"].events[-1].tag("\\!")
    e0["ooa_flute"].machine_arrow(intro.hold_cell(20, ).eps(0, ")")(),
                                  instruction="repeat, slowing down",
                                  with_repeat=False).eps(1, "\\>")(9, "pp")()
    e0["ooa_flute"].respell = "sharps"

    e0["ooa_clarinet"].machine_arrow(lib("cell_rest1") +
                                     lib("intro_cell_down").t(7),
                                     instruction="repeat, slowing down",
                                     with_repeat=False).eps(
                                         3,
                                         "\\>",
                                     )(9, "pp")()
    e0["ooa_clarinet"].respell = "sharps"

    e0["ooa_alto_sax1"].machine_arrow(
        s.staves["ooa_alto_sax1"].cells[-1](),
        instruction="repeating a simple figure 4X, slowing down",
        with_repeat=False).eps(1, "\\>")(9, "pp")()

    e0["ooa_alto_sax2"].machine_arrow(
        s.staves["ooa_alto_sax2"].cells[-1](),
        instruction="repeating a simple figure 3X, slowing down",
        with_repeat=False).eps(1, "\\>")(9, "pp")()

    tenor_end = lib("intro_a_phrase_0").t(7).cells[1] + lib(
        "intro_a_phrase_0").t(7).cells[0]

    e0["ooa_tenor_sax"].machine_arrow(tenor_end,
                                      instruction="repeat, slowing down",
                                      with_repeat=False).eps(
                                          1,
                                          "\\>",
                                      )(9, "pp")()

    e0["ooa_bari_sax"].machine_arrow(intro.hold_cell(-8, ).eps(0, ")")(),
                                     instruction="repeat 3X, slowing down",
                                     with_repeat=False).eps(1, "\\>")(9,
                                                                      "pp")()

    e0["ooa_bassoon"].machine_arrow(intro.hold_cell(-15, ).eps(0, ")")(),
                                    instruction="repeat 2X, slowing down",
                                    with_repeat=False).eps(1, "\\>")(9, "pp")()

    horn_end = s.staves["ooa_horn"].phrases[-1]()
    horn_end.events.untag("-")
    horn_end.t(-12).eps(0, pitch="R")(1, "\\>")(1, 4,
                                                "(")(2, 6,
                                                     ")")(3, 7, 8,
                                                          beats=2)(8, "pp")()
    horn_end.note_events[-1].pitch += 12

    e0["ooa_horn"].machine_arrow(horn_end,
                                 instruction="repeat 3X, slowing down",
                                 with_repeat=False)

    trumpet_end = lib("intro_a_phrase_1").cells[1]().t(14).eps(1, "fermata")()
    e0["ooa_trumpet"].machine_arrow(trumpet_end,
                                    instruction="repeat, 2X",
                                    with_repeat=False).eps(1, "\\>")(9, "pp")()

    e0["ooa_trombone"].machine_arrow(lib("intro_cell_down").t(-5),
                                     instruction="repeat 2X",
                                     with_repeat=False).eps(
                                         1,
                                         "\\>",
                                     )(9, "pp")()
    e0["ooa_trombone"].respell = "sharps"

    e0["ooa_mallets"].machine_arrow(ImaginaryCell(rhythm=(4, ),
                                                  pitches=(16, )).eps(
                                                      0, ":32")(),
                                    with_repeat=False).eps(1, "\\>")(9, "pp")()

    e0["ooa_drum_set"].machine_arrow(get_improv_line(
        instruction="improv, rolls",
        rhythm=(4, ),
        times=1,
    ).eps(0, "fermata", ":32")(),
                                     with_repeat=False).eps(1, "\\>")(9,
                                                                      "pp")()

    e0["ooa_guitar"].machine_arrow(intro.hold_cell(8, ),
                                   with_repeat=False).eps(
                                       1, "\\>", "distorted, ethereal")(9,
                                                                        "pp")()
    e0["ooa_guitar"].respell = "sharps"

    e0["ooa_bass_guitar"].machine_arrow(intro.hold_cell(-15, ),
                                        with_repeat=False).eps(
                                            1, "\\>",
                                            "distorted, ethereal")(9, "pp")()

    # (NOTE: switching strings between 1 and 2)

    ooa_vln1_end = s.staves["ooa_violin2"].phrases[-1]()
    ooa_vln1_end.note_events[-1].pitch -= 12

    e0["ooa_violin1"].machine_arrow(
        ooa_vln1_end,
        instruction="repeat 3X, slowing down (not together with others)",
        with_repeat=False).eps(1, "\\>")(9, "pp")()

    e0["ooa_violin2"].machine_arrow(
        s.staves["ooa_violin1"].phrases[-1](),
        instruction="repeat 4X, slowing down (not together with others)",
        with_repeat=False).eps(1, "\\>")(9, "pp")()

    ooa_vc1_end = s.staves["ooa_cello2"].phrases[-1]()
    ooa_vc1_end.note_events[-1].pitch -= 12
    ooa_vc1_end.note_events[-2].pitch -= 12

    e0["ooa_cello1"].machine_arrow(
        ooa_vc1_end,
        instruction="repeat 2X, slowing down (not together with others)",
        with_repeat=False).eps(1, "\\>")(9, "pp")()

    e0["ooa_cello2"].machine_arrow(
        s.staves["ooa_cello1"].phrases[-1](),
        instruction="repeat 5X, slowing down (not together with others)",
        with_repeat=False).eps(1, "\\>")(9, "pp")()

    e0["cco_flute1"].machine_arrow(lib("cell_rest4").eps(0, "fermata")(),
                                   with_repeat=False)

    e0["cco_flute2"].machine_arrow(lib("cell_rest4").eps(0, "fermata")(),
                                   with_repeat=False)

    e0["cco_oboe1"].machine_arrow(lib("cell_rest4").eps(0, "fermata")(),
                                  with_repeat=False)

    e0["cco_oboe2"].machine_arrow(lib("cell_rest4").eps(0, "fermata")(),
                                  with_repeat=False)

    e0["cco_clarinet1"].machine_arrow(lib("cell_rest4").eps(0, "fermata")(),
                                      with_repeat=False)

    e0["cco_clarinet2"].machine_arrow(lib("cell_rest4").eps(0, "fermata")(),
                                      with_repeat=False)

    e0["cco_bassoon"].machine_arrow(lib("cell_rest4").eps(0, "fermata")(),
                                    with_repeat=False)

    e0["cco_horn"].machine_arrow(lib("cell_rest4").eps(0, "fermata")(),
                                 with_repeat=False)

    e0["cco_trumpet"].machine_arrow(lib("cell_rest4").eps(0, "fermata")(),
                                    with_repeat=False)

    e0["cco_trombone"].machine_arrow(lib("cell_rest4").eps(0, "fermata")(),
                                     with_repeat=False)

    e0["cco_percussion"].machine_arrow(lib("cell_rest4").eps(
        0, "fermata", "l.v.")(),
                                       with_repeat=False)

    e0["harp1"].machine_arrow(lib("cell_rest4").eps(0, "fermata")(),
                              with_repeat=False)

    e0["harp2"].machine_arrow(lib("cell_rest4").eps(0, "fermata")(),
                              with_repeat=False)

    e0["piano1"].machine_arrow(lib("cell_rest4").eps(0, "fermata")(),
                               with_repeat=False)

    e0["piano2"].machine_arrow(lib("cell_rest4").eps(0, "fermata")(),
                               with_repeat=False)

    e0["cco_violin_i"].machine_arrow(lib("cell_rest4").eps(0, "fermata")(),
                                     with_repeat=False)

    e0["cco_violin_ii"].machine_arrow(lib("cell_rest4").eps(0, "fermata")(),
                                      with_repeat=False)

    e0["cco_viola"].machine_arrow(lib("cell_rest4").eps(0, "fermata")(),
                                  with_repeat=False)

    e0["cco_cello"].machine_arrow(lib("cell_rest4").eps(0, "fermata")(),
                                  with_repeat=False)

    e0["cco_bass"].machine_arrow(lib("cell_rest4").eps(0, "fermata")(),
                                 with_repeat=False)

    for bass_seg in s.staves["cco_bass"].segments:
        bass_seg.transformed(calliope.Transpose(interval=12))

    s.fill_rests(beats=16 * 4)

    for st in s.staves:
        try:
            end_seg = e0[st.name]
            if end_seg.events:
                end_seg.events[-1].tag("""!\\bar "|." """)
            st.append(end_seg)
        except:
            print("st.name not in final free block")

    # s.staves["cco_violin_i"].append(b0["cco_violin_i1"]
    #     )

    # strings_pulse1 = pulse.Pulse(
    #     fabric_staves = (
    #         "ooa_violin1", "ooa_violin2", "ooa_cello1", "ooa_cello2",
    #         "cco_violin_i", "cco_violin_ii", "cco_viola"),
    #     pulse_beats = 26,
    #     )

    # strings_swell1 = swell_hit.SwellHit(
    #     fabric_staves = (
    #         "ooa_violin1", "ooa_violin2", "ooa_cello1", "ooa_cello2",
    #         "cco_violin_i", "cco_violin_ii", "cco_viola"),
    #     swell_duration = 5.5,
    #     hit_rest = 0,
    #     )

    # strings_low_pulse1 = pulse.Pulse(
    #     fabric_staves = ("cco_cello", "cco_bass"),
    #     pulse_duration = 1,
    #     pulse_beats = 29,
    #     )

    # counter_winds = ditto.Ditto(
    #     calliope.LineBlock(
    #         COUNTER_LINE_1(),
    #         COUNTER_LINE_2(),
    #         ),
    #     fabric_staves = ("ooa_flute", "ooa_clarinet",
    #         "cco_flute1", "cco_flute2",
    #         "cco_clarinet1", "cco_clarinet2")
    #     )

    # osti_lb = rock.OstiLineBlock(
    #     phrase_count=7,
    #     cuts = (
    #         dict(crop=(0,6)),
    #         dict(crop=(0,6)),
    #         dict(crop=(0,6)),
    #         dict(crop=(2,0)),
    #         ),
    #     slur_cells = True,
    #     )

    # osti1 = ditto.Ditto(osti_lb,
    #     fabric_staves = ("ooa_bassoon", "cco_oboe1", "cco_oboe2", "cco_bassoon")
    #     )

    # osti1_accents = hit_cells.HitCells(osti_lb,
    #     fabric_staves = instrument_groups.get_instruments("sax")
    #     )

    # # TO DO: move to lyrical section
    # melody_lb = calliope.LineBlock(
    #         HOME_LINE(),
    #         )

    # my_melody = melody.Melody(melody_lb,
    #     fabric_staves = ("ooa_trumpet", "cco_trumpet"),
    #     )

    # # TO DO: this doesn't work right... why?
    # # melody_accents = (hit_cells.HitCells(
    # #     melody_lb,
    # #     fabric_staves = ("ooa_horn", "cco_horn"),
    # #     hit_duration = 0.5,
    # #     )
    # #     )
    # melody_accents = melody.Melody(melody_lb,
    #     fabric_staves = ("ooa_horn", "cco_horn"),
    #     )

    # s.extend_from(
    #     counter_winds(),
    #     strings_pulse1(),
    #     strings_low_pulse1,
    #     osti1,
    #     osti1_accents,
    #     my_melody,
    #     melody_accents,
    #     )
    # s.extend_from(
    #     strings_swell1(),
    #     extend_last_machine=True,
    #     )

    # s.fill_rests(fill_to="cco_violin_i")

    # # =======================================================
    # # bars 9-16

    # # =======================================================
    # adjust for bass 8va

    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]
            main_seg.tempo_command = """ \\note #"4" #UP "= 112 ca" """
            for next_seg in list(segs[1:-1]):
                main_seg.extend(next_seg)
                next_seg.parent.remove(next_seg)
            main_seg.rehearsal_mark_number = 13
            main_seg.compress_full_bar_rests = True
Ejemplo n.º 3
0
def score2(lib):
    s = score.ImaginaryScore()
    sb = lib("rock_block2")
    s = sb().annotate(slur_cells=True, label=("phrases", "cells")).to_score(s)

    rim_shots = ImaginaryCell(rhythm=(1, 1, 1, 1), pitches=(2, 2, 2, 2))
    rim_shots.note_events.tag("\\withSlash")

    drum_rhythm2 = lambda_segment.LambdaSegment(
        calliope.SegmentBlock(
            ImaginarySegment(
                lib("rock_rhythm2"),
                get_improv_line(times=8),
                rim_shots,
                get_improv_line(times=6),
                lib("drum_hits") * 3,
            )),
        fabric_staves=("ooa_drum_set", ),
        func=lambda x: x,
    )

    cco_perc1 = osti.Osti(fabric_staves=("cco_percussion", ),
                          osti_pulse_duration=0.5,
                          osti_cell_length=8,
                          osti_cell_count=9,
                          func=lambda x: x.eps(0, "mf")())
    cco_perc2 = lambda_segment.LambdaSegment(
        sb.with_only("high_rhythm"),
        fabric_staves=("cco_percussion", ),
        func=lambda x: x.with_only("cells", 9, 10, 11, 12, 13, 14, 15),
    )
    cco_perc3 = osti.Osti(fabric_staves=("cco_percussion", ),
                          osti_pulse_duration=0.5,
                          osti_cell_length=8,
                          osti_cell_count=3,
                          func=lambda x: x.eps(0, "mf")())
    cco_perc1.note_events.setattrs(pitch=0)
    cco_perc2.note_events.setattrs(pitch=0)
    cco_perc3.note_events.setattrs(pitch=0)
    cco_perc3.cells[-2].note_events[0].tag("\\<")
    cco_perc3.note_events[-1].tag("f")
    s.extend_from(cco_perc1, cco_perc2, cco_perc3)

    riffs_block = short_block.ChordsToSegmentBlock(
        selectable=sb.with_only("riff", ).segments[0],
        sort_chords=True,
    )

    # TO DO: add ranges
    # =======================================================

    trumpet_mute_outs = ImaginarySegment(
        ImaginaryCell(rhythm=(-4, )).eps(0, "mute out")())
    s.staves["ooa_trumpet"].append(trumpet_mute_outs())
    s.staves["cco_trumpet"].append(trumpet_mute_outs())

    harp1_riff = lambda_segment.LambdaSegment(
        sb.with_only("riff", ),
        fabric_staves=("harp1", ),
        tag_events={0: ("mf", )},
        func=lambda x: x,
    )
    harp1_riff.cells[:16].setattrs(respell="sharps")

    # TO DO: model this pattern... already used multiple times!
    poke_harp1 = []
    next_include = False
    for i, e in enumerate(harp1_riff.events):
        e_pitch = e.pitch
        if len(e_pitch) > 1 and abs(e_pitch[0] - e_pitch[1]) == 12:
            next_include = True
            poke_harp1.append(i)
        elif next_include:
            poke_harp1.append(i)
            next_include = False
        else:
            next_include = False
    harp1_riff.segments[0].poke("events", *poke_harp1)

    piano_riff = lambda_segment.LambdaSegment(
        sb.with_only("riff"),
        fabric_staves=(
            "piano1",
            "piano2",
        ),
        tag_all_note_events=(".", ),
        ranges=pitch_ranges.LOW_TO_HIGH_RANGES,
        assign_pitches_from_selectable=True,
        func=lambda x: x.eps(0, "bass")(),
        funcs=(
            lambda x: x.eps(40, "treble")(136, "8va")(151, "8va!")(),
            lambda x: x.eps(0, "8vb")(23, "8vb!")(112, "treble")(),
        ))
    piano_riff.staves["piano1"].note_events[-1].pitch += 12
    piano_riff.staves["piano1"].phrases[:8].apply(lambda x: x.t(12))
    piano_riff.staves["piano2"].phrases[8:].apply(lambda x: x.t(-12))

    pizz = lambda_segment.LambdaSegment(
        sb.with_only("chords"),
        ranges=pitch_ranges.LOW_TO_HIGH_RANGES,
        fabric_staves=instrument_groups.get_instruments("cco_strings"),
        mask_staves=("cco_bass", ),
        assign_pitches_from_selectable=True,
        func=lambda x: x.transformed(calliope.StandardDurations()))
    pizz.staves["cco_viola"].note_events[0].tag("pizz")

    constant_pluck = osti.Osti(
        sb,
        fabric_staves=instrument_groups.get_instruments(
            "ooa_guitar", "ooa_strings"),
        ranges=pitch_ranges.LOW_TO_HIGH_RANGES,
        osti_pulse_duration=1,
        osti_cell_length=4,
        osti_cell_count=9,
    )
    for st in constant_pluck.staves:
        st.segments[0].eps(0, "mf", "pizz, distorted")()

    s.extend_from(
        harp1_riff,
        piano_riff,
        pizz,
        drum_rhythm2,
        constant_pluck,
    )
    # =======================================================

    # BARS 1-6

    opening_bass = lambda_segment.LambdaSegment(
        sb.with_only("bass_line"),
        assign_pitches_from_selectable=True,
        # ranges=pitch_ranges.PitchRanges(pitch_ranges.BOTTOM_SEQ),
        fabric_staves=("ooa_bassoon", "cco_bassoon", "ooa_trombone",
                       "cco_trombone", "ooa_bass_guitar", "cco_bass"),
        # tag_events = {0:("mf", "pizz")},
        # func = lambda x: x.only_first("cells",7).bookend_pad(0,3),
        # func = lambda x: x.crop("cells",1),
        func=lambda x: x.only_first("cells", 14).transformed(
            calliope.StandardDurations()),
        funcs=(
            lambda x: bass_artics(x),
            lambda x: bass_artics(x),
            lambda x: bass_artics(x.poke("cells", 7, 8, 10, 11)),
            lambda x: bass_artics(x.poke("cells", 7, 8, 10, 11)),
            lambda x: x,
            lambda x: x.eps(1, "pizz")(),
        ))
    for st in opening_bass.staves:
        st.note_events[0].tag("f")

    s.extend_from(opening_bass, )

    # # =======================================================
    wind_cloud_4_5 = lambda_segment.LambdaSegment(
        lib("rock_grid_g2_c4_5"),
        fabric_staves=(
            "ooa_flute",
            "cco_flute1",
            "cco_flute2",
            "ooa_clarinet",
            "cco_clarinet1",
            "cco_clarinet2",
        ),
        # tag_events = {0:("mp", "\\<",), 7:("mf",)},
        # assign_pitches_from_selectable = True,
        # selectable_start_beat = 16*4,
        # func = lambda x: x.slur_cells().bookend_pad(2,3),
        # func = lambda x: x.crop("cells",1),
        bookend_beats=(7, 0),
        tag_all_note_events=("-", ),
        tag_events={
            0: ("mp", "\\<"),
            -1: (".", "f")
        },
        func=lambda x: x,
    )
    sax_opening_driving = driving_off.DrivingOff(
        sb,
        ranges=pitch_ranges.HIGH_TO_LOW_RANGES,
        fabric_staves=instrument_groups.get_instruments("sax", ),
        bookend_beats=(6, 3),
    )

    s.extend_from(
        wind_cloud_4_5,
        sax_opening_driving,
    )

    s.fill_rests(beats=7 * 4)
    # # =======================================================
    cloud_16_17 = lib("rock_grid_g2_c16_17")
    wind_cloud_16_17 = lambda_segment.LambdaSegment(
        cloud_16_17,
        fabric_staves=(
            "ooa_flute",
            "ooa_clarinet",
            "ooa_alto_sax1",
            "ooa_alto_sax2",
            "ooa_tenor_sax",
            "ooa_bari_sax",
        ),
        tag_all_note_events=("-", ),
        tag_events={
            1: ("mp", "\\<"),
            -1: (".", "f")
        },
        func=lambda x: x.bookend_pad(3, 0),
    )
    brass_midpoint_driving = driving_off.DrivingOff(
        sb,
        selectable_start_beat=(7 * 4),
        ranges=pitch_ranges.MID_RANGES,
        fabric_staves=instrument_groups.get_instruments("brass", ),
        bookend_beats=(2, 0),
    )

    s.extend_from(
        wind_cloud_16_17,
        brass_midpoint_driving,
    )

    s.fill_rests(beats=9 * 4)
    # # =======================================================
    # BAR 10+
    # # =======================================================
    mallets_improv1 = improv.Improv(
        sb,
        fabric_staves=("ooa_mallets", ),
        improv_times=3,
        ranges=pitch_ranges.HIGHISH_RANGES,
        selectable_start_beat=9 * 4,
        # pitch_selectable_indices = (
        #     (0,1,3,5),
        #     ),
    )
    mallets_improv2 = improv.Improv(
        sb,
        instruction="",
        fabric_staves=("ooa_mallets", ),
        improv_times=4,
        ranges=pitch_ranges.HIGHISH_RANGES,
        selectable_start_beat=12 * 4,
        # pitch_selectable_indices = (
        #     (0,2,4,5),
        #     ),
    )
    mallets_improv3 = improv.Improv(
        sb,
        instruction="",
        fabric_staves=("ooa_mallets", ),
        improv_times=3,
        ranges=pitch_ranges.HIGHISH_RANGES,
        selectable_start_beat=16 * 4,
        # pitch_selectable_indices = (
        #     (0,2,4,5),
        #     ),
    )
    s.extend_from(mallets_improv1, mallets_improv2, mallets_improv3)

    flute_high_swells = staggered_swell.StaggeredSwells(
        sb,
        low_dynamic="mp",
        swell_dynamic="mf",
        cell_count=1,
        phrase_count=5,
        swell_duration=8,
        selectable_start_beat=9 * 4,
        # swell_split_ratios = (
        #     1/2,
        #     )
        swell_staggers=(
            (0, 4),
            (2, 2),
            (3, 1),
            # (0.5,0.5),
            # (1,0)
        ),
        fabric_staves=(
            "cco_flute1",
            "cco_flute2",
            "ooa_flute",
        ),
    )
    s.extend_from(flute_high_swells, )

    s.fill_rests(beats=12 * 4)
    # # =======================================================
    cloud_26_31 = lib("rock_grid_g2_c26_31")
    wind_cloud_26_31 = lambda_segment.LambdaSegment(
        cloud_26_31,
        fabric_staves=(
            "ooa_clarinet",
            "ooa_alto_sax1",
            "ooa_alto_sax2",
            "ooa_tenor_sax",
            "ooa_bari_sax",
            "ooa_bassoon",
        ),
        tag_all_note_events=("-", ),
        tag_events={
            0: ("mf", "\\<"),
            -1: (".", "f")
        },
        bookend_beats=(3, 1))

    s.extend_from(wind_cloud_26_31, )

    # # =======================================================
    # BAR 16+
    # s.fill_rests(beats=15*4)

    hits_final = lambda_segment.LambdaSegment(
        sb.with_only("chords"),
        ranges=pitch_ranges.HIGHISH_TO_MID_RANGES,
        fabric_staves=instrument_groups.get_instruments(
            "ooa_brass", "ooa_strings") + ("ooa_guitar", "ooa_bass_guitar"),
        assign_pitches_from_selectable=True,
        selectable_start_beat=15 * 4,
        func=lambda x: x.with_only("cells", 32, 33).bookend_pad(3, 1),
        tag_all_note_events=(">", ))
    for st in hits_final.staves["ooa_violin1", "ooa_violin2", "ooa_cello1",
                                "ooa_cello2"]:
        st.note_events[0].tag("arco, distorted")
    s.extend_from(hits_final)

    s.fill_rests(beats=16 * 4)
    strings_improv = improv.Improv(
        sb.with_only("high_drones"),
        fabric_staves=instrument_groups.get_instruments("ooa_strings", ),
        improv_times=3,
        ranges=pitch_ranges.HIGHISH_RANGES,
        selectable_start_beat=16 * 4,
    )
    s.extend_from(strings_improv)

    # # =======================================================
    # adjust for bass 8va
    for bass_seg in s.staves["cco_bass"].segments:
        bass_seg.transformed(calliope.Transpose(interval=12))

    s.fill_rests()
    # s.remove(s.staff_groups["short_score"])

    for staff in s.staves:
        # staff.phrases.transformed(calliope.Label())
        # staff.lines.transformed(calliope.Label())
        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 = 8
            main_seg.compress_full_bar_rests = True
Ejemplo n.º 4
0
def score0(lib):
    s = score.ImaginaryScore()
    sb = lib("integrate_block0")

    s = sb().annotate(slur_cells=True, label=("cells", )).to_score(s)

    # s.extend_from(
    #     # TO DO: re-add harp and piano
    #     # my_harp(),
    #     # my_piano(),
    #     # lib("integrate0_strings_counter_score"),
    #     # lib("integrate0_winds_counter_broken_score"),
    #     # lib("integrate0_cello_pad_score"),
    #     )

    s.extend_from(
        pizz_flutter.PizzFlutter(
            sb,
            # ranges=pitch_ranges.MID_RANGES,
            # selectable_start_beat = 0,
            pizz_flutter_initial=
            True,  # if True then will add pizz and f.t. indications
            pizz_flutter_beats=8,
            bookend_beats=(0, 1),
            mask_staves=("cco_bass", ),
            pizz_dynamic="mf",
            flutter_dynamic="p",
        ))
    s.extend_from(
        pizz_flutter.PizzFlutter(
            sb,
            ranges=pitch_ranges.MID_RANGES,
            # selectable_start_beat = 0,
            pizz_flutter_beats=7,
            mask_staves=("cco_bass", )),
        extend_last_machine=True)
    # (make the guitars quiter)
    for st in s.staves["ooa_guitar", "ooa_bass_guitar"]:
        st.note_events[0].tag("mp")

    drum_set = ImaginarySegment(
        ImaginaryCell(rhythm=(-4 * 4, )),
        lib("drum_off_short").eps(
            0,
            "p",
        )(),
        get_improv_line(rhythm=(1, ) * 4, times=8),
        lib("drum_du_du").eps(0, "mp", "\\<")(13, "mf")(),
    )
    s.staves["ooa_drum_set"].append(drum_set)

    mallets = pad.Pad(
        sb.with_only("high_drones"),
        fabric_staves=("ooa_mallets", ),
        pad_durations=(4, ) * 10,
        tag_all_note_events=(":32", ),
        bookend_beats=(4 * 4, 0),
        after_func=lambda x: x.eps(
            0,
            "p",
        )(),
    )
    s.extend_from(mallets)

    bass_accent_es = (2, 5, 12, 15, 28, 36)
    bass_accent_es2 = (1, 4, 8, 14, 17)

    bassoon_undo = lambda_segment.LambdaSegment(
        sb.with_only("bass_line", ),
        fabric_staves=("cco_bassoon", ),
        func=lambda x: x.only_first("cells", 11).crop_chords(indices=(-1, )).
        eps(0, "mf")(1, 6, 11, 14, 17, 21, 27, 30, 31, 33, 35, 38, "-")
        (*bass_accent_es, ".", ">")(3, 7, 9, 18, 22, 24, 39, 41, "(")
        (4, 8, 10, 19, 23, 25, 40, 42, ")")())
    bassoon_undo2 = lambda_segment.LambdaSegment(
        sb.with_only("bass_line", ),
        fabric_staves=("ooa_bassoon", ),
        func=lambda x: x.only_last("cells", 5).crop_chords(indices=(-1, )).eps(
            0, 3, 10, 16, "-")(*bass_accent_es2, ".", ">")(6, 11, "(")
        (7, 13, ")")())
    tenor_highlights = lambda_segment.LambdaSegment(
        sb.with_only("bass_line", ),
        fabric_staves=("ooa_tenor_sax", ),
        func=lambda x: x.poke("events", *bass_accent_es).crop_chords(indices=(
            -1, )).smear_after(extend_beats=3).eps(2, "p")())
    basson_highlights = lambda_segment.LambdaSegment(
        sb.with_only("bass_line", ),
        fabric_staves=("ooa_bassoon", ),
        func=lambda x: x.only_first("cells", 11).poke(
            "events", *bass_accent_es).crop_chords(indices=(-1, )).
        smear_before(extend_beats=3, rearticulate=True).ops("note_events")
        (0, 2, 4, 6, 8, 10, "p", "\\<")(1, 3, 5, 7, 9, 11, "mf", ".")())
    bass_line = lambda_segment.LambdaSegment(
        sb.with_only("bass_line", ),
        fabric_staves=("cco_bass", "cco_percussion"),
        funcs=(
            lambda x: x.crop_chords(indices=(0, )).t(12).eps(1, "pizz", "mf")
            (),
            lambda x: x.only_first("cells", 6).crop_chords(indices=(
                0, 1)).smart_ranges(
                    ((-15, -4), )
                    # ).label("events"
                ).poke("events", 1, 4, 5, 11, 15, 18, 19).e_smear_after(
                    1, 11, fill=True).bookend_pad(0, 3).eps(
                        0, "\\timpStaff", "timpani")(1, 9, "pp", "\\<")
            (3, 10, "mp")(1, 9, ":32")()))

    harp = lambda_segment.LambdaSegments(
        sb.with_only("riff", ),
        fabric_staves=("harp1", "harp2"),
        funcs=(
            lambda x: x.crop("cells", 1).t(12).transformed(
                calliope.StandardDurations()).eps(0, "mf")(),
            lambda x: x.crop("cells", 1).transformed(
                calliope.StandardDurations()).t(-12).eps()(),
        ),
        bookend_beats=(4, 0),
    )
    guitars = osti.Osti(sb.with_only("bass_drones"),
                        fabric_staves=(
                            "ooa_bass_guitar",
                            "ooa_guitar",
                        ),
                        ranges=pitch_ranges.MID_RANGES,
                        osti_pulse_duration=1,
                        osti_cell_length=10,
                        osti_cell_count=4,
                        after_func=lambda x: x.eps(0, "disorted")())
    sax_counter = lambda_segment.LambdaSegment(
        sb.with_only("melody_line1"),
        fabric_staves=("ooa_alto_sax1", ),
        func=lambda x: x.transformed(artics.FuseRepeatedNotes()).slur_cells(
        ).eps(1, "mp")())
    s.extend_from(
        bass_line,
        bassoon_undo,
        tenor_highlights,
        basson_highlights,
        bassoon_undo2,
        guitars,
        harp,
        sax_counter,
    )
    cym_line = ImaginaryLine(
        ImaginaryCell(rhythm=(1, -3), ).eps(0, ":32", "p", "sus. cym.",
                                            "\\percStaff", "(")(1, ")")(),
        ImaginaryCell(rhythm=(-4 * 8, ), ),
        ImaginaryCell(rhythm=(4, ), ).eps(0, ":32", "mp", "(sus. cym.)")(),
    )
    s.staves["cco_percussion"].segments[-1].append(cym_line)

    s.fill_rests(5 * 4)

    bari_improv = improv.Improv(sb,
                                fabric_staves=("ooa_bari_sax", ),
                                improv_times=5,
                                ranges=pitch_ranges.MID_RANGES,
                                selectable_start_beat=5 * 4,
                                pitch_selectable_indices=((0, 2, 5), ),
                                dynamic="pp")
    bari_improv.note_events[0].tag("\\<")
    bari_improv.note_events[9].tag("mp")
    s.extend_from(bari_improv)

    oboe_swells = staggered_swell.StaggeredSwells(
        sb.with_only("mid_drones"),
        fabric_staves=("cco_oboe1", "cco_oboe2", "cco_flute1", "cco_flute2"),
        ranges=pitch_ranges.MID_TO_HIGHISH_RANGES,
        selectable_start_beat=5 * 4,
        swell_duration=8,
        # cell_count=2,
        # phrase_count=2,
    )

    s.extend_from(oboe_swells)

    s.fill_rests(beats=8 * 4)
    clarinet_highlights = lambda_segment.LambdaSegments(
        sb.with_only("bass_line", ),
        fabric_staves=(
            "cco_clarinet1",
            "cco_clarinet2",
        ),
        funcs=(
            lambda x: x.only_last("cells", 5).poke("events", *bass_accent_es2).
            crop_chords(indices=(-1, )).smear_before(
                extend_beats=3, rearticulate=True).ops("note_events")
            (0, 2, 4, 6, 8, "p", "\\<")(1, 3, 5, 7, 9, "mf", ".")
            (), lambda x: x.only_last("cells", 5).poke(
                "events", *bass_accent_es2).crop_chords(indices=(
                    -1, )).smear_after(extend_beats=3).eps(1, "p")()))
    s.extend_from(clarinet_highlights, )

    s.fill_rests(beats=10 * 4)
    brass_improv1 = improv.Improv(sb,
                                  fabric_staves=("ooa_horn", "ooa_trumpet",
                                                 "ooa_trombone"),
                                  improv_times=1,
                                  ranges=pitch_ranges.MID_RANGES,
                                  selectable_start_beat=10 * 4,
                                  pitch_selectable_indices=((0, 2, 4), ),
                                  dynamic="p")
    brass_improv2 = improv.Improv(
        sb,
        instruction="",
        fabric_staves=("ooa_horn", "ooa_trumpet", "ooa_trombone"),
        improv_times=2,
        ranges=pitch_ranges.MID_RANGES,
        selectable_start_beat=11 * 4,
        pitch_selectable_indices=((0, 2, 4), ),
        # dynamic="p"
    )
    s.extend_from(brass_improv1, brass_improv2)

    s.fill_rests()

    # s.lines.apply(lambda x:x.auto_respell())
    # s.phrases.apply(lambda x:x.auto_respell())
    # s.as_rhythm_and_short()
    # s.remove(s.staff_groups["short_score"])

    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 = 10
            main_seg.compress_full_bar_rests = True
Ejemplo n.º 5
0
def score3(lib):
    s = score.ImaginaryScore()
    sb = lib("integrate_block3")

    s = sb().annotate(slur_cells=True, label=("phrases", "cells")).to_score(s)

    drum_set = ImaginarySegment(
        lib("drum_quick_off2").eps(0, "mp")(),
        get_improv_line(rhythm=(1, ) * 4, times=6),
        lib("drum_du_du").eps(0, "\\<")(),
        lib("drum_rock_out").eps(0, "mf")(),
        get_improv_line(rhythm=(1, ) * 4, times=5),
        get_improv_line(instruction="improv", rhythm=(0.5, ) * 8, times=2),
    )
    s.staves["ooa_drum_set"].append(drum_set)

    # # ================================================
    # # STARTING IMPROV
    improv_winds1 = improv.Improv(
        sb,
        fabric_staves=("ooa_flute", "ooa_clarinet", "ooa_alto_sax1",
                       "ooa_alto_sax2"),
        improv_times=7,
        # selectable_start_beat=12*4,
        ranges=pitch_ranges.MID_RANGES,
        dynamic="mp")
    improv_winds2 = improv.Improv(sb,
                                  fabric_staves=("ooa_tenor_sax",
                                                 "ooa_bari_sax",
                                                 "ooa_bassoon"),
                                  improv_times=4,
                                  selectable_start_beat=3 * 4 + 2,
                                  bookend_beats=(3 * 4, 0),
                                  ranges=pitch_ranges.TOP_RANGES,
                                  pitch_selectable_indices=(
                                      (1, 3, 4),
                                      (0, 2, 5),
                                  ),
                                  dynamic="mp")
    improv_winds3 = improv.Improv(sb,
                                  fabric_staves=("ooa_horn", "ooa_trumpet",
                                                 "ooa_trombone"),
                                  improv_times=2,
                                  selectable_start_beat=5 * 4,
                                  bookend_beats=(5 * 4, 0),
                                  ranges=pitch_ranges.TOP_RANGES,
                                  pitch_selectable_indices=((0, 1, 3, 4), ),
                                  dynamic="mp")
    s.extend_from(
        improv_winds1,
        improv_winds2,
        improv_winds3,
    )

    counter_me = lambda_segment.LambdaSegments(
        sb.with_only("counter_line"),
        fabric_staves=(
            "cco_flute1",
            "cco_flute2",
            "ooa_mallets",
            "harp1",
            # "harp2",
            "cco_oboe1",
            "cco_oboe2",
            "cco_clarinet1",
            "cco_clarinet2",
        ),
        func=lambda x: x.crop("cells", 0, 12),
        funcs=(
            lambda x: x.only_first("cells", 16).eps()(),
            lambda x: x.only_first("cells", 16).eps()(),
            lambda x: x.transformed(
                calliope.StandardDurations(
                    min_duration=0.25,
                    standard_duration=0.5,
                )).eps(0, "mf")(),
            lambda x: x.poke("events", 0, 2, 5, 7, 8, 14, 21, 23, 24, 28, 30,
                             31).smear_after(min_beats=1, ).stack_p([(0, -12)])
            .transformed(calliope.StandardDurations()).eps(0, "mf")(),
            # lambda x:x.poke("events",0,2,5,7,8,14,21,23,24,28,30,31).smear_after(
            #     min_beats=1,
            #     ).transformed(
            #     calliope.StandardDurations()
            #     ).t(-12)(),
            lambda x: x.poke(
                "events",
                0,
                5,
                14,
                23,
                28,
            ).smear_before(
                extend_beats=2,
                gap_beats=0.5,
                rearticulate=True,
            ).smear_after(min_beats=1, ).ops("note_events")
            (0, 2, 4, 6, 8, "mf", ".")(1, 3, 5, 7, 9, "mp", "\\<")(),
            lambda x: x.poke(
                "events",
                2,
                7,
                21,
                25,
                30,
            ).smear_after(min_beats=1, ).smear_before(
                extend_beats=2,
                gap_beats=0.5,
                rearticulate=True,
            ).ops("note_events")(0, 2, 4, 6, 8, "mp", "\\<")
            (1, 3, 5, 7, 9, "mf", ".")(),
            lambda x: x.poke(
                "events",
                0,
                5,
                14,
                23,
                28,
            ).smear_before(
                extend_beats=2,
                gap_beats=0.5,
                rearticulate=True,
            ).smear_after(min_beats=1, ).ops("note_events")
            (0, 2, 4, 6, 8, "mf", ".")(1, 3, 5, 7, 9, "mp", "\\<")(),
            lambda x: x.poke(
                "events",
                2,
                7,
                21,
                25,
                30,
            ).smear_after(min_beats=1, ).smear_before(
                extend_beats=2,
                gap_beats=0.5,
                rearticulate=True,
            ).ops("note_events")(0, 2, 4, 6, 8, "mp", "\\<")
            (1, 3, 5, 7, 9, "mf", ".")(),
        ))
    for fi, f in enumerate(counter_me.staves("cco_flute1", "cco_flute2")):
        for i, c in enumerate(f.cells):
            if i % 2 == fi:
                c.poke("events", 0).ops("note_events")(0, ".")()
            else:
                c.note_events[:-1].tag("-")
                c.note_events[-1:].tag(".")
        f.transformed(
            calliope.StandardDurations(
                min_duration=0.25,
                standard_duration=0.5,
            ))

    flourish_flutes = osti.Osti(sb,
                                fabric_staves=("cco_flute1", "cco_flute2"),
                                ranges=pitch_ranges.LOW_TO_HIGH_RANGES,
                                selectable_start_beat=9 * 4,
                                osti_pulse_duration=0.5,
                                osti_cell_length=8,
                                osti_cell_count=1,
                                after_func=lambda x: x.eps(0, "\\<", "(")())
    for st in flourish_flutes.staves:
        st.segments[0].fuse()
        st.segments[0].note_events[-1].tag(")")

    # flutes.slur_cells()
    # violins_melody = lambda_segment.LambdaSegment(
    #     sb.with_only("mid_drones"),
    #     fabric_staves = ("cco_violin_i",),
    #     func = lambda x: x.eps(
    #         1, "mf")(
    #         1,5,9,11,13,16,21,23,26,28,30,33,36,40,44,46,48,51,56)(
    #         ).annotate(label=("events",)),
    #     )

    cellos_horns_melody = lambda_segment.LambdaSegment(
        sb.with_only("mid_drones"),
        fabric_staves=("cco_cello", "cco_horn"),
        func=lambda x: x.eps(1, "mf")(5, 9, 11, 16, 21, 26, 31, 33, "(")
        (6, 10, 12, 17, 22, 27, 32, 34, ")")
        ().crop("cells", 0, 4).t(-12),  #.annotate(label=("events",)),
    )
    for st in cellos_horns_melody.staves:
        for n in st.note_events[2, 5, 10]:
            n.pitch += 12

    violins_end_melody = lambda_segment.LambdaSegment(
        sb.with_only("mid_drones"),
        fabric_staves=(
            "cco_flute1",
            "cco_flute2",
            "cco_violin_i",
            "cco_violin_ii",
        ),
        func=lambda x: x.eps(1, "mf")(5, 9, 11, 16, 21, 26, 31, 33, "(")
        (6, 10, 12, 17, 22, 27, 32, 34, ")")
        ().crop("cells", 4).crop("events", 3).e_smear_before(
            1,
            extend_beats=0.25,
            cover_notes=True,
        ).e_smear_before(
            6,
            extend_beats=0.25,
            cover_notes=True,
        ).t(12).eps(1, 6, ">")(),  #.annotate(label=("events",)),
    )
    for st in violins_end_melody.staves:
        st.note_events[0].pitch += 12
        st.note_events[0].tag("f")

    constant_pluck = osti.Osti(
        sb,
        fabric_staves=instrument_groups.get_instruments("ooa_strings") +
        ("ooa_guitar", "ooa_bass_guitar"),
        ranges=pitch_ranges.HIGHISH_TO_LOW_RANGES,
        bookend_beats=(4, 0),
        osti_pulse_duration=0.5,
        osti_cell_length=8,
        osti_cell_count=9,
        after_funcs=(
            lambda x: x.mask("cells", 0, 1, 2, 3).eps(8 * 4, "mp",
                                                      "pizz, distorted")(),
            lambda x: x.mask("cells", 0, 1, 2, 3).eps(8 * 4, "mp",
                                                      "pizz, distorted")(),
            lambda x: x.mask("cells", 0, 1).eps(8 * 2, "mp", "pizz, distorted")
            (),
            lambda x: x.mask("cells", 0, 1).eps(8 * 2, "mp", "pizz, distorted")
            (),
            lambda x: x.eps(0, "mp", "distorted")(),
            lambda x: x.eps(0, "mp", "distorted")(),
        ))
    constant_pluck2 = osti.Osti(
        sb,
        fabric_staves=instrument_groups.get_instruments("ooa_strings") +
        ("ooa_guitar", "ooa_bass_guitar"),
        ranges=pitch_ranges.LOW_TO_HIGH_RANGES,
        selectable_start_beat=10 * 4,
        osti_pulse_duration=1,
        osti_cell_length=4,
        osti_cell_count=6,
        after_func=lambda x: x.eps(
            0,
            "mf",
        )())
    for st in constant_pluck2.staves:
        if st.name in instrument_groups.get_instruments("ooa_strings"):
            st.note_events[0].tag("arco")
            st.note_events.tag(".")

    measured_trems = osti.Osti(
        sb,
        fabric_staves=("cco_violin_i", "cco_violin_ii", "cco_viola"),
        ranges=pitch_ranges.LOW_TO_HIGHISH_RANGES,
        osti_pulse_duration=0.5,
        osti_cell_length=8,
        osti_cell_count=9,
        tag_all_note_events=(":16", ),
        after_funcs=(
            lambda x: x.mask("cells", 0, 1).ops("cells")(7, "\\<")
            ().ops("note_events")(
                0,
                "mp",
            )(),
            lambda x: x.mask("cells", 0, 1, 2, 3).ops("cells")(7, "\\<")
            ().ops("note_events")(
                0,
                "mp",
            )(),
            lambda x: x.ops("note_events")(
                0,
                "mp",
            )().ops("cells")(7, "\\<")()(),
        ))

    measured_trems2 = osti.Osti(
        sb,
        fabric_staves=("cco_viola", "cco_cello"),
        ranges=pitch_ranges.HIGH_TO_LOW_RANGES,
        osti_pulse_duration=0.5,
        osti_cell_length=8,
        osti_cell_count=8,
        selectable_start_beat=8 * 4,
        tag_all_note_events=(":16", ),
    )
    measured_trems2.staves["cco_viola"].segments[0].crop("cells", 1)
    measured_trems2.staves["cco_viola"].note_events[0].tag("mf")

    sax_melody = lambda_segment.LambdaSegment(
        sb.with_only("high_drones"),
        fabric_staves=instrument_groups.get_instruments(
            "ooa_winds",
            "sax",
            "ooa_brass",
        ),
        func=lambda x: x.crop("cells", 4).slur_cells().ops("note_events")
        (0, "mf")(),
        bookend_beats=(4, 0),
        funcs=(
            lambda x: x.t(12),  #fl
            lambda x: x,  #cl
            lambda x: x.t(-24),  #bsn
            lambda x: x,  #as
            lambda x: x.t(-5),  #as
            lambda x: x.t(-12),  #ts
            lambda x: x.t(-24),  #bs
            lambda x: x.t(-12),  #hn
            lambda x: x.t(-12),  #tpt
            lambda x: x.t(-17),  #tbn
        ))

    cco_wind_melodies = lambda_segment.LambdaSegment(
        sb.with_only("melody_line1", "melody_line2"),
        fabric_staves=(
            "cco_oboe1",
            "cco_oboe2",
            "cco_clarinet1",
            "cco_clarinet2",
        ),
        func=lambda x: x.with_only("cells", 10, 11, 12, 13, 14, 15).slur_cells(
        ).eps(1, "mf")())

    bass_pulse = osti.Osti(sb.with_only("bass_drones"),
                           fabric_staves=("cco_bass", "cco_percussion"),
                           ranges=pitch_ranges.MID_TO_LOW_RANGES,
                           osti_pulse_duration=1,
                           osti_cell_count=16,
                           osti_cell_length=4,
                           after_funcs=(
                               lambda x: x.eps(0, "mp")(28, "\\<")(36, "mf")(),
                               lambda x: x.mask("cells", 0, 1).eps(
                                   8, "mp", "timpani", "\\timpStaff")(),
                           ))
    bass_pulse.segments[0].smart_ranges([(-19, -6)])

    end_doves = x = dovetail.Dovetail(
        sb,
        fabric_staves=("cco_horn", "cco_trumpet", "cco_trombone",
                       "cco_bassoon"),
        ranges=pitch_ranges.LOW_TO_HIGH_RANGES,
        selectable_start_beat=10 * 4,
        tag_all_note_events=("."),
        # dove_count = 4,
        # dove_event_count = 4,
        # tail_event_count = 1,
        dovetail_duration=24,
        # event_duration = 0.5,
        offset=3,
        after_func=lambda x: x.ops("note_events")(0, "mf")())
    for n in end_doves.staves["cco_horn"].note_events[:7]:
        n.pitch += 12

    end_osti = osti.Osti(sb,
                         fabric_staves=("harp1", "harp2", "piano1", "piano2"),
                         ranges=pitch_ranges.HIGHISH_TO_MID_RANGES,
                         selectable_start_beat=10 * 4,
                         osti_pulse_duration=0.5,
                         osti_cell_length=8,
                         osti_cell_count=6,
                         tag_all_note_events=(">"),
                         after_funcs=(
                             lambda x: x.eps(0, "mf")(),
                             lambda x: x,
                             lambda x: x.eps(0, "mf")(),
                             lambda x: x,
                         ))
    end_osti.staves["piano2"].segments[0].t(-12)

    end_roll = pad.Pad(sb.with_only("bass_drones"),
                       fabric_staves=("ooa_mallets", ),
                       ranges=pitch_ranges.HIGHISH_RANGES,
                       selectable_start_beat=10 * 4,
                       pad_durations=(8, 16),
                       after_func=lambda x: x.eps(0, "mf", "\\<", ":32")
                       (1, "f", ":32")())

    s.extend_from(
        counter_me,
        # trumpets_melody,
        # clarinets_melody,
        cellos_horns_melody,
        constant_pluck,
        constant_pluck2,
        bass_pulse,
        measured_trems,
        flourish_flutes,
        violins_end_melody,
        sax_melody,
        measured_trems2,
        extend_last_machine=True)
    s.fill_rests(beats=10 * 4)
    s.extend_from(cco_wind_melodies, end_doves, end_osti, end_roll)

    # trumpets_melody = lambda_segment.LambdaSegment(
    #     sb.with_only("melody_line2"),
    #     fabric_staves = ("ooa_trumpet","cco_trumpet"),
    #     func = lambda x: x.eps(
    #         # 5,9,11,16,21,26,31,33, "(")(
    #         # 6,10,12,17,22,27,32,4, ")")(
    #         ).slur_cells(),#.annotate(label=("events",)),
    #     )
    # clarinets_melody = lambda_segment.LambdaSegment(
    #     sb.with_only("melody_line1"),
    #     fabric_staves = ("ooa_clarinet","cco_clarinet1","cco_clarinet2"),
    #     func = lambda x: x.eps(
    #         1, "mf")(
    #         # 5,9,11,16,21,26,31,33, "(")(
    #         # 6,10,12,17,22,27,32,4, ")")(
    #         ).slur_cells(),#.annotate(label=("events",)),
    #     )

    # my_piano = sus_piano.SusPiano1(
    #     sus_duration=8*4,
    #     accents = (
    #         (0, 3, 6, 8, 10, 12),
    #         (0, 2,),
    #         )
    #     )

    # my_harp = sus_piano.SusPiano1(
    #     sus_duration=8*4,
    #     fabric_staves = ("harp1", "harp2",),
    #     accents = (
    #         (0, 3, 6, 8, 10, 12),
    #         (0, 2,),
    #         )
    #     )
    # strings_counter = melody.Melody(
    #     calliope.LineBlock(
    #         COUNTER_LINE_1(),
    #         ),
    #     fabric_staves = ("cco_violin_i", "cco_violin_ii", "cco_viola",)
    #     )

    # counter_line_broken = COUNTER_LINE_1()
    # print(counter_line_broken)
    # counter_line_broken.transformed(calliope.Poke(
    #     selection=counter_line_broken.note_events[0,1, 2,3,5,6,7,8]
    #     ))

    # # TO DO: continue this shaping
    # winds_counter_broken = melody.Melody(
    #     calliope.LineBlock(
    #         counter_line_broken,
    #         ),
    #     fabric_staves = ("cco_clarinet1","cco_clarinet2")
    #     )

    # # TO DO: need pitches:
    # cello_pad = pad.Pad(
    #     fabric_staves = ("cco_cello",),
    #     pad_durations = (4,)*8
    #     )

    # pop_fizz1 = pizz_flutter.PizzFlutter(
    #     pizz_flutter_initial = True,
    #     pizz_flutter_beats = 3,
    #     mask_staves = ("harp1", "harp2"),
    #     )
    # pop_fizz2 = pizz_flutter.PizzFlutter(
    #     pizz_flutter_beats = 3,
    #     mask_staves = ("harp1", "harp2"),
    #     bookend_beats = (0,2)
    #     )

    # s.extend_from(
    #     my_harp,
    #     my_piano,
    #     pop_fizz1,
    #     )
    # s.extend_from(
    #     pop_fizz2,
    #     extend_last_machine = True,
    #     )
    # s.fill_rests()

    # =======================================================
    # bars 9-16

    # s.extend_from(
    #     my_harp(),
    #     my_piano(),
    #     strings_counter,
    #     winds_counter_broken,
    #     cello_pad,
    #     )

    s.lines.setattrs(respell="flats")
    s.phrases.setattrs(respell="flats")
    s.fill_rests()

    # # =======================================================
    # adjust for bass 8va
    # for bass_seg in s.staves["cco_bass"].segments:
    #     bass_seg.transformed(calliope.Transpose(interval=12))

    # s.as_rhythm_and_short()
    # s.remove(s.staff_groups["short_score"])

    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]
            main_seg.tempo_command = """ Gradual Accel. ... """
            for next_seg in list(segs[1:]):
                main_seg.extend(next_seg)
                next_seg.parent.remove(next_seg)
            main_seg.rehearsal_mark_number = 14
            main_seg.compress_full_bar_rests = True
Ejemplo n.º 6
0
def score5(lib):
    s = score.ImaginaryScore()
    sb = lib("integrate_block5")
    s = sb().annotate(slur_cells=True, label=("phrases", "cells")).to_score(s)

    strings_pulse1 = pulse.Pulse(
        sb,
        fabric_staves=("ooa_violin1", "ooa_violin2", "ooa_cello1",
                       "ooa_cello2", "cco_violin_i", "cco_violin_ii",
                       "cco_viola"),
        pulse_beats=26,
        tag_all_note_events=(".", ),
    )

    strings_swell1 = swell_hit.SwellHit(
        sb,
        fabric_staves=("ooa_violin1", "ooa_violin2", "ooa_cello1",
                       "ooa_cello2", "cco_violin_i", "cco_violin_ii",
                       "cco_viola"),
        swell_duration=5.5,
        hit_rest=0,
    )

    low_pulse1 = pulse.Pulse(
        sb.with_only("bass_drones"),
        fabric_staves=("ooa_bass_guitar", "ooa_guitar", "cco_cello",
                       "cco_bass"),
        pulse_duration=1,
        pulse_beats=29,
        bookend_beats=(0, 3),
    )
    low_pulse1.staves["cco_cello", "cco_bass"].note_events.tag(".")

    sax_melody = lambda_segment.LambdaSegments(
        sb.with_only("mid_drones"),
        fabric_staves=("ooa_alto_sax1", "ooa_alto_sax2", "ooa_tenor_sax"),
        # bookend_beats=(0,0),
        funcs=(
            lambda x: x.slur_cells().eps(1, "mf")(),
            lambda x: x.slur_cells().eps(1, "mf")(),
            lambda x: x.slur_cells().t(-12).eps(1, "mf")(),
        ),
    )
    srings_fast = osti.Osti(
        sb,
        fabric_staves=instrument_groups.get_instruments("strings"),
        ranges=pitch_ranges.LOW_TO_HIGH_RANGES,
        selectable_start_beat=8 * 4,
        osti_pulse_duration=0.25,
        osti_cell_length=16,
        osti_cell_count=8,
    )
    vibraphone_riff = lambda_segment.LambdaSegment(
        sb.with_only("riff"),
        fabric_staves=("ooa_mallets", ),
        func=lambda x: x,
    )

    s.extend_from(strings_pulse1, )
    s.extend_from(
        strings_swell1(),
        extend_last_machine=True,
    )
    s.extend_from(low_pulse1, )
    s.extend_from(
        # counter_winds(),
        # strings_pulse1,
        # strings_low_pulse1,
        sax_melody,
        vibraphone_riff,
        # osti1,
        # driving_sax,
        # my_melody,
        # melody_accents,
        # bass_line,
    )
    s.extend_from(srings_fast)

    # s.extend_from(
    #     strings_swell1(),
    #     extend_last_machine=True,
    #     )

    # TO DO: consider bringing some of this back
    # counter_winds = ditto.Ditto(
    #     calliope.LineBlock(
    #         COUNTER_LINE_1(),
    #         COUNTER_LINE_2(),
    #         ),
    #     fabric_staves = ("ooa_flute", "ooa_clarinet",
    #         "cco_flute1", "cco_flute2",
    #         "cco_clarinet1", "cco_clarinet2")
    #     )

    # osti_lb = rock.OstiLineBlock(
    #     phrase_count=7,
    #     cuts = (
    #         dict(crop=(0,6)),
    #         dict(crop=(0,6)),
    #         dict(crop=(0,6)),
    #         dict(crop=(2,0)),
    #         ),
    #     slur_cells = True,
    #     )

    # osti1 = ditto.Ditto(osti_lb,
    #     fabric_staves = ("ooa_bassoon", "cco_oboe1", "cco_oboe2", "cco_bassoon")
    #     )

    # osti1_accents = hit_cells.HitCells(osti_lb,
    #     fabric_staves = instrument_groups.get_instruments("sax"),
    #     mask_staves = ("ooa_bari_sax"),
    #     )

    # TO DO: move to lyrical section
    # melody_lb = calliope.LineBlock(
    #         HOME_LINE(),
    #         )

    # my_melody = melody.Melody(melody_lb,
    #     fabric_staves = ("ooa_trumpet", "cco_trumpet"),
    #     )

    # TO DO: this doesn't work right... why?
    # melody_accents = (hit_cells.HitCells(
    #     melody_lb,
    #     fabric_staves = ("ooa_horn", "cco_horn"),
    #     hit_duration = 0.5,
    #     )
    #     )
    # melody_accents = melody.Melody(melody_lb,
    #     fabric_staves = ("ooa_horn", "cco_horn"),
    #     )

    # # TO DO... move this into integration
    # driving_sax = driving_off.DrivingOff(
    #     fabric_staves = instrument_groups.get_instruments("sax",),
    #     mask_staves = ("ooa_bari_sax"),
    #     bookend_beats = (0,1),
    #     )

    # bass_line = melody.Melody(
    #     calliope.LineBlock(
    #         calliope.Line(*BASS_LINE()[:-1]),
    #         ),
    #     fabric_staves = ("ooa_trombone", "ooa_bass_guitar", "ooa_bari_sax", "cco_trombone", ),
    #     )

    # s.extend_from(
    #     counter_winds(),
    #     strings_pulse1(),
    #     strings_low_pulse1,
    #     osti1,
    #     driving_sax,
    #     my_melody,
    #     melody_accents,
    #     bass_line,
    #     )
    # s.extend_from(
    #     strings_swell1(),
    #     extend_last_machine=True,
    #     )

    # s.fill_rests(fill_to="cco_violin_i")

    # # =======================================================
    # # bars 9-16

    # s.extend_from(
    #     counter_winds(),
    #     osti1,
    #     osti1_accents,
    #     strings_pulse1(),
    #     strings_low_pulse1(),
    #     )
    s.fill_rests()
    s.midi_tempo = 112
    return s
Ejemplo n.º 7
0
def score3(lib):
    s = score.ImaginaryScore()
    sb3 = lib("lyrical_block3")
    s = sb3().annotate(slur_cells=True, label=("phrases", "cells")).to_score(s)

    # TO DO: add ranges
    # =======================================================
    # throuhout pad / texture

    drum_set = ImaginarySegment(
        lib("drum_dark"), get_improv_line(rhythm=(1, ) * 4, times=9),
        get_improv_line(instruction="improv", rhythm=(0.5, ) * 8, times=1))
    s.staves["ooa_drum_set"].append(drum_set)

    cym_seg = ImaginarySegment(
        # TO DO... this would be good in the library...
        ImaginaryCell(rhythm=(-4 * 9, )),
        ImaginaryCell(rhythm=(4, 4), ).eps(0, 1, ":32")(0, "\\<")(1, "mf")(),
        ImaginaryCell(rhythm=(-4, )).eps(0, "l.v.")(),
    )
    s.staves["cco_percussion"].append(cym_seg)

    s.extend_from(
        lambda_segment.LambdaSegment(
            sb3.with_only("high_drones", ),
            fabric_staves=("piano1", ),
            func=lambda x: x,
        ))
    s.extend_from(
        lambda_segment.LambdaSegment(
            sb3.with_only("bass_drones"),
            fabric_staves=("cco_bass", "piano2"),
            func=lambda x: x.crop("events", 0, 1).eps(22, beats=4)(),
            funcs=(
                lambda x: x.crop_chords((0, ), ),
                lambda x: x,
            ),
        ))
    ooa_strings_pulses = pulse_on_off_beat.PulseOnOffBeat(
        sb3,
        fabric_staves=(
            "ooa_violin1",
            "ooa_violin2",
            "ooa_cello1",
            "ooa_cello2",
        ),
        phrase_beats=(4, ) * 6,
        ranges=pitch_ranges.HIGHISH_TO_LOW_RANGES,
    )
    for st in ooa_strings_pulses.staves:
        for phrase in st.phrases:
            if phrase.note_events:
                phrase.note_events[0].tag(".")
                phrase.note_events[1:].tag("-")
    ooa_strings_pulses2 = osti.Osti(
        sb3,
        fabric_staves=(
            "ooa_violin1",
            "ooa_violin2",
            "ooa_cello1",
            "ooa_cello2",
        ),
        ranges=pitch_ranges.BOTTOM_RANGES,
        selectable_start_beat=6 * 4,
        osti_pulse_duration=1,
        tag_all_note_events=("-", ),
        osti_cell_length=4,
        osti_cell_count=4,
    )
    ooa_strings_pulses3 = pad.Pad(sb3,
                                  fabric_staves=(
                                      "ooa_violin1",
                                      "ooa_violin2",
                                      "ooa_cello1",
                                      "ooa_cello2",
                                  ),
                                  ranges=pitch_ranges.BOTTOM_RANGES,
                                  selectable_start_beat=10 * 4,
                                  pad_durations=(2, 2, 4),
                                  tag_events={
                                      0: ("\\<", ),
                                      2: ("f", )
                                  })
    mallets_osti = osti.Osti(
        sb3.with_only("high_drones"),
        fabric_staves=("ooa_mallets", ),
        ranges=pitch_ranges.TOP_RANGES,
        osti_pulse_duration=0.5,
        osti_cell_length=8,
        osti_cell_count=11,
    )
    for n in mallets_osti.note_events:
        n.pitch = (n.pitch, n.pitch - 12)
    s.extend_from(ooa_strings_pulses, ooa_strings_pulses2, ooa_strings_pulses3,
                  mallets_osti)
    # =======================================================
    # bars 1-4
    # =======================================================
    # melody and bass lines:
    violin_i = lambda_segment.LambdaSegment(
        sb3.with_only("counter_line", ),
        fabric_staves=("cco_violin_i", ),
        func=lambda x: x.scramble("cells", 2, 3, 4, 5, 2, 4, 3).mask(
            "cells", 1, 3).e_smear_after(fill=True).eps(0, 2, 4, 6, 9, "(")
        (1, 3, 5, 7, 10, ")")())

    violin_ii_seg = sb3["melody_line2"]().with_only(
        "cells", 0, 1, 2, 3).crop_chords((0, )).e_smear_after(fill=True)
    violin_ii_seg.note_events[:4].transformed(calliope.Transpose(interval=7))
    violin_ii_seg.note_events[0, 2,
                              5].transformed(calliope.Transpose(interval=12))
    violin_ii_seg.e_smear_after(fill=True).eps(7, 9, 11, "(")(8, 10, 12, ")")()
    s["cco_violin_ii"].append(violin_ii_seg)

    viola_cello = lambda_segment.LambdaSegments(
        sb3.with_only("melody_line1", ),
        fabric_staves=(
            "cco_viola",
            "cco_cello",
        ),
        func=lambda x: x.with_only("cells", 0, 1, 2, 3).e_smear_after(
            fill=True).eps(
                1,
                "div.",
            )(1, 6, 9, 15, "(")(2, 7, 10, 16, ")")(),
        funcs=(lambda x: x, lambda x: x.t(-12)),
    )

    s.extend_from(violin_i, viola_cello)

    # pads
    s.extend_from(
        lyrical.SaxSwell(
            sb3.with_only("bass_drones", ),
            ranges=pitch_ranges.get_ranges(ratio_mid=0.7, spread=16),
            swell_dynamic="mf",
            swell_duration=8,
        ),
        lyrical.SaxSwell(
            sb3,
            selectable_start_beat=8,
            ranges=pitch_ranges.get_ranges(ratio_mid=0.6, spread=16),
            swell_dynamic="mf",
            swell_duration=8,
        ),
        lyrical.SaxSwell(
            sb3.with_only("counter_line", ),
            selectable_start_beat=16,
            ranges=pitch_ranges.get_ranges(ratio_mid=0.6, spread=16),
            swell_dynamic="mf",
            swell_duration=8,
        ),
    )

    # =======================================================
    # bars 5-12
    # =======================================================
    # lines
    violin_i = lambda_segment.LambdaSegment(
        sb3.with_only("counter_line", ),
        fabric_staves=("cco_violin_i", ),
        bookend_beats=(2, 0),
        func=lambda x: x.crop("cells", 2).mask("cells", 4, 5).crop(
            "events", 0, 6).e_smear_after(fill=True).eps(
                0, 2, 5, 8, 11, 13, 15, 18, 21, "(")
        (1, 3, 6, 9, 12, 14, 16, 19, 22, ")")(23, 24, 25, 26, 27, 28, 29, "-")
        (29, beats=0.5)(30, beats=4)())
    for c in violin_i.cells[2:]:
        c.t(-12)
    violin_ii = lambda_segment.LambdaSegment(
        sb3.with_only("melody_line2", ),
        fabric_staves=("cco_violin_ii", ),
        func=lambda x: x.crop("cells", 4).mask("cells", 2).e_smear_after(
            fill=True).crop("events", 0, 1).eps(1, 5, 9, 11, 16, "(")
        (2, 6, 10, 12, 17, ")")(19, 20, 21, 22, "-")(22, beats=0.5)
        (23, beats=4)().t(-12)  #.label("events")
    )
    viola = lambda_segment.LambdaSegment(
        sb3.with_only("melody_line1", ),
        fabric_staves=("cco_viola", ),
        func=lambda x: x.crop("cells", 4).e_smear_after(fill=True).crop(
            "events", 0, 3).eps(1, "f")(1, 4, 7, 9, 13, 17, 19, 21, "(")
        (2, 5, 8, 10, 14, 18, 20, 22, ")")(23, 24, "-")(24, beats=1)
        (25, beats=4)()  #.label("events")
    )
    cello = lambda_segment.LambdaSegment(
        sb3.with_only("bass_line", ),
        fabric_staves=("cco_cello", ),
        func=lambda x: x.crop("cells", 3).crop_chords(
            (0, )).crop("events", 0, 4).eps(1, "f")(1, 11, 18, "(")
        (2, 12, 19, ")")(24, 25, 26, 27, "-")(28, beats=4)()  #.label("events")
    )

    s.extend_from(violin_i, violin_ii, viola, cello)

    guitar_improv1 = improv.Improv(
        sb3,
        instruction="improv on these pitches, spacyey fx",
        fabric_staves=("ooa_guitar", ),
        improv_times=3,
        ranges=pitch_ranges.MID_RANGES,
        # selectable_start_beat=7*4,
        dynamic="mf")
    guitar_improv2 = improv.Improv(
        sb3,
        instruction="",
        fabric_staves=("ooa_guitar", ),
        improv_times=3,
        ranges=pitch_ranges.MID_RANGES,
        selectable_start_beat=3 * 4,
    )
    s.extend_from(guitar_improv1, guitar_improv2)
    s.fill_rests(beats=6 * 4)

    guitar_improv3 = improv.Improv(
        sb3,
        instruction="",
        fabric_staves=("ooa_guitar", ),
        improv_times=3,
        ranges=pitch_ranges.MID_RANGES,
        selectable_start_beat=6 * 4,
    )
    guitar_improv3_bass = improv.Improv(
        sb3,
        instruction="improv on these pitches, spacey fx",
        fabric_staves=("ooa_bass_guitar", ),
        improv_times=3,
        ranges=pitch_ranges.MID_RANGES,
        selectable_start_beat=6 * 4,
        dynamic="mf")
    s.extend_from(guitar_improv3, guitar_improv3_bass)
    guitar_improv4 = improv.Improv(
        sb3,
        instruction="",
        fabric_staves=(
            "ooa_guitar",
            "ooa_bass_guitar",
        ),
        improv_times=2,
        ranges=pitch_ranges.MID_RANGES,
        selectable_start_beat=9 * 4,
    )
    s.extend_from(guitar_improv4)

    # anything here?
    s.fill_rests(beats=11 * 4)

    s.fill_rests()

    # adjust for bass 8va
    for bass_seg in s.staves["cco_bass"].segments:
        bass_seg.t(12)

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

    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 = 5
            main_seg.compress_full_bar_rests = True
Ejemplo n.º 8
0
x = lick.Lick(
    sb,
    fabric_staves=instrument_groups.get_instruments("brass"),
    ranges=pitch_ranges.MID_RANGES,
    # selectable_start_beat = 0,
    # lick_rhythm = (1.5, 1.5, 1),
    # lick_count = 4,
)
# calliope.illustrate(x)
# ======================================================================
# OSTI
x = osti.Osti(
    sb,
    fabric_staves=instrument_groups.get_instruments("strings"),
    ranges=pitch_ranges.MID_RANGES,
    # selectable_start_beat = 0,
    # osti_pulse_duration = 0.5,
    # osti_cell_length = 6,
    # osti_cell_count = 2,
)
# calliope.illustrate(x)
# ======================================================================
# PAD
x = pad.Pad(
    sb,
    fabric_staves=instrument_groups.get_instruments("strings"),
    ranges=pitch_ranges.MID_RANGES,
    # selectable_start_beat = 0,
    # pad_durations = (4,)*4,
)
# x = pad.MalletsPad(sb)