def gliss_up_block(rest_beats=-1, low_beats=3, high_beats=4, transpose=0, tags=()): return calliope.SegmentBlock( ImaginarySegment( ImaginaryCell( rhythm=(rest_beats, low_beats, high_beats), pitches=("R", 16 + transpose, 27 + transpose), respell="sharps", ).eps( 0, "speed up into tremolo", )(1, "!\\glissando :8", "\\<", *tags)(2, "ff", ":32")()))
def score1(lib): s = score.ImaginaryScore() sb = lib("rock_block1") s = sb().annotate( slur_cells=True, label=("phrases", "cells") ).to_score(s) riffs_block = short_block.ChordsToSegmentBlock( selectable = sb.with_only("riff",).segments[0], sort_chords=True, ) # TO DO: consider poking apart the clouds a little bit # # TO DO: add ranges # # ======================================================= # WOOD BLOCK, BASS, PIZZ THORUGHOUT wood_block = lambda_segment.LambdaSegment( sb.with_only("high_rhythm"), fabric_staves = ("cco_percussion",), # tag_events = {0:("mp", "woodblock")}, func = lambda x: x, # func = lambda x: x.only_first("cells",8) ) wood_block.note_events.setattrs(pitch=0) # TO DO... consider varying this up... so not always # bass on double stop bass_drones = lambda_segment.LambdaSegment( sb.with_only("bass_drones"), # selectable_start_beat = (23*4), fabric_staves = ( "ooa_bass_guitar", "cco_bass", ), func = lambda x: x.t(12), # tag_events = {0:("mf",)}, ) opening_wind_hits = lambda_segment.LambdaSegment( sb.with_only("chords"), ranges=pitch_ranges.MID_RANGES, fabric_staves = instrument_groups.get_instruments( "sax","ooa_winds","ooa_brass"), assign_pitches_from_selectable = True, func = lambda x: x.only_first("cells",1).bookend_pad(0,1), tag_all_note_events=(".",) ) opening_pizz = lambda_segment.LambdaSegment( sb.with_only("chords"), ranges=pitch_ranges.BOTTOM_RANGES, fabric_staves = instrument_groups.get_instruments( "strings"), mask_staves = ("cco_bass",), # tag_events = {0:("mf", "pizz")}, assign_pitches_from_selectable = True, func = lambda x: x.only_first("cells",7 ).bookend_pad(0,3).eps( 0, "!\\snappizzicato")(), ) s.extend_from( wood_block, bass_drones, opening_wind_hits, opening_pizz, ) # # ======================================================= # OPENING RIFFS ON GUITAR, HARP, MALLETS mallets_riff = lambda_segment.LambdaSegment( sb.with_only("riff",), fabric_staves = ( "ooa_mallets", ), tag_events = {0:("mf", "hard mallets")}, func = lambda x: x, ) poke_mallets = [] next_include = False for i,e in enumerate(mallets_riff.events): e_pitch = e.pitch if len(e_pitch)>1 and abs(e_pitch[0]-e_pitch[1])==12: next_include = True poke_mallets.append(i) elif next_include: poke_mallets.append(i) next_include = False else: next_include = False mallets_riff.segments[0].poke("events", *poke_mallets) mallets_riff.note_events[-4:].transformed(calliope.Transpose(interval=-12)) riffs_opening = lambda_segment.LambdaSegments( riffs_block, fabric_staves = ( "ooa_guitar", "harp1", ), # tag_events = {0:("mf", "hard mallets")}, funcs = ( lambda x: x.only_first("cells", 8 ).crop_chords(indices=(1,)).t(-12 ).bookend_pad(0,1), lambda x: x.only_first("cells", 8 ).crop_chords(indices=(0,) ).bookend_pad(0,1), ) ) s.extend_from( mallets_riff, riffs_opening, ) # # ======================================================= cymbals = lambda_segment.LambdaSegment( sb.with_only("high_rhythm"), fabric_staves = ("ooa_drum_set",), func = lambda x: x.only_first("cells",6).eps( 0, "improv, cymbals", "mp")(), tag_all_note_events = ("note_head:0:slash",) ) cymbals.note_events.setattrs(pitch=0) s.extend_from(cymbals,) s.extend_from( lambda_segment.LambdaSegment( calliope.SegmentBlock(ImaginarySegment( lib("rock_rhythm1"), get_improv_line( rhythm=(1,)*8, times=6 ), get_improv_line( rhythm=(0.5,)*16, times=1, instruction="improv, solo" ), )), fabric_staves = ("ooa_drum_set",), func = lambda x: x, ) ) osti_chords_piano = lambda_segment.LambdaSegments( sb.with_only("melody_line2"), fabric_staves = ("piano1","piano2"), func = lambda x: x.crop_chords(above=(3,)).only_first("cells",7), funcs = ( lambda x: x.ops("note_events")( 0,"f")(), lambda x: x.t(-12).ops("note_events")( 0,"treble")(), ) ) # osti_chords_piano.staves["piano2"].note_events[0].tag("treble") s.extend_from(osti_chords_piano,) s.fill_rests(beats=8) osti_chords_brass = lambda_segment.LambdaSegment( sb.with_only("melody_line2"), fabric_staves = instrument_groups.get_instruments("brass",), func = lambda x:x.only_first("cells",7 ).crop("events",4).poke("note_events",0,3,4,7,8,9 ).ops("events")(0,"mf")(), tag_all_note_events=("-",), assign_pitches_from_selectable=True, selectable_start_beat=8, ranges=pitch_ranges.MID_RANGES, ) s.extend_from(osti_chords_brass,) s.fill_rests(beats=4*4) # # ======================================================= cloud_6 = lib("rock_grid_g1_c6") # cloud_11[3].t(12) wind_cloud_6 = lambda_segment.LambdaSegment( cloud_6, fabric_staves = ( "cco_flute1", "ooa_clarinet", "ooa_flute", "cco_clarinet1", "cco_flute2", "cco_clarinet2", ), tag_events = {1:("mp", "\\<",), 6:("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), # func = lambda x: x.only_first("cells",8) ) wind_cloud_6.phrases.setattrs(respell="flats") wind_cloud_6.staves["ooa_flute"].phrases.setattrs(respell="sharps") s.extend_from( wind_cloud_6, ) s.fill_rests(fill_to="cco_flute1") # # ======================================================= # FROM BAR 7 mid_pads = lambda_segment.LambdaSegments( sb.with_only("mid_drones",), fabric_staves = ( "ooa_guitar", "cco_viola", ), funcs = ( lambda x: x.crop("cells",1).eps( 0,"distorted, spacey","mf")(), lambda x: x.crop("cells",1).eps( 0, "mf","arco","sul pont")(), ) ) brass_swells = staggered_swell.StaggeredSwells( sb.with_only("mid_drones"), low_dynamic = "p", swell_dynamic = "mf", cell_count = 1, phrase_count=8, swell_duration = 8, selectable_start_beat=6*4, # swell_split_ratios = ( # 1/2, # ) swell_staggers = ( (0,2), (1,1), # (0.5,0.5), # (1,0) ), fabric_staves = ( "ooa_horn", "cco_horn","ooa_trumpet", "cco_trumpet" ), ) for st in brass_swells.staves["ooa_trumpet", "cco_trumpet"]: st.note_events[0].tag("straight mute") # for c in horn_swells.cells: # c.events[-1].tag("\\!") # # ======================================================= # continue riff... TO DO, are violins the best option here? # # ======================================================= # TO DO: consider merging into single staff # TO DO: ooa violin fx??????!! ooa_violins = lambda_segment.LambdaSegment( sb.with_only("riff"), assign_pitches_from_selectable = True, ranges=pitch_ranges.LOW_TO_HIGHISH_RANGES, fabric_staves = ( "ooa_violin1", "ooa_violin2", ), # tag_events = {0:("mf", "hard mallets")}, tag_all_note_events = ("-",), selectable_start_beat=6*4, func = lambda x: x.with_only("cells", 8,9,10,11,12,13,14,15,16 ).crop("events",2).eps( 0, "arco")() # ).bookend_pad(0,1) ) s.extend_from( mid_pads, brass_swells, ooa_violins, ) # # ======================================================= # BAR 13 +: # cco flutes high E drones # closing string pizz # cco clarinets and oboes trade off riff # # ======================================================= # TO DO: check this flute range with dynamics... consider piccolo s.fill_rests(beats=12*4) # TO DO: consider modeling this with flutes... DRY flute_high_swells = staggered_swell.StaggeredSwells( sb.with_only("high_drones"), low_dynamic = "p", swell_dynamic = "mf", cell_count = 1, phrase_count=4, swell_duration = 8, selectable_start_beat=12*4, # swell_split_ratios = ( # 1/2, # ) swell_staggers = ( (0,2), (1,1), # (0.5,0.5), # (1,0) ), fabric_staves = ( "cco_flute1", "cco_flute2" ), ) closing_pizz = lambda_segment.LambdaSegment( sb.with_only("chords"), ranges=pitch_ranges.HILL_UP_RANGES, fabric_staves = instrument_groups.get_instruments( "cco_strings") + ("ooa_cello1","ooa_cello2"), mask_staves = ("cco_bass", "cco_viola"), selectable_start_beat=12*4, tag_events = {0:("mf", "pizz")}, assign_pitches_from_selectable = True, func = lambda x: x.crop("cells",17), # func = lambda x: x.crop("cells",1), # func = lambda x: x.only_first("cells",8) ) midpoint_wind_hit = lambda_segment.LambdaSegment( sb.with_only("chords"), ranges=pitch_ranges.MID_RANGES, fabric_staves = instrument_groups.get_instruments( "sax","ooa_winds") + ("ooa_trombone",), assign_pitches_from_selectable = True, selectable_start_beat=12*4, func = lambda x: x.with_only("cells",17).bookend_pad(0,2), tag_all_note_events=(".",) ) ob_cl_dove_riff = dovetail.Dovetail( sb.with_only("riff"), fabric_staves=("cco_oboe1","cco_oboe2","cco_clarinet1","cco_clarinet2"), ranges=pitch_ranges.LOW_TO_HIGH_RANGES, # tag_events = {0:("THIS CLOUD SUCKS",)}, tag_all_note_events = ("-",), selectable_start_beat=12*4, dovetail_duration = 28, ) piano_riff = lambda_segment.LambdaSegment( sb.with_only("riff"), fabric_staves=("piano1","piano2",), ranges=pitch_ranges.PitchRanges(pitch_ranges.RangeSeq().add_abstract( 0, pitch_ranges.TOP_RANGE, ).add_abstract( 0.5, pitch_ranges.MID_RANGE, ).add_abstract( 1, pitch_ranges.TOP_RANGE, ),), assign_pitches_from_selectable=True, selectable_start_beat=12*4, tag_all_note_events = (".",), func = lambda x: x.crop("cells", 17), ) piano_riff.staves["piano1"].note_events[-5:].transformed( calliope.Transpose(interval=12)) piano_riff.staves["piano1"].note_events[28,29,30].transformed( calliope.Transpose(interval=12)) piano_riff.staves["piano2"].note_events[6,7,8,9,10,11, 22,23,24,25,28,30,31,32,33,34,35,36,].transformed( calliope.Transpose(interval=-12)) piano_riff.staves["piano1"].segments[0].eps( 0,48,"8va")( 5,55,"8va!")() piano_riff.staves["piano2"].segments[0].t(-12).eps( 18, "bass",)( 40, "treble")() # NOT NEEDED SINCE ALREADY TREBLE # piano_riff.staves["piano2"].events[0].tag("treble") # ob_cl_dove_riff.transformed(calliope.SlurCells()) s.extend_from( flute_high_swells, closing_pizz,ob_cl_dove_riff, piano_riff, midpoint_wind_hit ) # # ======================================================= # BAR 16+ # 23/24 wind cloud # # ======================================================= s.fill_rests(beats=15*4) wind_cloud_23_24 = lambda_segment.LambdaSegment( lib("rock_grid_g1_c23_24"), fabric_staves = ( "ooa_flute","ooa_clarinet", "ooa_alto_sax1","ooa_alto_sax2","ooa_tenor_sax","ooa_bari_sax", ), 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), func = lambda x: x, ) wind_cloud_23_24.phrases.apply(lambda x:x.auto_respell()) s.extend_from(wind_cloud_23_24,) s.fill_rests(beats=16*4) end_wind_hit = lambda_segment.LambdaSegment( sb.with_only("chords"), ranges=pitch_ranges.BOTTOM_RANGES, fabric_staves = instrument_groups.get_instruments( "sax","ooa_winds") + ("ooa_trombone",), assign_pitches_from_selectable = True, selectable_start_beat=12*4, func = lambda x: x.with_only("cells",25).bookend_pad(0,1), tag_all_note_events=(".",".") ) s.extend_from(end_wind_hit,) s.fill_rests(beats=19*4) end_winds_improv = improv.Improv( sb, fabric_staves = ("ooa_flute", "ooa_clarinet", "ooa_alto_sax1", "ooa_alto_sax2"), improv_times = 3, ranges = pitch_ranges.HIGHISH_RANGES, selectable_start_beat=19*4, dynamic="mp" # pitch_selectable_indices = ( # (0,2,4,5), # ), ) s.extend_from( end_winds_improv, ) # # ======================================================= s.fill_rests() 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 = 7 main_seg.compress_full_bar_rests = True
def score4(lib): s = score.ImaginaryScore() sb = lib("rock_block4") s = sb().annotate(slur_cells=True, label=("phrases", "cells")).to_score(s) # riffs_block = short_block.ChordsToSegmentBlock( # selectable = sb.with_only("riff",).segments[0], # sort_chords=True, # ) # =======================================================# # bass line carries all the way through... s.extend_from( lambda_segment.LambdaSegment( calliope.SegmentBlock( ImaginarySegment( get_improv_line(instruction="ad lib", rhythm=(1, ) * 4, times=22))), fabric_staves=("cco_percussion", ), func=lambda x: x.eps("\\percStaff")(), )) s.extend_from( lambda_segment.LambdaSegment( calliope.SegmentBlock( ImaginarySegment( get_improv_line(instruction="ad lib with rolls", rhythm=(1, ) * 4, times=9).eps(8 * 4 - 2, "\\>")(8 * 4 + 3, "pp")())), fabric_staves=("cco_percussion", ), func=lambda x: x, )) s.extend_from( lambda_segment.LambdaSegment( calliope.SegmentBlock( ImaginarySegment(lib("rock_rhythm1"), get_improv_line(rhythm=(1, ) * 8, times=10))), fabric_staves=("ooa_drum_set", ), func=lambda x: x, )) s.extend_from( lambda_segment.LambdaSegment( calliope.SegmentBlock( ImaginarySegment( get_improv_line(instruction="ad lib with rolls", rhythm=(1, ) * 4, times=9).eps(8 * 4 - 2, "\\>")(8 * 4 + 3, "pp")())), fabric_staves=("ooa_drum_set", ), func=lambda x: x, )) guitar_improv1 = improv.Improv( sb, instruction="improv, straight quarter notes on these pitches", fabric_staves=("ooa_guitar", "ooa_bass_guitar"), improv_times=2, ranges=pitch_ranges.MID_RANGES, dynamic="mf", pitch_selectable_indices=((0, 2, 4, 5), ), ) guitar_improv2 = improv.Improv( sb, instruction="", fabric_staves=("ooa_guitar", "ooa_bass_guitar"), improv_times=2, ranges=pitch_ranges.MID_RANGES, selectable_start_beat=4 * 2, pitch_selectable_indices=((1, 3, 5, 6), ), ) guitar_improv3 = improv.Improv( sb, instruction="", fabric_staves=("ooa_guitar", ), improv_times=2, ranges=pitch_ranges.MID_RANGES, selectable_start_beat=8 * 2, pitch_selectable_indices=((0, 2, 4, 5), ), ) s.extend_from(guitar_improv1, guitar_improv2, guitar_improv3) guitar_improv1.note_events[0].tag("fat fx") bass_line = lambda_segment.LambdaSegment( sb.with_only("bass_line", ), fabric_staves=("ooa_bass_guitar", ), func=lambda x: x.only_first("cells", 7).crop("cells", 1), tag_events={ 0: ("f", ), }, ) bass_line.cells[-1].t(12) piano_chords_rh = lambda_segment.LambdaSegment( sb.with_only("chords", ), fabric_staves=("piano1", ), # tag_all_note_events = ("-",), tag_events={ 0: ("f", ), }, func=lambda x: x.with_only("cells", 0).crop_chords(above=(3, )), ) piano_chords_lh = lambda_segment.LambdaSegment( sb.with_only("riff", ), fabric_staves=("piano2", ), tag_all_note_events=(".", ), func=lambda x: x.only_first("cells", 12).t(-24).e_smear_after( *[i * 2 for i in range(24)], extend_beats=0.5, cover_notes=True). crop_chords(indices=((0, 2), )), ) string_chords = pad.Pad( sb.with_only("bass_drones"), fabric_staves=instrument_groups.get_instruments("cco_strings"), mask_staves=("cco_bass", ), ranges=pitch_ranges.LOW_TO_HIGH_RANGES, pad_durations=(10, 8, 6), tag_all_note_events=(":32", ), after_func=lambda x: x.eps(0, "pp", "\\<")(1, "mp")(2, "\\<")()) s.extend_from(string_chords) # piano_chords_lh2 = lambda_segment.LambdaSegment( # sb.with_only("chords",), # fabric_staves=("piano2",), # # tag_all_note_events = ("-",), # func = lambda x: x.crop_chords(below=(3,)), # ) # for n in piano_chords_lh2.note_events: # if sum(n.pitch) > 0: # n.pitch = [p - 12 for p in n.pitch] trumpet_line1 = lambda_segment.LambdaSegment( sb.with_only( "mid_drones", ), # TO DO... mid_drones not the best name for this fabric_staves=("cco_trumpet", ), func=lambda x: x.only_first("cells", 5).bookend_pad(0, 2), tag_events={ 0: ("mp", "solo", "\\<"), 1: ("(", "f"), 2: (")"), 3: ("(", ), 4: (")"), }, ) trumpet_line2 = lambda_segment.LambdaSegment( sb.with_only( "mid_drones", ), # TO DO... mid_drones not the best name for this fabric_staves=("ooa_trumpet", ), func=lambda x: x.with_only("cells", 5, 6, 7, 8, 9).bookend_pad(10), tag_events={ 1: ("f", "solo"), 2: ("(", ), 3: (")"), }, ) trumpet_line3 = lambda_segment.LambdaSegment( sb.with_only( "mid_drones", ), # TO DO... mid_drones not the best name for this fabric_staves=("cco_trumpet", ), func=lambda x: x.with_only("cells", 10, 11, 12, 13, 14).crop_chords( (0, )).bookend_pad(8), tag_events={ 2: ("(", ), 3: (")"), 4: ("(", ), 5: (")"), }, ) s.extend_from( trumpet_line1, trumpet_line2, trumpet_line3, bass_line, piano_chords_rh, piano_chords_lh, ) # ======================================================= s.cells.apply(lambda x: x.auto_respell()) riff_mallets1 = lambda_segment.LambdaSegment( sb.with_only("riff", ), fabric_staves=("ooa_mallets", ), func=lambda x: x.only_first("cells", 12).crop_chords(below=(2, 1)). crop_chords(above=(1, )), tag_events={0: ("f", )}, ) riff_harp1 = lambda_segment.LambdaSegment( sb.with_only("riff", ), fabric_staves=("harp1", ), func=lambda x: x.only_first("cells", 12).crop_chords(above=(-1, )), tag_events={0: ("f", )}, ) # creates downward line for each phrase: current_staff = "harp1" for p in riff_harp1.phrases: while p.note_events[0].pitch < 14: p.t(12) for n1, n2 in zip(p.note_events[0:-1], p.note_events[1:]): while n2.pitch > n1.pitch: n2.pitch -= 12 # if n2.pitch < 0 and current_staff=="harp1": # n1.tag("""\\change Staff = "harp2" """) # current_staff = "harp2" # if current_staff=="harp2": # p.events[-1].tag("""\\change Staff = "harp1" """) # current_staff = "harp1" s.extend_from( riff_mallets1, riff_harp1, ) s.fill_rests(beats=6 * 4) # ======================================================= # BARS 7+ # ======================================================= guitar_riff = lambda_segment.LambdaSegment( sb.with_only("riff", ), fabric_staves=("ooa_guitar", ), func=lambda x: x.with_only("cells", *list(range(12, 25))), ) s.extend_from(guitar_riff) piano_osti = lambda_segment.LambdaSegment( sb.with_only("melody_line2", ), fabric_staves=("piano1", "piano2"), func=lambda x: x.with_only("cells", *list(range(1, 7))), funcs=( lambda x: x, lambda x: x.t(-12).eps(0, "treble")(), ), bookend_beats=(0, 2), ) brass_osti = lambda_segment.LambdaSegment( sb.with_only("melody_line2", ), fabric_staves=instrument_groups.get_instruments("brass"), mask_staves=("cco_trumpet"), selectable_start_beat=6 * 4, assign_pitches_from_selectable=True, tag_all_note_events=("-", ), ranges=pitch_ranges.LOWISH_TO_HIGH_RANGES, bookend_beats=(4, 2), func=lambda x: x.with_only("cells", 3, 4, 5, 6).eps(0, "p", "\\<") (10, "mf")(0, 1, 5, 7, 9, "-")(2, 6, 10, ".")()) string_chords2 = pad.Pad( sb.with_only("bass_drones", "mid_drones", "high_drones", "riff", "bass_line"), fabric_staves=instrument_groups.get_instruments("strings"), mask_staves=("cco_bass", ), ranges=pitch_ranges.HIGHISH_TO_LOW_RANGES, pad_durations=(3, 1) * 8, tag_all_note_events=(":32", ), selectable_start_beat=6 * 4, after_func=lambda x: x.eps(0, "mf")()) s.extend_from(string_chords2, extend_last_machine=True) fl_swells = staggered_swell.StaggeredSwells( sb.with_only("high_drones"), low_dynamic="mp", swell_dynamic="mf", cell_count=1, phrase_count=4, swell_duration=16, selectable_start_beat=6 * 4, # swell_split_ratios = ( # 1/2, # ) swell_staggers=( (0, 2), (1, 1), # (0.5,0.5), # (1,0) ), fabric_staves=("cco_flute1", "cco_flute2"), ) cl_dove_riff = dovetail.Dovetail( sb.with_only( "riff", "counter_line", ), fabric_staves=("ooa_alto_sax1", "ooa_alto_sax2", "ooa_tenor_sax", "ooa_clarinet", "cco_clarinet1", "cco_clarinet2"), ranges=pitch_ranges.MID_RANGES, dove_count=3, selectable_start_beat=6 * 4, dovetail_duration=8 * 4, after_func=lambda x: x.slur_cells().ops("note_events")(0, "mf")()) s.extend_from(piano_osti, cl_dove_riff, fl_swells, brass_osti) s.fill_rests(beats=10 * 4) # ======================================================= # BARS 11+ # ======================================================= counter_line = lambda_segment.LambdaSegment( sb.with_only("counter_line", ), assign_pitches_from_selectable=True, selectable_start_beat=10 * 4, ranges=pitch_ranges.HIGHISH_TO_LOW_RANGES, fabric_staves=("ooa_bari_sax", "ooa_bassoon", "ooa_trombone", "ooa_bass_guitar"), func=lambda x: cresc( bass_artics(x.with_only("cells", 1, 2, 3, 4, 5, 6, 7, 8).fuse()))) s.extend_from(counter_line) flute_improv = improv.Improv(sb, fabric_staves=("ooa_flute", ), improv_times=4, ranges=pitch_ranges.HIGHISH_RANGES, selectable_start_beat=10 * 4, pitch_selectable_indices=((2, 4, 5, 6, 7), ), dynamic="mf") s.extend_from(flute_improv) s.fill_rests(beats=11 * 4) bass_to_end = lambda_segment.LambdaSegment( sb.with_only("bass_drones"), fabric_staves=("cco_bass", ), func=lambda x: x.crop("cells", 22, 1).crop_chords(below=(1, )).eps( 0, "p", "\\<")(6, "mf")(21, "p")(29, "\\<")(36, "ff", beats=4)()) s.extend_from(bass_to_end) s.fill_rests(beats=14 * 4) # ======================================================= # BARS 15+ # ======================================================= guitar_fx = improv.Improv( instruction="crazy fat distorted sounds", assign_improv_pitches_from_selectable=False, fabric_staves=("ooa_guitar", ), after_func=lambda x: x.eps(0, "p", "\\<")(7, "f")(), ) s.extend_from(guitar_fx) cloud_25_26 = lambda_segment.LambdaSegment( lib("rock_grid_g4_c25_26"), fabric_staves=( "ooa_bassoon", "ooa_cello1", "ooa_cello2", "cco_oboe1", "cco_oboe2", "cco_bassoon", ), # tag_events = {0:("(",),3:(")",),4:("(",),7:(")",),8:("(",),11:(")",)}, # tag_all_note_events = ("-",), func=lambda x: x.eps(0, "mp", "\\<")(23, "f")(), ) for seg in cloud_25_26.segments: for i, n in enumerate(seg.note_events): if i % 2 == 0: n.tag("(") else: n.tag(")") s.extend_from(cloud_25_26, ) s.fill_rests(beats=15.5 * 4, only_staves=("ooa_alto_sax1", "ooa_alto_sax2", "ooa_tenor_sax", "ooa_bari_sax", "ooa_violin1", "ooa_violin2")) cloud_27_28 = lambda_segment.LambdaSegment( lib("rock_grid_g4_c27_28"), fabric_staves=instrument_groups.get_instruments("sax", "ooa_strings") + ( "ooa_bassoon", "cco_oboe1", "cco_oboe2", "cco_bassoon", ), # tag_events = {0:("(",),3:(")",),4:("(",),7:(")",),8:("(",),11:(")",)}, # tag_all_note_events = ("-",), func=lambda x: x.eps(0, "mp", "\\<")(15, "f")(), ) for seg in cloud_27_28.segments: for i, n in enumerate(seg.note_events): if i % 2 == 0: n.tag("(") else: n.tag(")") s.extend_from(cloud_27_28, extend_last_machine=True) hit_staves = s.unused_staves_at_beat(14 * 4) hit_mask_staves = ("ooa_mallets", "ooa_drum_set", "ooa_guitar", "ooa_bass_guitar", "cco_percussion", "piano1", "piano2", "harp1", "harp2") opening_hit = hits.Hits( sb, fabric_staves=hit_staves, mask_staves=hit_mask_staves, ranges=pitch_ranges.BOTTOM_RANGES, selectable_start_beat=14 * 4, hits_spacing=(4, ), hit_duration=1, tag_all_note_events=(">", "."), ) then_swell_hit = swell_hit.SwellHit( sb, fabric_staves=hit_staves, mask_staves=hit_mask_staves, ranges=pitch_ranges.MID_TO_HIGHISH_RANGES, selectable_start_beat=15 * 4, low_dynamic="p", hit_dynamic="f", swell_duration=7.5, hit_duration=0.5, hit_rest=0, hit_articulations=(".", ">")) s.extend_from(opening_hit, then_swell_hit) s.fill_rests(beats=17 * 4) # ======================================================= bass_guitar_riff = lambda_segment.LambdaSegment( sb.with_only("riff", ), fabric_staves=("ooa_bass_guitar", ), func=lambda x: x.with_only("cells", *list(range(29, 36))).t(-24).eps( 0, "mf")(), ) s.extend_from(bass_guitar_riff) dove_riff2 = dovetail.Dovetail( sb.with_only( "riff", "counter_line", ), fabric_staves=( "ooa_tenor_sax", "ooa_clarinet", "ooa_bari_sax", "ooa_bassoon", "ooa_alto_sax1", "ooa_alto_sax2", "ooa_flute", ), ranges=pitch_ranges.HIGHISH_RANGES, dove_count=3, selectable_start_beat=17 * 4, dovetail_duration=4.5 * 4, after_func=lambda x: x.slur_cells().ops("note_events")(0, "mf")()) counter_line2 = lambda_segment.LambdaSegment( sb.with_only("counter_line", ), assign_pitches_from_selectable=True, selectable_start_beat=17 * 4, ranges=pitch_ranges.HIGHISH_TO_LOW_RANGES, fabric_staves=instrument_groups.get_instruments( "cco_winds", "cco_brass"), mask_staves=("cco_flute1", "cco_flute2"), func=lambda x: cresc( bass_artics( x.with_only("cells", *list(range(10, 18))).transformed( calliope.StandardDurations()))), ) counter_line_mallets = lambda_segment.LambdaSegment( sb.with_only("counter_line", ), fabric_staves=("ooa_mallets", ), # bookend_beats=(0,2), func=lambda x: x.with_only("cells", *list(range(10, 18))).eps(1, "f") (), ) piano_osti2 = lambda_segment.LambdaSegment( sb.with_only("melody_line2", ), fabric_staves=("piano1", "piano2"), func=lambda x: x.with_only("cells", *list(range(8, 12))), funcs=( lambda x: x, lambda x: x.t(-12).eps(0, "bass")(5, "treble")(), ), bookend_beats=(0, 1), ) brass_osti2 = lambda_segment.LambdaSegment( sb.with_only("melody_line2", ), fabric_staves=instrument_groups.get_instruments("ooa_brass"), selectable_start_beat=17 * 4, assign_pitches_from_selectable=True, ranges=pitch_ranges.LOWISH_TO_HIGH_RANGES, bookend_beats=(0, 1), func=lambda x: x.with_only("cells", *list(range(8, 12))).eps( 0, "p", "\\<")(10, "mf")(0, 1, 5, 7, 9, "-")(2, 6, 10, ".")()) s.extend_from(dove_riff2, counter_line2, piano_osti2, brass_osti2, counter_line_mallets) s.fill_rests(beats=22 * 4) # # ======================================================= # # BARS 23+ # # ======================================================= # END FULL PADS: rolls = pad.Pad( sb.with_only("high_drones"), ranges=pitch_ranges.TOP_RANGES, selectable_start_beat=22 * 4, fabric_staves=( "ooa_mallets", "piano1", "piano2", "harp1", ), pad_durations=(4, ) * 8, tag_all_note_events=(":32", ), after_func=lambda x: x.eps(0, "p")(3, "\\<")(7, "ff")(), ) rolls.staves["piano1"].segments[0].note_events[0].tag("8va") rolls.staves["piano1"].segments[0].note_events[-1].tag("8va!") rolls.staves["piano1"].segments[0].stack_p([(0, 12)]) rolls.staves["piano2"].segments[0].stack_p([ (-12, -24) ]).crop("cells", 0).bookend_pad(4, 0) rolls.staves["piano2"].events.untag("p", "ff", "\\<") s.extend_from(rolls) # END CLOUD: cloud_37_39 = lambda_segment.LambdaSegment( lib("rock_grid_g4_c37_39"), fabric_staves=("ooa_clarinet", "ooa_violin1", "ooa_violin2", "cco_clarinet1", "cco_clarinet2", "cco_viola"), # tag_events = {0:("(",),3:(")",),4:("(",),7:(")",),8:("(",),11:(")",)}, # tag_all_note_events = ("-",), func=lambda x: cresc(x.fuse(), "p", "mf").bookend_pad(3), funcs=( lambda x: x.slur_cells(), lambda x: x.eps(1, 3, 6, 8, 10, 13, "(")(2, 5, 7, 9, 11, 14, ")") (), lambda x: x.eps(1, 4, 9, 11, 13, "(")(3, 6, 10, 12, 14, ")")(), lambda x: x.slur_cells(), lambda x: x.slur_cells(), lambda x: x.eps(1, 5, 8, 11, 13, "(")(3, 7, 9, 12, 14, ")")(), )) cloud_38_40 = lambda_segment.LambdaSegment( lib("rock_grid_g4_c38_40"), fabric_staves=("ooa_bari_sax", "ooa_bassoon", "ooa_cello1", "ooa_cello2", "cco_bassoon", "cco_cello"), func=lambda x: cresc(x.fuse(), "mp", "mf").bookend_pad(6), funcs=( lambda x: x.slur_cells(), lambda x: x.slur_cells(), lambda x: x, lambda x: x, lambda x: x.slur_cells(), lambda x: x, )) cloud_39_41 = lambda_segment.LambdaSegment( lib("rock_grid_g4_c39_41"), fabric_staves=("cco_flute1", "cco_flute2", "cco_oboe1", "cco_oboe2", "cco_violin_i", "cco_violin_ii"), func=lambda x: cresc(x.fuse(), "mp", "f").bookend_pad(9), funcs=( lambda x: x.slur_cells(), lambda x: x.slur_cells(), lambda x: x.slur_cells(), lambda x: x.slur_cells(), lambda x: x, lambda x: x, )) s.extend_from(cloud_37_39, cloud_38_40, cloud_39_41, extend_last_machine=True) s.fill_rests(beats=25 * 4) guitar_fx2 = improv.Improv( instruction="crazy fat distorted sounds", assign_improv_pitches_from_selectable=False, improv_rhythm=(1, ) * (4 * 4 + 2), fabric_staves=( "ooa_guitar", "ooa_bass_guitar", ), after_func=lambda x: x.mask("events", 18, 19).eps(0, "mp", "\\<") (17, "f")(), ) s.extend_from(guitar_fx2) cloud_40_42 = lambda_segment.LambdaSegment( lib("rock_grid_g4_c40_42"), fabric_staves=("ooa_trombone", "ooa_violin1", "ooa_violin2", "cco_horn", "cco_trombone", "cco_viola"), func=lambda x: cresc(x.fuse(), "mp", "f"), funcs=( lambda x: x.slur_cells(), lambda x: x, lambda x: x, lambda x: x.slur_cells(), lambda x: x.slur_cells(), lambda x: x, )) s.extend_from(cloud_40_42, extend_last_machine=True) s.fill_rests(beats=25 * 4 + 3) cloud_41_43 = lambda_segment.LambdaSegment( lib("rock_grid_g4_c41_43"), fabric_staves=("ooa_clarinet", "cco_clarinet1", "cco_clarinet2", "ooa_cello1", "ooa_cello2", "cco_cello"), func=lambda x: cresc(x.fuse(), "mf", "f"), funcs=( lambda x: x.slur_cells(), lambda x: x.slur_cells(), lambda x: x.slur_cells(), lambda x: x, lambda x: x, lambda x: x, )) s.extend_from( cloud_41_43, extend_last_machine=True, ) s.fill_rests(beats=26 * 4 + 2) # glisses s.extend_from( lambda_segment.LambdaSegment(gliss_up_block(-2, 2, 10), fabric_staves=("cco_violin_i", "cco_violin_ii")), extend_last_machine=True, ) cloud_42_45 = lambda_segment.LambdaSegment( lib("rock_grid_g4_c42_45"), fabric_staves=( "ooa_alto_sax1", "ooa_alto_sax2", "ooa_tenor_sax", "ooa_bari_sax", "ooa_bassoon", "cco_bassoon", ), func=lambda x: cresc(x.fuse(), "mf", "ff").slur_cells(), ) s.extend_from( cloud_42_45, extend_last_machine=True, ) s.fill_rests(beats=27 * 4 + 1) cloud_43_45 = lambda_segment.LambdaSegment( lib("rock_grid_g4_c43_45"), fabric_staves=("ooa_flute", "ooa_horn", "ooa_trumpet", "cco_oboe1", "cco_oboe2", "cco_trumpet"), func=lambda x: cresc(x.fuse(), "mf", "ff").slur_cells(), ) s.extend_from( cloud_43_45, extend_last_machine=True, ) # glisses s.extend_from( lambda_segment.LambdaSegment(gliss_up_block(-1, 2, 6), fabric_staves=("ooa_violin1", "ooa_violin2", "cco_viola"), after_funcs=( lambda x: x, lambda x: x, lambda x: x.t(-12), )), extend_last_machine=True, ) s.fill_rests(beats=28) # glisses s.extend_from( lambda_segment.LambdaSegment(gliss_up_block(-2, 2, 2, -12, ("tenor", )), fabric_staves=("ooa_cello1", "ooa_cello2", "cco_cello")), extend_last_machine=True, ) s.fill_rests(beats=31 * 4) s.fill_rests(beats=32 * 4) for st in s.staves: st.events[-1].tag("fermata") # ======================================================= # 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"]) # s.only_staves("harp1", "harp2", "piano1", "piano2") 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 = 9 main_seg.compress_full_bar_rests = True
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
line().transformed(calliope.Transpose(interval=-4)), respell=respell) BASS_SEGMENT = calliope.Segment(BASS_LINE(), BASS_LINE(), BASS_LINE_1_FLAT(), BASS_LINE_2_FLAT(), respell="flats") texture_riff = T9_RIFF.to_line_block(8) MOVE = calliope.SegmentBlock( move_segment(HOME_LINE, respell="flats"), move_segment(HOME_U_LINE, respell="flats"), move_segment(COUNTER_LINE, respell="flats"), BASS_SEGMENT, move_segment(texture_riff[1], respell="flats"), move_segment(texture_riff[0], respell="flats"), ) # for e in MOVE.select[0,1,2,3].note_events: # e.pitch = (e.pitch, e.pitch+12) calliope.ScaleRhythm(scale=1 / 2)(MOVE) rhythm_intricate_a = R3_INTRACATE_CELL_BLOCK_A.to_rhythm_line_block(20) rhythm_intricate_b = R3_INTRACATE_CELL_BLOCK_B2.to_rhythm_line_block(40) MOVE.append(rhythm_intricate_b()[1]) MOVE.append(rhythm_intricate_a()[0]) MOVE.append(rhythm_intricate_a()[1])
def score0(lib): s = score.ImaginaryScore() sb = lib("rock_block0") s = sb().annotate(slur_cells=True, label=("phrases", "cells")).to_score(s) # TO DO: add ranges # ======================================================= low_drums = lambda_segment.LambdaSegment( sb.with_only("bass_rhythm"), fabric_staves=("ooa_drum_set", ), tag_events={0: ("mp", "sticks")}, func=lambda x: x.only_first("cells", 2)) cowbell = lambda_segment.LambdaSegment( sb.with_only("high_rhythm"), fabric_staves=("cco_percussion", ), tag_events={0: ("mp", "to cowbell")}, func=lambda x: x.eps(0, "\\percStaff")().ops("note_events") (0, "cowbell", "mp")(), # func = lambda x: x.only_first("cells",8) ) cowbell.note_events.setattrs(pitch=0) low_drums.staves["ooa_drum_set"].segments[0].append( get_improv_line(rhythm=(1, ) * 8, times=3)) harp_piano_highlights = lambda_segment.LambdaSegments( sb.with_only("counter_line", "riff"), fabric_staves=("harp1", "harp2", "piano1", "piano2"), funcs=( lambda x: x.ops("note_events")(0, "mp")(), lambda x: x.poke("cells", 9, 10, 12, 13).ops("note_events") (0, "treble")(), )) s.extend_from(low_drums, cowbell, harp_piano_highlights) s.fill_rests(beats=8 * 4) # # ======================================================= s.extend_from( lambda_segment.LambdaSegment( calliope.SegmentBlock( ImaginarySegment(lib("rock_rhythm1"), get_improv_line(rhythm=(1, ) * 8, times=11))), fabric_staves=("ooa_drum_set", ), func=lambda x: x, )) s.fill_rests(beats=16 * 4) # # ======================================================= guitar = lambda_segment.LambdaSegment( sb.with_only("riff"), fabric_staves=("ooa_guitar", ), tag_events={0: ("mp", )}, func=lambda x: x.crop("cells", 1), # func = lambda x: x.only_first("cells",8) ) for c in guitar.staves["ooa_guitar"].cells[13:]: c.t(-12) pizz = lambda_segment.LambdaSegment( sb.with_only("chords"), ranges=pitch_ranges.MID_RANGES, fabric_staves=instrument_groups.get_instruments("strings"), mask_staves=("cco_bass", ), tag_events={0: ( "mf", "pizz", )}, assign_pitches_from_selectable=True, selectable_start_beat=16 * 4, func=lambda x: x.crop("cells", 1).ops("note_events") (0, 4, "!\\snappizzicato")(), ) s.extend_from( guitar, pizz, ) # # ======================================================= # TO DO... add in piano and harp sections s.fill_rests(beats=22 * 4) wind_hits = lambda_segment.LambdaSegment( sb.with_only("chords"), ranges=pitch_ranges.MID_RANGES, fabric_staves=instrument_groups.get_instruments( "sax", "ooa_winds", "ooa_brass"), assign_pitches_from_selectable=True, selectable_start_beat=22 * 4, func=lambda x: x.with_only("cells", 11, 12, 13, 14, 15).mask( "cells", 0).ops("note_events")(0, "mp")(), tag_all_note_events=(".", ), bookend_beats=(0, 1)) s.extend_from(wind_hits, ) # # ======================================================= # block for cell 11 minor chord cloud cloud_11 = lib("rock_grid_g0_c11") cloud_11[3].t(12) wind_block_11 = lambda_segment.LambdaSegment( cloud_11, fabric_staves=( "cco_oboe2", "cco_clarinet1", "cco_flute2", "cco_flute1", "cco_oboe1", "cco_clarinet2", ), tag_events={ 0: ( "p", "\\<", ), 5: ("mf", ) }, # assign_pitches_from_selectable = True, # selectable_start_beat = 16*4, func=lambda x: x.slur_cells().bookend_pad(0, 1), # func = lambda x: x.crop("cells",1), # func = lambda x: x.only_first("cells",8) ) wind_block_11.phrases.setattrs(respell="flats") s.extend_from(wind_block_11, ) s.fill_rests(beats=23 * 4) cloud_13 = lib("rock_grid_g0_c13") cloud_13[0].t(-12) cloud_13[1].t(-12) cloud_13[4].t(12) wind_block_13 = lambda_segment.LambdaSegment( cloud_13, fabric_staves=( "cco_trombone", #0 "cco_bassoon", #1 "cco_clarinet2", #2 "cco_flute2", #3 "cco_flute1", #4 "cco_oboe2", #5 "cco_oboe1", #6 "cco_clarinet1", #7 "cco_trumpet", #8 ), tag_events={ 1: ( "p", "\\<", ), 6: ("mf", ) }, # assign_pitches_from_selectable = True, # selectable_start_beat = 16*4, # ranges=pitch_ranges.PitchRanges(pitch_ranges.MID_SEQ), func=lambda x: x.slur_cells().bookend_pad(2, 3), # func = lambda x: x.crop("cells",1), # func = lambda x: x.only_first("cells",8) ) wind_block_13.phrases.setattrs(respell="flats") wind_block_13.staves["cco_clarinet2", "cco_trumpet"].phrases.setattrs(respell="sharps") s.extend_from(wind_block_13, ) s.fill_rests(beats=25 * 4) # TO DO... add swell hits here... s.fill_rests(beats=23 * 4) # # ======================================================= bass_drones = lambda_segment.LambdaSegment( sb.with_only("bass_drones"), selectable_start_beat=(23 * 4), fabric_staves=( "ooa_bass_guitar", "cco_bass", ), func=lambda x: x.crop("cells", 1), tag_events={0: ("mf", )}, ) s.extend_from(bass_drones) s.fill_rests(beats=29 * 4) # # ======================================================= # TO DO: this cloud is not lovely!! cloud_21_22 = lib("rock_grid_g0_c21_22") cloud_21_22[7].t(-12) cloud_21_22[8].t(-12) # cloud_21_22[4].t(12) wind_cloud_21_22 = lambda_segment.LambdaSegment( cloud_21_22, fabric_staves=( "cco_flute1", #0 "cco_flute2", #1 "cco_oboe1", #2 "cco_oboe2", #3 "cco_clarinet1", #4 "cco_clarinet2", #5 "cco_trumpet", #6 "cco_bassoon", #7 "cco_trombone", #8 ), # selectable_start_beat = 16*4, # ranges=pitch_ranges.PitchRanges(pitch_ranges.MID_SEQ), func=lambda x: x.fuse().slur_cells().bookend_pad(2).eps( 1, "mp", "\\<")(), ) for st in wind_cloud_21_22.staves: st.note_events[-1].tag("f") wind_cloud_21_22.phrases.setattrs(respell="flats") s.extend_from(wind_cloud_21_22, ) s.fill_rests() for staff in s.staves: if staff.segments: staff.segments[ 0].tempo_command = """ \\note #"4" #UP "= 160 ca" """ staff.segments[0].rehearsal_mark_number = 6 s.segments.setattrs(compress_full_bar_rests=True) s.midi_tempo = 160 return s
lib.set_nodes(my_home_a, "phrases", "cells") my_home_b = home_b() lib["home_b"] = my_home_b lib.set_nodes(my_home_b, "phrases", "cells") lib.add(home_a_b, home_b_a, home_b_aup4, home_b_aup5, home_a_bup5) 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)
my_pitches.append(None) else: my_pitches.append(my_pitch[bs % len(my_pitch)]) pulse_counter += 1 my_cell.pitches = my_pitches my_phrase.append(my_cell) phrase_list.append(my_phrase) phrase_list.reverse() return phrase_list TEST_BLOCK = calliope.SegmentBlock( calliope.Segment(HOME_LINE), calliope.Segment(HOME_U_LINE), calliope.Segment(T9_RIFF.to_line_block(8)[0]), calliope.Segment(T9_RIFF.to_line_block(8)[1]), ) pa = PitchAnalyzer(TEST_BLOCK) T11_PULSE = T11_Pulse(pitch_analizer=pa) # # calliope.illustrate(TEST_BLOCK.to_score(name="test")) calliope.illustrate(TEST_BLOCK.to_score()) # define pulse duration, pitches from, num lines, ranges, seed (for random assignment)