def opposite_timespans(one_voice_timespan_list): for span1, span2 in zip(one_voice_timespan_list, one_voice_timespan_list[1:]): i = one_voice_timespan_list.index(span1) if i == 0: if span1.start_offset == 0: print("it is at the beginning") pass else: new_initial_span = abjad.AnnotatedTimespan( start_offset=(0, 1), stop_offset=span1.start_offset, annotation="Silence " + one_voice_timespan_list[0].annotation, ) one_voice_timespan_list.append(new_initial_span) timespans = abjad.TimespanList([span1, span2]) if timespans.all_are_contiguous is False: new_span = abjad.AnnotatedTimespan( start_offset=span1.stop_offset, stop_offset=span2.start_offset, annotation="Silence " + one_voice_timespan_list[i + 1].annotation, ) one_voice_timespan_list.append(new_span)
def __call__(self, counts, max_duration=None, translation=0, rotation=None, voice_name=None): if rotation: counts = counts[rotation:] + counts[:rotation] counts = self._ready_counts(counts, translation) denominator = self.denominator increment_total = 0 + translation timespan_list = abjad.TimespanList([]) for count in counts: if count < 0: increment_total += abs(count) continue start = increment_total stop = start + count if max_duration is not None: stop = (max_duration + start) if count > max_duration else stop timespan_list.append( abjad.AnnotatedTimespan( start_offset=(start, denominator), stop_offset=(stop, denominator), annotation=voice_name, )) increment_total += count return timespan_list
def talea_timespans(talea, advancement=0): talea = abjad.new(talea) talea = talea.advance(advancement) timespans = abjad.TimespanList([]) total_duration = 0 for duration in talea: start = total_duration stop = total_duration + abs(duration) if duration < 0: timespan = SilentTimespan(start_offset=start, stop_offset=stop, annotation=None) else: timespan = abjad.AnnotatedTimespan(start_offset=start, stop_offset=stop, annotation=None) timespans.append(timespan) total_duration += abs(duration) return timespans
def make_showable_list(timespan_lists): master_list = abjad.TimespanList([]) for i, timespan_list in enumerate(timespan_lists): for timespan in timespan_list: if isinstance(timespan, SilentTimespan): new_span = SilentTimespan( start_offset=timespan.start_offset, stop_offset=timespan.stop_offset, annotation=str(i + 1), ) else: new_span = abjad.AnnotatedTimespan( start_offset=timespan.start_offset, stop_offset=timespan.stop_offset, annotation=str(i + 1), ) master_list.extend([new_span]) master_list.sort() return master_list
self.voice_name = voice_name # Define an initial timespan structure, annotated with music specifiers. This # structure has not been split along meter boundaries. This structure does not # contain timespans explicitly representing silence. Here I make four, one # for each voice, using Python's list comprehension syntax to save some # space. print('Collecting timespans and rmakers ...') voice_1_timespan_list = abjad.TimespanList([ abjad.AnnotatedTimespan( start_offset=start_offset, stop_offset=stop_offset, annotation=MusicSpecifier( rhythm_maker=rhythm_maker, voice_name='Voice 1', ), ) for start_offset, stop_offset, rhythm_maker in [ [0, 1, musicmaker_one], [2, 3, musicmaker_one], ] ]) voice_5_timespan_list = abjad.TimespanList([ abjad.AnnotatedTimespan( start_offset=start_offset, stop_offset=stop_offset, annotation=MusicSpecifier( rhythm_maker=rhythm_maker, voice_name='Voice 5',
# structure has not been split along meter boundaries. This structure does not # contain timespans explicitly representing silence. Here I make four, one # for each voice, using Python's list comprehension syntax to save some # space. silence_maker = abjadext.rmakers.NoteRhythmMaker(division_masks=[ abjadext.rmakers.SilenceMask(pattern=abjad.index([0], 1), ), ], ) print('Collecting timespans and rmakers ...') voice_1_timespan_list = abjad.TimespanList([ abjad.AnnotatedTimespan( start_offset=start_offset, stop_offset=stop_offset, annotation=MusicSpecifier( rhythm_maker=rhythm_maker, voice_name='Voice 1', ), ) for start_offset, stop_offset, rhythm_maker in [ [(0, 4), (1, 4), rmaker_one], [(1, 4), (2, 4), rmaker_one], [(2, 4), (3, 4), rmaker_one], [(3, 4), (4, 4), rmaker_one], [(4, 4), (5, 4), rmaker_one], [(5, 4), (6, 4), rmaker_one], [(6, 4), (7, 4), rmaker_one], [(7, 4), (8, 4), rmaker_one], [(8, 4), (9, 4), rmaker_one], [(9, 4), (10, 4), rmaker_one], [(10, 4), (11, 4), rmaker_one], [(11, 4), (12, 4), rmaker_one],
if span1.annotation == "Mat_B" and span2.annotation == "Mat_B": if span1 <= span2: coincident_offsets.append(span1.start_offset) else: coincident_offsets.append(span2.start_offset) if span1.stop_offset > span2.stop_offset: coincident_offsets.append(abjad.Offset(span1.stop_offset)) # else: # print(span1.stop_offset) # print(span2.stop_offset) # coincident_offsets.append(abjad.Offset(span2.stop_offset)) coincident_offsets.sort() meters = [] for off1, off2 in zip(coincident_offsets, coincident_offsets[1:]): new_ts = abjad.AnnotatedTimespan(start_offset=off1, stop_offset=off2) final_list.append(new_ts) meters.append(abjad.Meter(new_ts.duration)) permitted_meters = [ # (7, 4), (5, 4), (4, 4), (3, 4), (3, 8), (11, 16), # (3, 16), ] # remove repeated coincident_offsets = list(dict.fromkeys(coincident_offsets))
self.music_maker = music_maker self.voice_name = voice_name # Define an initial timespan structure, annotated with music specifiers. This # structure has not been split along meter boundaries. This structure does not # contain timespans explicitly representing silence. Here I make four, one # for each voice, using Python's list comprehension syntax to save some # space. print('Collecting timespans and rmakers ...') voice_1_timespan_list = abjad.TimespanList([ abjad.AnnotatedTimespan( start_offset=start_offset, stop_offset=stop_offset, annotation=MusicSpecifier( music_maker=music_maker, voice_name='Voice 1', ), ) for start_offset, stop_offset, music_maker in [ [(0, 4), (2, 4), sopranino_musicmaker_one], [(2, 4), (3, 4), sopranino_musicmaker_one], [(5, 4), (7, 4), sopranino_musicmaker_one], [(7, 4), (8, 4), sopranino_musicmaker_one], [(12, 4), (14, 4), sopranino_musicmaker_two], [(14, 4), (15, 4), sopranino_musicmaker_two], [(17, 4), (18, 4), sopranino_musicmaker_one], [(18, 4), (20, 4), sopranino_musicmaker_one], [(28, 4), (31, 4), sopranino_musicmaker_two], [(33, 4), (35, 4), sopranino_musicmaker_two], [(35, 4), (36, 4), sopranino_musicmaker_two],
self.music_maker = music_maker self.voice_name = voice_name # Define an initial timespan structure, annotated with music specifiers. This # structure has not been split along meter boundaries. This structure does not # contain timespans explicitly representing silence. Here I make four, one # for each voice, using Python's list comprehension syntax to save some # space. print("Collecting timespans and rmakers ...") ###group one### voice_1_timespan_list = abjad.TimespanList([ abjad.AnnotatedTimespan( start_offset=start_offset, stop_offset=stop_offset, annotation=MusicSpecifier(music_maker=music_maker, voice_name="Voice 1"), ) for start_offset, stop_offset, music_maker in [ [(0, 8), (3, 8), flutemusicmaker_one], [(4, 8), (8, 8), flutemusicmaker_two], [(10, 8), (12, 8), flutemusicmaker_three], [(12, 8), (15, 8), flutemusicmaker_one], [(18, 8), (24, 8), flutemusicmaker_two], [(28, 8), (33, 8), flutemusicmaker_three], [(33, 8), (35, 8), flutemusicmaker_one], [(40, 8), (42, 8), flutemusicmaker_two], [(42, 8), (44, 8), flutemusicmaker_three], [(44, 8), (48, 8), flutemusicmaker_one], [(54, 8), (55, 8), flutemusicmaker_two], [(62, 8), (64, 8), flutemusicmaker_three], [(72, 8), (75, 8), flutemusicmaker_one],
import abjad ts_list = abjad.TimespanList() spans = [ abjad.AnnotatedTimespan(0, (1, 8), "hello"), abjad.AnnotatedTimespan((1, 8), (1, 4), "world"), ] print(spans) for _ in spans: ts_list.append(_) print(ts_list) durations = [timespan.duration for timespan in ts_list] print(durations) staff = abjad.Staff("c'4") print(abjad.lilypond(staff)) leaves = staff[:] abjad.mutate.split(leaves, durations, tie_split_notes=False) print(abjad.lilypond(staff))
import abjad #(set-default-paper-size "ledger") voice_1_timespan_list = abjad.TimespanList([ abjad.AnnotatedTimespan( start_offset=start_offset, stop_offset=stop_offset, annotation=music_maker ) for start_offset, stop_offset, music_maker in [ [(0, 8), (95, 8), 'GUERRERO Sections'], [(95, 8), (261, 8), 'GUERRERO Sections'], [(261, 8), (365, 8), 'GUERRERO Sections'], [(365, 8), (397, 8), 'GUERRERO Sections'], [(397, 8), (507, 8), 'GUERRERO Sections'], [(507, 8), (707, 8), 'GUERRERO Sections'], [(707, 8), (907, 8), 'GUERRERO Sections'], [(907, 8), (1003, 8), 'GUERRERO Sections'], [(1003, 8), (1099, 8), 'GUERRERO Sections'], [(1099, 8), (1211, 8), 'GUERRERO Sections'], [(1211, 8), (1267, 8), 'GUERRERO Sections'], # title - description - harmony - rhythm - tempo [(0, 8), (95, 8), 'Invocation - Shepard Tone - 24 Note Ascending Glissando - Talea - 60bpm'], [(95, 8), (261, 8), 'Section A - Sustained - Multiphonics - Sustained - 60bpm'], [(261, 8), (365, 8), 'Section B - Random Walk Glissando Swells - Centered Around Chord Tones - Talea - 90bpm'], [(365, 8), (397, 8), 'Section C - Transition - Increase Of Density - Talea - 90bpm'], [(397, 8), (507, 8), 'Section D - Tongue Slaps And Air Tones - Chord Tones - Talea - 108bpm'], [(507, 8), (707, 8), 'Section E - Trills And Fast Random Walks - Chord Tone Trills And Sustained Tones Drawn From Multiphonics - Even Divisions And Sustain - 90bpm'], [(707, 8), (907, 8), 'Section F - Trills And Sustains - Chord Tone Trills And Sustained Tones Drawn From Multiphonics - Talea - 90bpm'], [(907, 8), (1003, 8), 'Section G - Centered Around Chord Tones - Random Walk Glissando Swells - Talea - 90bpm'],
silence_talea=rmakers.Talea(counts=([13, 5, 1]), denominator=4), ) # temporary list temp_list = timespan_maker( music_specifiers=music_specifiers, target_timespan=target_timespan ) # the same algorythm generates durations for different voices using the annotation # the list bellow contains all the timespans the_list = muda.timespan.TimespanList() # translate evans classes to abjad AnnotatedTimespan for span in temp_list: new_span = abjad.AnnotatedTimespan( span.start_offset, span.stop_offset, annotation=span.voice_name, ) the_list.append(new_span) # this is a muda function that separate the timespan according to its annotation (its voice name) separated_list = the_list.SeparateTimespansByAnnotation() # another muda function that generates the silent timespans for each voice (the "negative", the opposite) for timespan_list in separated_list: timespan_list.OppositeTimespanList() timespan_list.sort() # convert to durations durations_list = [] # the lists bellow go to materials and are used as divisions in rhythm makers
import abjad ts_list = abjad.TimespanList() spans = [ abjad.AnnotatedTimespan(0, 2, "hello"), abjad.AnnotatedTimespan(0, 2, "world") ] for _ in spans: ts_list.append(_) location = [abjad.Offset(1)] ts_list.split_at_offsets(location) # annotation is preserved through splitting!