def test_Inspection_duration_03(): """ Clock duration equals duration divide by effective tempo. """ staff = abjad.Staff("c'8 d'8 e'8 f'8") mark = abjad.MetronomeMark(abjad.Duration(1, 4), 38) abjad.attach(mark, staff[0]) mark = abjad.MetronomeMark(abjad.Duration(1, 4), 42) abjad.attach(mark, staff[2]) abjad.Score([staff]) assert format(staff) == abjad.String.normalize(r""" \new Staff { \tempo 4=38 c'8 d'8 \tempo 4=42 e'8 f'8 } """) assert abjad.inspect(staff[0]).duration(in_seconds=True) == abjad.Duration( 15, 19) assert abjad.inspect(staff[1]).duration(in_seconds=True) == abjad.Duration( 15, 19) assert abjad.inspect(staff[2]).duration(in_seconds=True) == abjad.Duration( 5, 7) assert abjad.inspect(staff[3]).duration(in_seconds=True) == abjad.Duration( 5, 7)
def test_scoretools_Inspection_get_effective_13(): r'''Attaches metronome mark to staff. ''' staff = abjad.Staff("c'8 d'8 e'8 f'8") mark_1 = abjad.MetronomeMark(abjad.Duration(1, 8), 38) abjad.attach(mark_1, staff[0], context='Staff') mark_2 = abjad.MetronomeMark(abjad.Duration(1, 8), 42) abjad.attach(mark_2, staff[2], context='Staff') assert format(staff) == abjad.String.normalize(r''' \new Staff { \tempo 8=38 c'8 d'8 \tempo 8=42 e'8 f'8 } ''') assert abjad.inspect(staff).is_well_formed() assert abjad.inspect(staff[0]).get_effective(abjad.MetronomeMark) == mark_1 assert abjad.inspect(staff[1]).get_effective(abjad.MetronomeMark) == mark_1 assert abjad.inspect(staff[2]).get_effective(abjad.MetronomeMark) == mark_2 assert abjad.inspect(staff[3]).get_effective(abjad.MetronomeMark) == mark_2
def __init__(self, beatspan=None, offset_in_ms=None, search_tree=None, tempo=None): beatspan = beatspan or abjad.Duration(0) beatspan = abjad.Duration(beatspan) offset_in_ms = offset_in_ms or abjad.Duration(0) offset_in_ms = abjad.Offset(offset_in_ms) if search_tree is None: search_tree = UnweightedSearchTree() assert isinstance(search_tree, SearchTree) tempo = tempo or abjad.MetronomeMark((1, 4), 60) # tempo = abjad.MetronomeMark(tempo) if isinstance(tempo, tuple): tempo = abjad.MetronomeMark(*tempo) assert not tempo.is_imprecise q_events = [] q_grids = [] self._beatspan = beatspan self._distances = {} self._offset_in_ms = offset_in_ms self._q_events = q_events self._q_grid = None self._q_grids = q_grids self._search_tree = search_tree self._tempo = tempo
def test_Inspection_duration_01(): """ Container duration in seconds equals sum of leaf durations in seconds. """ staff = abjad.Staff("c'8 d'8 e'8 f'8") mark = abjad.MetronomeMark(abjad.Duration(1, 4), 38) abjad.attach(mark, staff[0]) mark = abjad.MetronomeMark(abjad.Duration(1, 4), 42) abjad.attach(mark, staff[2]) score = abjad.Score([staff]) assert format(score) == abjad.String.normalize(r""" \new Score << \new Staff { \tempo 4=38 c'8 d'8 \tempo 4=42 e'8 f'8 } >> """) assert abjad.inspect(score).duration(in_seconds=True) == abjad.Duration( 400, 133)
def __init__( self, beatspan: abjad.typings.Duration | None = None, offset_in_ms: abjad.Duration | int | None = None, search_tree: SearchTree | None = None, tempo: abjad.MetronomeMark | abjad.typings.Duration | None = None, ): beatspan = beatspan or abjad.Duration(0) beatspan = abjad.Duration(beatspan) offset_in_ms = offset_in_ms or abjad.Duration(0) offset_in_ms = abjad.Offset(offset_in_ms) if search_tree is None: search_tree = UnweightedSearchTree() assert isinstance(search_tree, SearchTree) tempo = tempo or abjad.MetronomeMark((1, 4), 60) # tempo = abjad.MetronomeMark(tempo) if isinstance(tempo, tuple): tempo = abjad.MetronomeMark(*tempo) assert not tempo.is_imprecise q_events: list[QEvent] = [] q_grids: tuple[QGrid, ...] = () self._beatspan = beatspan self._offset_in_ms = offset_in_ms self._q_events = q_events self._q_grid: QGrid | None = None self._q_grids = q_grids self._search_tree = search_tree self._tempo = tempo
def metronome_marks(): return dict([ ("39", abjad.MetronomeMark((1, 4), 39)), ("52", abjad.MetronomeMark((1, 4), 52)), ("91", abjad.MetronomeMark((1, 4), 91)), ("117", abjad.MetronomeMark((1, 4), 117)), ])
def test_QEventSequence_from_tempo_scaled_leaves_02(): staff = abjad.Staff([]) staff.append(abjad.Note(0, (1, 4))) staff.append(abjad.Rest((1, 4))) staff.append(abjad.Rest((1, 8))) staff.append(abjad.Note(1, (1, 8))) staff.append(abjad.Note(1, (1, 8))) staff.append(abjad.Note(2, (1, 8))) staff.append(abjad.Note(2, (1, 8))) staff.append(abjad.Note(3, (1, 8))) staff.append(abjad.Skip((1, 4))) staff.append(abjad.Rest((1, 4))) staff.append(abjad.Note(3, (1, 8))) staff.append(abjad.Chord([0, 1, 4], (1, 4))) abjad.tie(staff[3:5]) abjad.tie(staff[5:7]) tempo = abjad.MetronomeMark((1, 4), 58) abjad.attach(tempo, staff[0], context="Staff") tempo = abjad.MetronomeMark((1, 4), 77) abjad.attach(tempo, staff[9], context="Staff") leaves = abjad.select.leaves(staff) q_events = abjadext.nauert.QEventSequence.from_tempo_scaled_leaves(leaves) assert q_events == abjadext.nauert.QEventSequence( ( abjadext.nauert.PitchedQEvent( abjad.Offset(0, 1), (abjad.NamedPitch("c'"),) ), abjadext.nauert.SilentQEvent(abjad.Offset(30000, 29)), abjadext.nauert.PitchedQEvent( abjad.Offset(75000, 29), (abjad.NamedPitch("cs'"),) ), abjadext.nauert.PitchedQEvent( abjad.Offset(105000, 29), (abjad.NamedPitch("d'"),) ), abjadext.nauert.PitchedQEvent( abjad.Offset(135000, 29), (abjad.NamedPitch("ef'"),) ), abjadext.nauert.SilentQEvent(abjad.Offset(150000, 29)), abjadext.nauert.PitchedQEvent( abjad.Offset(15600000, 2233), (abjad.NamedPitch("ef'"),) ), abjadext.nauert.PitchedQEvent( abjad.Offset(16470000, 2233), ( abjad.NamedPitch("c'"), abjad.NamedPitch("cs'"), abjad.NamedPitch("e'"), ), ), abjadext.nauert.TerminalQEvent(abjad.Offset(18210000, 2233)), ) )
def post_process_voice_one(voice_one, score): # rehearsal mark markI = abjad.RehearsalMark(number=2) abjad.attach(markI, voice_one[0]) # metronome mark I abjad.attach( abjad.MetronomeMark(None, None, "Quasi Statico"), voice_one[0]) # metronome mark II abjad.attach( abjad.MetronomeMark(None, None, "Lento"), voice_one[6][0]) # metronome mark III abjad.attach( abjad.MetronomeMark(None, None, "Quasi Statico"), voice_one[13]) # metronome mark IV abjad.attach( abjad.MetronomeMark(None, None, "Lento"), voice_one[21]) # REGISTER TRANSPOSITION abjad.mutate(voice_one).transpose(-12) voice_one.append(abjad.Skip((3, 4))) voice_one.append(abjad.Skip((3, 4))) # text script (timbres) priority priority = abjad.LilyPondLiteral( r" \once \override Staff.TextScript.outside-staff-priority = #1100" + " " + r"\once \override Staff.TextScript.padding = #4") abjad.attach(priority, voice_one[-2]) # registers register_two = abjad.Markup( r"""\scale #'(0.5 . 0.5) \column{ \line{ \draw-circle #1.1 #0.3 ##t \draw-circle #1.1 #0.3 ##f } \line{ \draw-circle #1.1 #0.3 ##t \draw-circle #1.1 #0.3 ##t } \line{ \draw-circle #1.1 #0.3 ##f \draw-circle #1.1 #0.3 ##f } \line{ \draw-circle #1.1 #0.3 ##f \draw-circle #1.1 #0.3 ##f } }""", direction=abjad.Up) abjad.attach(register_two, voice_one[-2]) abjad.attach(abjad.Clef("bass"), voice_one[-8]) return voice_one
def test_MeasurewiseQSchema___getitem___02(): item_a = abjadext.nauert.MeasurewiseQSchemaItem( search_tree=abjadext.nauert.UnweightedSearchTree({2: None})) item_b = abjadext.nauert.MeasurewiseQSchemaItem(tempo=((1, 4), 76)) item_c = abjadext.nauert.MeasurewiseQSchemaItem(time_signature=(3, 4)) item_d = abjadext.nauert.MeasurewiseQSchemaItem( search_tree=abjadext.nauert.UnweightedSearchTree({5: None}), use_full_measure=True, ) schema = abjadext.nauert.MeasurewiseQSchema( { 2: item_a, 4: item_b, 7: item_c, 8: item_d }, search_tree=abjadext.nauert.UnweightedSearchTree({3: None}), tempo=((1, 8), 58), time_signature=(5, 8), use_full_measure=False, ) assert (schema[0] == schema[1] == { "search_tree": abjadext.nauert.UnweightedSearchTree({3: None}), "tempo": abjad.MetronomeMark((1, 8), 58), "time_signature": abjad.TimeSignature((5, 8)), "use_full_measure": False, }) assert (schema[2] == schema[3] == { "search_tree": abjadext.nauert.UnweightedSearchTree({2: None}), "tempo": abjad.MetronomeMark((1, 8), 58), "time_signature": abjad.TimeSignature((5, 8)), "use_full_measure": False, }) assert (schema[4] == schema[5] == schema[6] == { "search_tree": abjadext.nauert.UnweightedSearchTree({2: None}), "tempo": abjad.MetronomeMark((1, 4), 76), "time_signature": abjad.TimeSignature((5, 8)), "use_full_measure": False, }) assert schema[7] == { "search_tree": abjadext.nauert.UnweightedSearchTree({2: None}), "tempo": abjad.MetronomeMark((1, 4), 76), "time_signature": abjad.TimeSignature((3, 4)), "use_full_measure": False, } assert (schema[8] == schema[9] == schema[1000] == { "search_tree": abjadext.nauert.UnweightedSearchTree({5: None}), "tempo": abjad.MetronomeMark((1, 4), 76), "time_signature": abjad.TimeSignature((3, 4)), "use_full_measure": True, })
def test_MetronomeMark_attach_01(): score = abjad.Score( r"\new Staff { c'' d'' e'' f'' } \new Staff { c' d' e' f' }") mark_1 = abjad.MetronomeMark((1, 8), 52) mark_2 = abjad.MetronomeMark((1, 8), 73) abjad.attach(mark_1, score[0][0]) assert pytest.raises(Exception, 'abjad.attach(mark_2, score[1][0])')
def test_quantizationtools_MeasurewiseQSchema___getitem___02(): item_a = quantizationtools.MeasurewiseQSchemaItem( search_tree=abjad.quantizationtools.UnweightedSearchTree({2: None})) item_b = quantizationtools.MeasurewiseQSchemaItem(tempo=((1, 4), 76)) item_c = quantizationtools.MeasurewiseQSchemaItem(time_signature=(3, 4)) item_d = quantizationtools.MeasurewiseQSchemaItem( search_tree=abjad.quantizationtools.UnweightedSearchTree({5: None}), use_full_measure=True) schema = quantizationtools.MeasurewiseQSchema( { 2: item_a, 4: item_b, 7: item_c, 8: item_d }, search_tree=abjad.quantizationtools.UnweightedSearchTree({3: None}), tempo=((1, 8), 58), time_signature=(5, 8), use_full_measure=False, ) assert schema[0] == schema[1] == { 'search_tree': quantizationtools.UnweightedSearchTree({3: None}), 'tempo': abjad.MetronomeMark((1, 8), 58), 'time_signature': abjad.TimeSignature((5, 8)), 'use_full_measure': False, } assert schema[2] == schema[3] == { 'search_tree': quantizationtools.UnweightedSearchTree({2: None}), 'tempo': abjad.MetronomeMark((1, 8), 58), 'time_signature': abjad.TimeSignature((5, 8)), 'use_full_measure': False, } assert schema[4] == schema[5] == schema[6] == { 'search_tree': quantizationtools.UnweightedSearchTree({2: None}), 'tempo': abjad.MetronomeMark((1, 4), 76), 'time_signature': abjad.TimeSignature((5, 8)), 'use_full_measure': False, } assert schema[7] == { 'search_tree': quantizationtools.UnweightedSearchTree({2: None}), 'tempo': abjad.MetronomeMark((1, 4), 76), 'time_signature': abjad.TimeSignature((3, 4)), 'use_full_measure': False, } assert schema[8] == schema[9] == schema[1000] == { 'search_tree': quantizationtools.UnweightedSearchTree({5: None}), 'tempo': abjad.MetronomeMark((1, 4), 76), 'time_signature': abjad.TimeSignature((3, 4)), 'use_full_measure': True, }
def __init__( self, offset_in_ms=None, search_tree=None, time_signature=None, tempo=None, use_full_measure=False, ): offset_in_ms = offset_in_ms or 0 offset_in_ms = abjad.Offset(offset_in_ms) if search_tree is None: search_tree = UnweightedSearchTree() assert isinstance(search_tree, SearchTree) tempo = tempo or abjad.MetronomeMark((1, 4), 60) # tempo = abjad.MetronomeMark(tempo) if isinstance(tempo, tuple): tempo = abjad.MetronomeMark(*tempo) assert not tempo.is_imprecise time_signature = time_signature or (4, 4) time_signature = abjad.TimeSignature(time_signature) use_full_measure = bool(use_full_measure) beats = [] if use_full_measure: beatspan = time_signature.duration beat = QTargetBeat( beatspan=beatspan, offset_in_ms=offset_in_ms, search_tree=search_tree, tempo=tempo, ) beats.append(beat) else: beatspan = abjad.Duration(1, time_signature.denominator) current_offset_in_ms = offset_in_ms beatspan_duration_in_ms = tempo.duration_to_milliseconds(beatspan) for i in range(time_signature.numerator): beat = QTargetBeat( beatspan=beatspan, offset_in_ms=current_offset_in_ms, search_tree=search_tree, tempo=tempo, ) beats.append(beat) current_offset_in_ms += beatspan_duration_in_ms self._beats = tuple(beats) self._offset_in_ms = offset_in_ms self._search_tree = search_tree self._tempo = tempo self._time_signature = time_signature self._use_full_measure = use_full_measure
def test_quantizationtools_QEventSequence_from_tempo_scaled_leaves_02(): staff = abjad.Staff([]) staff.append(abjad.Note(0, (1, 4))) staff.append(abjad.Rest((1, 4))) staff.append(abjad.Rest((1, 8))) staff.append(abjad.Note(1, (1, 8))) staff.append(abjad.Note(1, (1, 8))) staff.append(abjad.Note(2, (1, 8))) staff.append(abjad.Note(2, (1, 8))) staff.append(abjad.Note(3, (1, 8))) staff.append(abjad.Skip((1, 4))) staff.append(abjad.Rest((1, 4))) staff.append(abjad.Note(3, (1, 8))) staff.append(abjad.Chord([0, 1, 4], (1, 4))) tie = abjad.Tie() abjad.attach(tie, staff[3:5]) tie = abjad.Tie() abjad.attach(tie, staff[5:7]) tempo = abjad.MetronomeMark((1, 4), 58) abjad.attach(tempo, staff[0], context='Staff') tempo = abjad.MetronomeMark((1, 4), 77) abjad.attach(tempo, staff[9], context='Staff') leaves = abjad.select(staff).leaves() q_events = quantizationtools.QEventSequence.from_tempo_scaled_leaves( leaves) assert q_events == quantizationtools.QEventSequence( (quantizationtools.PitchedQEvent(abjad.Offset(0, 1), (abjad.NamedPitch("c'"), )), quantizationtools.SilentQEvent(abjad.Offset(30000, 29)), quantizationtools.PitchedQEvent(abjad.Offset(75000, 29), (abjad.NamedPitch("cs'"), )), quantizationtools.PitchedQEvent(abjad.Offset(105000, 29), (abjad.NamedPitch("d'"), )), quantizationtools.PitchedQEvent(abjad.Offset(135000, 29), (abjad.NamedPitch("ef'"), )), quantizationtools.SilentQEvent(abjad.Offset(150000, 29)), quantizationtools.PitchedQEvent(abjad.Offset(15600000, 2233), (abjad.NamedPitch("ef'"), )), quantizationtools.PitchedQEvent(abjad.Offset(16470000, 2233), ( abjad.NamedPitch("c'"), abjad.NamedPitch("cs'"), abjad.NamedPitch("e'"), )), quantizationtools.TerminalQEvent(abjad.Offset(18210000, 2233))))
def test_quantizationtools_BeatwiseQSchemaItem___new___02(): item = abjad.quantizationtools.BeatwiseQSchemaItem(tempo=((1, 4), 60)) assert item.beatspan is None assert item.search_tree is None assert item.tempo == abjad.MetronomeMark((1, 4), 60)
def test_LilyPondParser__indicators__MetronomeMark_02(): target = abjad.Score([abjad.Staff([abjad.Note(0, 1)])]) leaves = abjad.select(target).leaves() mark = abjad.MetronomeMark((1, 4), 60) abjad.attach(mark, leaves[0], context="Staff") assert format(target) == abjad.String.normalize( r""" \new Score << \new Staff { \tempo 4=60 c'1 } >> """ ) parser = abjad.parser.LilyPondParser() result = parser(format(target)) assert format(target) == format(result) and target is not result leaves = abjad.select(result).leaves() leaf = leaves[0] marks = abjad.inspect(leaf).indicators(abjad.MetronomeMark) assert len(marks) == 1
def test_Tuplet_get_timespan_01(): staff = abjad.Staff(r"c'4 d'4 \times 2/3 { e'4 f'4 g'4 }") leaves = abjad.select(staff).leaves() score = abjad.Score([staff]) mark = abjad.MetronomeMark((1, 4), 60) abjad.attach(mark, leaves[0]) assert format(score) == abjad.String.normalize(r""" \new Score << \new Staff { \tempo 4=60 c'4 d'4 \times 2/3 { e'4 f'4 g'4 } } >> """) assert abjad.inspect(staff).timespan(in_seconds=True) == \ abjad.Timespan(0, 4) assert abjad.inspect(staff[0]).timespan(in_seconds=True) == \ abjad.Timespan(0, 1) assert abjad.inspect(staff[1]).timespan(in_seconds=True) == \ abjad.Timespan(1, 2) assert abjad.inspect(staff[-1]).timespan(in_seconds=True) == \ abjad.Timespan(2, 4)
def test_Inspection_timespan_26(): """ Offset seconds work with explicit metronome mark. """ staff = abjad.Staff("c'8 d'8 e'8 f'8") mark = abjad.MetronomeMark(abjad.Duration(1, 8), 48) abjad.attach(mark, staff[0], context='Staff') assert format(staff) == abjad.String.normalize(r""" \new Staff { \tempo 8=48 c'8 d'8 e'8 f'8 } """) start_offset = abjad.inspect( staff[0]).timespan(in_seconds=True).start_offset assert start_offset == abjad.Offset(0) start_offset = abjad.inspect( staff[1]).timespan(in_seconds=True).start_offset assert start_offset == abjad.Offset(5, 4)
def test_MeasurewiseQSchema___init___01(): item_a = abjadext.nauert.MeasurewiseQSchemaItem( search_tree=abjadext.nauert.UnweightedSearchTree({2: None})) item_b = abjadext.nauert.MeasurewiseQSchemaItem(tempo=((1, 4), 76)) item_c = abjadext.nauert.MeasurewiseQSchemaItem(time_signature=(3, 4)) item_d = abjadext.nauert.MeasurewiseQSchemaItem(use_full_measure=True) schema = abjadext.nauert.MeasurewiseQSchema( { 2: item_a, 4: item_b, 7: item_c, 8: item_d }, search_tree=abjadext.nauert.UnweightedSearchTree({3: None}), tempo=((1, 8), 58), time_signature=(5, 8), use_full_measure=False, ) assert len(schema.items) == 4 assert schema.search_tree == abjadext.nauert.UnweightedSearchTree( {3: None}) assert schema.tempo == abjad.MetronomeMark((1, 8), 58) assert schema.time_signature == abjad.TimeSignature((5, 8)) assert schema.use_full_measure is False
def test_lilypondproxytools_LilyPondGrobNameManager___setattr___18(): r'''Override LilyPond abjad.MetronomeMark grob. ''' staff = abjad.Staff("c'8 d'8 e'8 f'8") score = abjad.Score([staff]) tempo = abjad.MetronomeMark(abjad.Duration(1, 4), 58) abjad.attach(tempo, staff[0]) abjad.override(score).metronome_mark.color = 'red' assert format(score) == abjad.String.normalize(r''' \new Score \with { \override MetronomeMark.color = #red } << \new Staff { \tempo 4=58 c'8 d'8 e'8 f'8 } >> ''') assert abjad.inspect(score).is_well_formed()
def test_LilyPondGrobNameManager___setattr___13(): """ Override LilyPond abjad.MetronomeMark grob. """ staff = abjad.Staff("c'8 d'8 e'8 f'8") score = abjad.Score([staff]) tempo = abjad.MetronomeMark(abjad.Duration(1, 4), 58) abjad.attach(tempo, staff[0]) abjad.override(score).metronome_mark.color = "red" assert format(score) == abjad.String.normalize(r""" \new Score \with { \override MetronomeMark.color = #red } << \new Staff { \tempo 4=58 c'8 d'8 e'8 f'8 } >> """) assert abjad.inspect(score).wellformed()
def test_quantizationtools_BeatwiseQSchemaItem___new___05(): tempo = abjad.MetronomeMark(textual_indication='lento') pytest.raises( AssertionError, 'item = abjad.quantizationtools.BeatwiseQSchemaItem(tempo=tempo)', )
def test_QEventSequence_from_tempo_scaled_durations_01(): """ Test basic functionality. """ durations = [abjad.Duration(x) for x in [(1, 4), (1, 3), (1, 7), (2, 5), (3, 4)]] tempo = abjad.MetronomeMark((1, 4), 55) q_events = abjadext.nauert.QEventSequence.from_tempo_scaled_durations( durations, tempo ) assert q_events == abjadext.nauert.QEventSequence( ( abjadext.nauert.PitchedQEvent( abjad.Offset(0, 1), (abjad.NamedPitch("c'"),) ), abjadext.nauert.PitchedQEvent( abjad.Offset(12000, 11), (abjad.NamedPitch("c'"),) ), abjadext.nauert.PitchedQEvent( abjad.Offset(28000, 11), (abjad.NamedPitch("c'"),) ), abjadext.nauert.PitchedQEvent( abjad.Offset(244000, 77), (abjad.NamedPitch("c'"),) ), abjadext.nauert.PitchedQEvent( abjad.Offset(34400, 7), (abjad.NamedPitch("c'"),) ), abjadext.nauert.TerminalQEvent(abjad.Offset(630400, 77)), ) )
def test_mutate__fuse_leaves_by_immediate_parent_06(): """ Fuse leaves in logical tie with same immediate parent. """ voice = abjad.Voice(r"c'16 ~ c'16 ~ c'16 ~ c'16 ~ c'16 r16 r16 r16 r4 r4") abjad.attach(abjad.MetronomeMark((1, 4), 120), voice[0]) logical_tie = abjad.get.logical_tie(voice[0]) result = abjad.mutate._fuse_leaves_by_immediate_parent(logical_tie) assert abjad.lilypond(voice) == abjad.String.normalize( r""" \new Voice { \tempo 4=120 c'4 ~ c'16 r16 r16 r16 r4 r4 } """ ), print(abjad.lilypond(voice)) assert abjad.wf.wellformed(voice) assert len(result) == 1
def test_lilypondparsertools_LilyPondParser__indicators__MetronomeMark_04(): target = abjad.Score([abjad.Staff([abjad.Note(0, 1)])]) mark = abjad.MetronomeMark( reference_duration=(1, 4), units_per_minute=60, textual_indication="Like a majestic swan, alive with youth and vigour!", ) leaves = abjad.select(target).leaves() abjad.attach(mark, leaves[0], context='Staff') assert format(target) == abjad.String.normalize(r''' \new Score << \new Staff { \tempo "Like a majestic swan, alive with youth and vigour!" 4=60 c'1 } >> ''') parser = abjad.lilypondparsertools.LilyPondParser() result = parser(format(target)) assert format(target) == format(result) and target is not result leaves = abjad.select(result).leaves() leaf = leaves[0] marks = abjad.inspect(leaf).get_indicators(abjad.MetronomeMark) assert len(marks) == 1
def test_QEventSequence_from_tempo_scaled_durations_02(): """ Silences are fused. """ durations = [ abjad.Duration(x) for x in [(1, 4), (-1, 4), (1, 4), (1, 4), (-1, 4), (-1, 4), (1, 4)] ] tempo = abjad.MetronomeMark((1, 4), 77) q_events = abjadext.nauert.QEventSequence.from_tempo_scaled_durations( durations, tempo ) assert q_events == abjadext.nauert.QEventSequence( ( abjadext.nauert.PitchedQEvent( abjad.Offset(0, 1), (abjad.NamedPitch("c'"),) ), abjadext.nauert.SilentQEvent(abjad.Offset(60000, 77)), abjadext.nauert.PitchedQEvent( abjad.Offset(120000, 77), (abjad.NamedPitch("c'"),) ), abjadext.nauert.PitchedQEvent( abjad.Offset(180000, 77), (abjad.NamedPitch("c'"),) ), abjadext.nauert.SilentQEvent(abjad.Offset(240000, 77)), abjadext.nauert.PitchedQEvent( abjad.Offset(360000, 77), (abjad.NamedPitch("c'"),) ), abjadext.nauert.TerminalQEvent(abjad.Offset(60000, 11)), ) )
def test_lilypondparsertools_LilyPondParser__indicators__MetronomeMark_03(): target = abjad.Score([abjad.Staff([abjad.Note(0, 1)])]) leaves = abjad.select(target).leaves() mark = abjad.MetronomeMark((1, 4), (59, 63)) abjad.attach(mark, leaves[0], context='Staff') assert format(target) == abjad.String.normalize(r''' \new Score << \new Staff { \tempo 4=59-63 c'1 } >> ''') parser = abjad.lilypondparsertools.LilyPondParser() result = parser(format(target)) assert format(target) == format(result) and target is not result leaves = abjad.select(result).leaves() leaf = leaves[0] marks = abjad.inspect(leaf).get_indicators(abjad.MetronomeMark) assert len(marks) == 1
def test_lilypondparsertools_LilyPondParser__indicators__MetronomeMark_05(): target = abjad.Score([abjad.Staff([abjad.Note(0, 1)])]) mark = abjad.MetronomeMark( reference_duration=(1, 16), units_per_minute=(34, 55), textual_indication="Faster than a thousand suns", ) leaves = abjad.select(target).leaves() abjad.attach(mark, leaves[0], context='Staff') assert format(target) == abjad.String.normalize(r''' \new Score << \new Staff { \tempo "Faster than a thousand suns" 16=34-55 c'1 } >> ''') parser = abjad.lilypondparsertools.LilyPondParser() result = parser(format(target)) assert format(target) == format(result) and target is not result leaves = abjad.select(result).leaves() leaf = leaves[0] marksn = abjad.inspect(leaf).get_indicators(abjad.MetronomeMark) assert len(marksn) == 1
def test_LilyPondParser__indicators__MetronomeMark_01(): target = abjad.Score([abjad.Staff([abjad.Note(0, 1)])]) mark = abjad.MetronomeMark(textual_indication="As fast as possible") abjad.attach(mark, target[0][0], context="Staff") assert abjad.lilypond(target) == abjad.String.normalize( r""" \new Score << \new Staff { \tempo "As fast as possible" c'1 } >> """ ) parser = abjad.parser.LilyPondParser() result = parser(abjad.lilypond(target)) assert abjad.lilypond(target) == abjad.lilypond(result) and target is not result leaves = abjad.select(result).leaves() leaf = leaves[0] marks = abjad.get.indicators(leaf, abjad.MetronomeMark) assert len(marks) == 1
def test_MeasurewiseQSchemaItem___new___04(): item = abjadext.nauert.MeasurewiseQSchemaItem( tempo=((1, 4), 57), time_signature=(6, 8) ) assert item.beatspan == abjad.Duration(1, 8) assert item.search_tree is None assert item.tempo == abjad.MetronomeMark((1, 4), 57) assert item.time_signature == abjad.TimeSignature((6, 8))
def test_BeatwiseQSchema___init___02(): schema = abjadext.nauert.BeatwiseQSchema() assert len(schema.items) == 0 assert schema.beatspan == abjad.Duration(1, 4) assert schema.search_tree == abjadext.nauert.UnweightedSearchTree() assert schema.tempo == abjad.MetronomeMark((1, 4), 60)