def block_cells_to_staff(self, line_index, staff_name, cell_indices): self.score.staves[staff_name].append( calliope.Line(*[ c() if i in cell_indices else calliope. Cell(pitches=(None, ), rhythm=(c.beats, )) for i, c in enumerate(self.line_block[line_index].cells) ]))
def to_line_block(self, times=1): my_line_block = calliope.LineBlock() for p in self: my_line_block.append(calliope.Line(*[p() for i in range(times)])) return my_line_block
def to_rhythm_line_block(self, times=1): my_line_block = RhythmLineBlock() for c in self: my_line_block.append(calliope.Line(*[c() for i in range(times)])) return my_line_block
def tell(self): s = SingLine() s.extend([SingPhraseA1(), SingPhraseB(), SingPhraseA0()]) SingSeq(interval=7, pitch=0).transform(s) calliope.SmartRange().transform(s) s["phrase0"].respell = "sharps" s["phrase1"].respell = "sharps" s["phrase2"].respell = "sharps" s["phrase3"].respell = "flats" s.insert(0, SingPhraseA0()) s.insert(1, SingPhraseA1()) s.insert(2, SingPhraseB()) s.insert(3, SingPhraseA0()) s.events[0].pitch += 5 # SPECIAL case for first event clang_line = calliope.Line( *[ClangPhrase(selectable=p) for p in s.phrases]) # TO DO: make this into a factory trem_line = calliope.Line(*[ calliope.Phrase( calliope.Cell(pitches=([e.pitch for e in p.events[1, 3, 4]], ), rhythm=(p[0].beats + p[1].beats, )), calliope.Cell(pitches=([e.pitch for e in p.events[-1, -2, -3]], ), rhythm=(p[2].beats + p[3].beats, )), ) for p in s.phrases ]) lb = calliope.LineBlock( clang_line, s, trem_line, ) # calliope.SlurCells()(lb) return lb
def sing_crunch_lb(**kwargs): my_list = sing_crunch_list(**kwargs) row_count = my_list[0].row_count lb = SingCrunchLineBlock() for i in range(row_count): lb.append(calliope.Line(*[p.as_row(i) for p in my_list])) return lb
def sing_move(): my_line = calliope.Line( SingPhraseA0(name="move_phrase_a0"), SingPhraseA1(name="move_phrase_a1"), SingPhraseB(name="move_phrase_b"), SingPhraseA0(name="move_phrase_aa0"), SingPhraseA1(name="move_phrase_aa1"), SingPhraseB(name="move_phrase_bb"), SingPhraseA0(name="move_phrase_aaa0"), ) l = MoveStory(selectable=my_line, ) l.tell1() return l
def weave(self, staff, index=0, **kwargs): if self.phrase_tree: my_phrases = [ calliope.Phrase(*[calliope.Cell(*[e() for e in c]) for c in p]) for p in self.phrase_tree ] else: my_phrases = [ p() for p in self.selectable.get_cyclic(index).phrases ] my_line = calliope.Line(*my_phrases) if self.slur_cells == True: calliope.SlurCells()(my_line) return my_line
class TestLineStacked(calliope.LineStacked): intervals = ( (0, 2, 3, 7, 12), (0, 2, 7, 9, 12), ) # swaps = ( # (4,3,2,1,0), # (0,1,2,3,4), # ) my_line1 = calliope.Line(cells.CloselyCell()) # my_line2 = calliope.Line( cells.CloselyCell(transpose) ) # t = TestLineStacked(name="cloud_test") # print(t.get_output_path(sub_directory="data") ) # print( t.get_calling_module().__file__) # calliope.illustrate_me( bubble=TestLineStacked )
def weave(self, staff, index=0, **kwargs): my_line = calliope.Line() for repeat in range(self.repeats): my_phrase = ImaginaryPhrase() for i, p in enumerate(self.pattern): my_accent = abjad.CyclicTuple(self.pattern_accent)[i] my_fill_in = abjad.CyclicTuple(self.pattern_fill_in)[i] my_pulse_type = abjad.CyclicTuple(self.pattern_pulse_type)[i] my_accent = abjad.CyclicTuple(self.pattern_accent)[i] if my_pulse_type == "all": my_rhythm = (self.pulse_duration, ) * p elif my_pulse_type == "first": if my_fill_in: my_rhythm = (p * self.pulse_duration, ) else: my_rhythm = (self.pulse_duration, self.pulse_duration - p * self.pulse_duration) else: # other if my_fill_in: q, r = divmod(p, 2) my_rhythm = [ self.pulse_duration * 2 for pq in range(q) ] if r: my_rhythm.append(self.pulse_duration) else: my_rhythm = [[ self.pulse_duration, 0 - self.pulse_duration ][pj % 2] for pj in range(p)] my_cell = ImaginaryCell(rhythm=my_rhythm) if my_accent: my_cell.note_events[0].tag(">") my_phrase.append(my_cell) my_line.append(my_phrase) return my_line
def tenor_sax_half_counter_score(lib): return melody.Melody(calliope.LineBlock( calliope.Line(*lib("counter_i")[-4:]), ), fabric_staves=("ooa_tenor_sax", ))
# 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]) for i in range(3): rhythm_pounding = calliope.Line( calliope.Cell(rhythm=(-8, )), R4_POUNDING_CELL_BLOCK_A[i](), calliope.Cell(rhythm=(-4, )), calliope.Cell(rhythm=(-8, )), R4_POUNDING_CELL_BLOCK_B[i](), ) MOVE.append( calliope.Segment(rhythm_pounding(), rhythm_pounding(), rhythm_pounding(), rhythm_pounding(), rhythm_pounding())) # rhythm_angular = R5_ANGULAR_CELL_BLOCK.to_rhythm_line_block(10) # MOVE.append(rhythm_angular[0]) rhythm_beat_c = R6_BEAT_CELL_BLOCK_C.to_rhythm_line_block(10) MOVE.append(rhythm_beat_c[0]()) MOVE.append(rhythm_beat_c[1]())
# ) # ) 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()), ), fabric_staves=( "ooa_trombone", "ooa_bass_guitar", "ooa_bari_sax", "cco_trombone", ), ) swell_end = swell_hit.SwellHit( swell_duration=6, bookend_beats=(10, 0), fabric_staves=[s.name for s in s.staves], mask_staves=bass_line.fabric_staves + ("piano1", "piano2", "harp1", "harp2", "ooa_guitar", "ooa_bass_guitar", "cco_percussion", "ooa_drumset") +
from imaginary.scores import score from arrange_from import ArrangeFrom import chords class BandWindsArrangeChords(ArrangeFrom): chord_size = 3 def arrange_to_machine(self, selection, machine, staff_index, **kwargs): selection = selection.copy() calliope.CropChords(index=staff_index % self.chord_size)(selection) if len(self.smart_ranges) > staff_index: calliope.SmartRange( smart_range=self.smart_ranges[staff_index])(selection) calliope.Overlay(selection=selection)(machine) score = score.ImaginaryScore() score.staff_groups["band"].staves["flute"].append( calliope.Line(rhythm=(-24, 12), pitches=(None, 4))) af = BandWindsArrangeChords(selection=chords.cf_line) af(score) calliope.illustrate(score)
) osti1 = ditto.Ditto( osti_lb, fabric_staves=("ooa_bassoon", "cco_oboe1", "cco_oboe2", "cco_bassoon") + instrument_groups.get_instruments("sax")) # 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_U_LINE(), HOME_D_LINE(), calliope.Line(*BASS_LINE()[:-1]), ) my_melody = melody.Melody( melody_lb, fabric_staves=( "ooa_trumpet", "ooa_horn", "ooa_trombone", "cco_trumpet", "cco_horn", "cco_trombone", ), ) # TO DO: this doesn't work right... why?
pitch = [pitch_lists[l][t] for l in range(chord_size)], beats=self.event_beats, ) for t in range(self.times) ] scale = [0,2,4,5,7,9,11,12,14] # print(scale[1:4]) # TO DO... this moves up too fast! cf_line = calliope.Line( *[ ChordsCellFactory1(event_beats=0.25, choose_seq = ( ( (scale[i],), (-7,0,7) ), ( (scale[i+1:i+4]), (-7,0,7) ), ( (scale[i+4],), (-7,0,7) , ), ), times=16, seed=(i+1)*3 ) for i in range(5) ], ) calliope.illustrate(cf_line, as_midi=True)
counter_winds1 = melody.Melody( calliope.LineBlock(COUNTER_LINE_1(), # COUNTER_LINE_2(), ), fabric_staves=("ooa_flute", "ooa_clarinet", "cco_flute1", "cco_flute2", "cco_clarinet1", "cco_clarinet2")) counter_winds2 = melody.Melody( calliope.LineBlock(COUNTER_LINE_2(), # COUNTER_LINE_2(), ), fabric_staves=("ooa_flute", "ooa_clarinet", "cco_flute1", "cco_flute2", "cco_clarinet1", "cco_clarinet2"), ) end_counter = melody.Melody( calliope.LineBlock(calliope.Line(*COUNTER_LINE_2()[-2:]), ), fabric_staves=instrument_groups.get_instruments("sax", ) + ( "ooa_bassoon", "cco_oboe1", "cco_oboe2", "cco_bassoon", ), mask_staves=("ooa_bari_sax", )) strings_pulse1 = pulse.Pulse( fabric_staves=("cco_violin_ii", "cco_viola"), pulse_beats=8 * 4, pulse_duration=1, ) strings_pulse2 = pulse.Pulse( fabric_staves=("ooa_violin1", "ooa_violin2", "cco_violin_i",
import abjad, calliope from folktale.lines.sing_line import SingLine s = SingLine() SING_CHORDS_FROM_CELLS = calliope.Line(*[ calliope.Cell(factory=calliope.ChordsFromSelectable(p.cells), ) for p in s.phrases ]) SING_CHORDS_FROM_CELLS.events.setattrs(beats=1) calliope.SlurCells()(SING_CHORDS_FROM_CELLS) SING_CELLS_PITCHES = [c.pitch for c in SING_CHORDS_FROM_CELLS.events] SING_CELLS_PITCHES_GROUP_2 = [ sorted(set(a) | set(b)) for a, b in zip(SING_CELLS_PITCHES[:-1], SING_CELLS_PITCHES[1:]) ] SING_CHORDS_FROM_CELLS_GROUP_2 = calliope.Cell( pitches=(SING_CELLS_PITCHES_GROUP_2), rhythm=(1, ) * len(SING_CELLS_PITCHES_GROUP_2)) # SING_CHORDS_FROM_CELLS_GROUP_2.illustrate_me()
def weave(self, staff, index=0, **kwargs): my_line = calliope.Line(*[ p() for p in getattr(self.selectable.get_cyclic(index), "phrases") ]) calliope.Poke(selection=self.poke_selection)(my_line) return my_line
my_low_melody = melody.Melody(melody_lb, fabric_staves = ("ooa_bari_sax", "ooa_cello1", "ooa_cello2", "cco_viola", "cco_cello", ), ) off_strings = pulse_on_off_beat.PulseOnOffBeat( fabric_staves = ( "ooa_violin1", "ooa_violin2", "cco_violin_i", "cco_violin_ii" ), phrase_beats = (8,)*4, ) tenor_sax_half_counter = melody.Melody( calliope.LineBlock( calliope.Line(*COUNTER_LINE_2()[-4:]), ), fabric_staves = ("ooa_tenor_sax",) ) lb1 = rock.OstiLineBlock( phrase_count=4, slur_cells = True, ) sax_guitar_osti = ditto.Ditto(lb1, fabric_staves = ("ooa_alto_sax1", "ooa_alto_sax2", "ooa_guitar") ) # TO DO: copy pitches from osti winds_doves = dovetail.Dovetail( dove_event_count = 6,