Ejemplo n.º 1
0
def test_Mutation_fuse_05():
    """
    Fuses leaves with differing LilyPond multipliers.
    """

    staff = abjad.Staff([abjad.Skip((1, 1)), abjad.Skip((1, 1))])
    staff[0].multiplier = (1, 16)
    staff[1].multiplier = (5, 16)

    assert format(staff) == abjad.String.normalize(r"""
        \new Staff
        {
            s1 * 1/16
            s1 * 5/16
        }
        """), print(format(staff))

    assert abjad.inspect(staff).duration() == abjad.Duration(3, 8)

    abjad.mutate(staff[:]).fuse()

    assert format(staff) == abjad.String.normalize(r"""
        \new Staff
        {
            s1 * 3/8
        }
        """)

    assert abjad.inspect(staff).duration() == abjad.Duration(3, 8)
    assert abjad.inspect(staff).wellformed()
Ejemplo n.º 2
0
def pad_voices_with_grace_skips(voices):
    """
    Pad voices with grace skips to fix the spacing issue with full-length
    tuplet brackets.
    """
    longest_durations = _get_longest_durations(voices)
    for voice in voices:
        for measure_number in longest_durations:
            first_leaf = abjad.get.leaf(voice[measure_number], 0)
            multiplier = _get_tuplet_multiplier(first_leaf)
            stored_duration, stored_multiplier = longest_durations[
                measure_number]
            if abjad.get.grace(first_leaf):
                container = abjad.get.parentage(first_leaf).parent
                assert isinstance(container, abjad.BeforeGraceContainer)
                duration = abjad.get.duration(container)
                if duration < stored_duration:
                    container.insert(0, abjad.Skip(stored_duration - duration))
                if multiplier != stored_multiplier:
                    multiplier = stored_multiplier / multiplier
                    multiplier = multiplier.reduce()
                    if multiplier != 1:
                        for leaf in container:
                            leaf.multiplier = multiplier
            else:
                multiplier = stored_multiplier / multiplier
                multiplier = multiplier.reduce()
                if multiplier == 1:
                    skip = abjad.Skip(stored_duration)
                else:
                    skip = abjad.Skip(stored_duration, multiplier=multiplier)
                container = abjad.BeforeGraceContainer([skip])
                abjad.attach(container, first_leaf)
Ejemplo n.º 3
0
def test_scoretools_Mutation_fuse_05():
    r'''Fuses leaves with differing LilyPond multipliers.
    '''

    staff = abjad.Staff([abjad.Skip((1, 1)), abjad.Skip((1, 1))])
    abjad.attach(abjad.Multiplier(1, 16), staff[0])
    abjad.attach(abjad.Multiplier(5, 16), staff[1])

    assert format(staff) == abjad.String.normalize(r'''
        \new Staff
        {
            s1 * 1/16
            s1 * 5/16
        }
        ''')

    assert abjad.inspect(staff).get_duration() == abjad.Duration(3, 8)

    abjad.mutate(staff[:]).fuse()

    assert format(staff) == abjad.String.normalize(r'''
        \new Staff
        {
            s1 * 3/8
        }
        ''')

    assert abjad.inspect(staff).get_duration() == abjad.Duration(3, 8)
    assert abjad.inspect(staff).is_well_formed()
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
Ejemplo n.º 5
0
def test_scoretools_Staff___setitem___01():

    staff = abjad.Staff([
        abjad.Note("c'4"),
        abjad.Rest((1, 4)),
        abjad.Chord([2, 3, 4], (1, 4)),
        abjad.Skip((1, 4)),
        abjad.Tuplet((4, 5), 4 * abjad.Note(0, (1, 16))),
    ])

    assert len(staff) == 5
    assert abjad.inspect(staff).is_well_formed()
    assert isinstance(staff[0], abjad.Note)
    assert isinstance(staff[1], abjad.Rest)
    assert isinstance(staff[2], abjad.Chord)
    assert isinstance(staff[3], abjad.Skip)
    assert isinstance(staff[4], abjad.Tuplet)
    staff[1] = abjad.Chord([12, 13, 15], (1, 4))
    assert len(staff) == 5
    assert abjad.inspect(staff).is_well_formed()
    assert isinstance(staff[0], abjad.Note)
    assert isinstance(staff[1], abjad.Chord)
    assert isinstance(staff[2], abjad.Chord)
    assert isinstance(staff[3], abjad.Skip)
    assert isinstance(staff[4], abjad.Tuplet)
    staff[0] = abjad.Rest((1, 4))
    assert len(staff) == 5
    assert abjad.inspect(staff).is_well_formed()
    assert isinstance(staff[0], abjad.Rest)
    assert isinstance(staff[1], abjad.Chord)
    assert isinstance(staff[2], abjad.Chord)
    assert isinstance(staff[3], abjad.Skip)
    assert isinstance(staff[4], abjad.Tuplet)
    staff[-2] = abjad.Tuplet((2, 3), 3 * abjad.Note(0, (1, 8)))
    assert len(staff) == 5
    assert abjad.inspect(staff).is_well_formed()
    assert isinstance(staff[0], abjad.Rest)
    assert isinstance(staff[1], abjad.Chord)
    assert isinstance(staff[2], abjad.Chord)
    assert isinstance(staff[3], abjad.Tuplet)
    assert isinstance(staff[4], abjad.Tuplet)
    staff[-1] = abjad.Note(13, (1, 4))
    assert len(staff) == 5
    assert abjad.inspect(staff).is_well_formed()
    assert isinstance(staff[0], abjad.Rest)
    assert isinstance(staff[1], abjad.Chord)
    assert isinstance(staff[2], abjad.Chord)
    assert isinstance(staff[3], abjad.Tuplet)
    assert isinstance(staff[4], abjad.Note)
    staff[-3] = abjad.Skip((1, 4))
    assert len(staff) == 5
    assert abjad.inspect(staff).is_well_formed()
    assert isinstance(staff[0], abjad.Rest)
    assert isinstance(staff[1], abjad.Chord)
    assert isinstance(staff[2], abjad.Skip)
    assert isinstance(staff[3], abjad.Tuplet)
    assert isinstance(staff[4], abjad.Note)
Ejemplo n.º 6
0
def test_Skip___eq___01():

    skip_1 = abjad.Skip((1, 4))
    skip_2 = abjad.Skip((1, 4))
    skip_3 = abjad.Skip((1, 8))

    assert not skip_1 == skip_2
    assert not skip_1 == skip_3
    assert not skip_2 == skip_3
Ejemplo n.º 7
0
def test_Staff___setitem___01():

    staff = abjad.Staff([
        abjad.Note("c'4"),
        abjad.Rest((1, 4)),
        abjad.Chord([2, 3, 4], (1, 4)),
        abjad.Skip((1, 4)),
        abjad.Tuplet((4, 5), "c'16 c'16 c'16 c'16"),
    ])

    assert len(staff) == 5
    assert abjad.wf.wellformed(staff)
    assert isinstance(staff[0], abjad.Note)
    assert isinstance(staff[1], abjad.Rest)
    assert isinstance(staff[2], abjad.Chord)
    assert isinstance(staff[3], abjad.Skip)
    assert isinstance(staff[4], abjad.Tuplet)
    staff[1] = abjad.Chord([12, 13, 15], (1, 4))
    assert len(staff) == 5
    assert abjad.wf.wellformed(staff)
    assert isinstance(staff[0], abjad.Note)
    assert isinstance(staff[1], abjad.Chord)
    assert isinstance(staff[2], abjad.Chord)
    assert isinstance(staff[3], abjad.Skip)
    assert isinstance(staff[4], abjad.Tuplet)
    staff[0] = abjad.Rest((1, 4))
    assert len(staff) == 5
    assert abjad.wf.wellformed(staff)
    assert isinstance(staff[0], abjad.Rest)
    assert isinstance(staff[1], abjad.Chord)
    assert isinstance(staff[2], abjad.Chord)
    assert isinstance(staff[3], abjad.Skip)
    assert isinstance(staff[4], abjad.Tuplet)
    staff[-2] = abjad.Tuplet((2, 3), "c'8 c'8 c'8")
    assert len(staff) == 5
    assert abjad.wf.wellformed(staff)
    assert isinstance(staff[0], abjad.Rest)
    assert isinstance(staff[1], abjad.Chord)
    assert isinstance(staff[2], abjad.Chord)
    assert isinstance(staff[3], abjad.Tuplet)
    assert isinstance(staff[4], abjad.Tuplet)
    staff[-1] = abjad.Note(13, (1, 4))
    assert len(staff) == 5
    assert abjad.wf.wellformed(staff)
    assert isinstance(staff[0], abjad.Rest)
    assert isinstance(staff[1], abjad.Chord)
    assert isinstance(staff[2], abjad.Chord)
    assert isinstance(staff[3], abjad.Tuplet)
    assert isinstance(staff[4], abjad.Note)
    staff[-3] = abjad.Skip((1, 4))
    assert len(staff) == 5
    assert abjad.wf.wellformed(staff)
    assert isinstance(staff[0], abjad.Rest)
    assert isinstance(staff[1], abjad.Chord)
    assert isinstance(staff[2], abjad.Skip)
    assert isinstance(staff[3], abjad.Tuplet)
    assert isinstance(staff[4], abjad.Note)
Ejemplo n.º 8
0
def test_Skip___ne___01():

    skip_1 = abjad.Skip((1, 4))
    skip_2 = abjad.Skip((1, 4))
    skip_3 = abjad.Skip((1, 8))

    assert skip_1 != skip_2
    assert skip_1 != skip_3
    assert skip_2 != skip_3
Ejemplo n.º 9
0
def see_pitches(pitches):
    G_staff = abjad.Staff()
    F_staff = abjad.Staff()
    staff_group = abjad.StaffGroup([G_staff, F_staff])
    pitch_range = abjad.pitch.PitchRange("[C4, +inf]")
    for pitch in pitches:
        test = pitch in pitch_range
        if test is True:
            note = abjad.Note.from_pitch_and_duration(pitch, (1, 1))
            G_staff.append(note)
            F_staff.append(abjad.Skip((1, 1)))
        if test is False:
            note = abjad.Note.from_pitch_and_duration(pitch, (1, 1))
            G_staff.append(abjad.Skip((1, 1)))
            F_staff.append(note)

    for i, note in enumerate(F_staff):
        abjad.attach(abjad.Markup(i), note)

    clef3 = abjad.Clef("treble^8")
    clef3_range = abjad.pitch.PitchRange("[G6, +inf]")
    clef2 = abjad.Clef("treble")
    clef2_range = abjad.pitch.PitchRange("[E4, E5]")
    clef1 = abjad.Clef("bass")
    clef1_range = abjad.pitch.PitchRange("[A1, G3]")
    clef0 = abjad.Clef("bass_8")
    clef0_range = abjad.pitch.PitchRange("[-inf, C1]")

    selection = abjad.select(G_staff).leaves()
    for i, leaf in enumerate(selection):
        if isinstance(leaf, abjad.Note):
            test3 = leaf in clef3_range
            test2 = leaf in clef2_range
            if test3 is True:
                abjad.attach(clef3, G_staff[i])
            elif test2 is True:
                abjad.attach(clef2, G_staff[i])

    selection2 = abjad.select(F_staff).leaves()
    for i, leaf in enumerate(selection2):
        if isinstance(leaf, abjad.Note):
            test3 = leaf in clef3_range
            test2 = leaf in clef2_range
            test1 = leaf in clef1_range
            test0 = leaf in clef0_range
            if test2 is True:
                abjad.attach(clef2, F_staff[i])
            elif test1 is True:
                abjad.attach(clef1, F_staff[i])
            elif test0 is True:
                abjad.attach(clef0, F_staff[i])

    abjad.show(staff_group)

    return staff_group
Ejemplo n.º 10
0
def test_Skip___init___05():

    note = abjad.Note(2, (1, 8))
    duration = note.written_duration
    skip = abjad.Skip(note)
    assert isinstance(skip, abjad.Skip)
    # check that attributes have not been removed or added.
    assert dir(note) == dir(abjad.Note("c'4"))
    assert dir(skip) == dir(abjad.Skip((1, 4)))
    assert abjad.lilypond(skip) == "s8"
    assert skip._parent is None
    assert skip.written_duration == duration
def test_scoretools_Note___init___12():
    r'''Initializes notes from skip.
    '''

    skip = abjad.Skip((1, 8))
    duration = skip.written_duration
    note = abjad.Note(skip)

    assert isinstance(note, abjad.Note)
    assert dir(skip) == dir(abjad.Skip((1, 4)))
    assert dir(note) == dir(abjad.Note("c'4"))
    assert note._parent is None
    assert note.written_duration == duration
Ejemplo n.º 12
0
def test_Skip___init___08():
    """
    Initialize skip from unincorporaed rest.
    """

    rest = abjad.Rest((1, 8))
    duration = rest.written_duration
    skip = abjad.Skip(rest)
    assert isinstance(skip, abjad.Skip)
    # check that attributes have not been removed or added.
    assert dir(rest) == dir(abjad.Rest((1, 4)))
    assert dir(skip) == dir(abjad.Skip((1, 4)))
    assert skip._parent is None
    assert skip.written_duration == duration
Ejemplo n.º 13
0
def test_Skip___init___02():
    """
    Initialize skip from containerize note.
    """

    chord = abjad.Chord([2, 3, 4], (1, 4))
    duration = chord.written_duration
    skip = abjad.Skip(chord)
    assert isinstance(skip, abjad.Skip)
    # check that attributes have not been removed or added.
    assert dir(chord) == dir(abjad.Chord([2, 3, 4], (1, 4)))
    assert dir(skip) == dir(abjad.Skip((1, 4)))
    assert skip._parent is None
    assert skip.written_duration == duration
Ejemplo n.º 14
0
    def __call__(self, time_signatures):
        r'''Calls measure-maker on `time_signatures`.

        Returns measures.
        '''
        import abjad
        measures = []
        for time_signature in time_signatures:
            time_signature = abjad.TimeSignature(time_signature)
            measure = abjad.Measure(
                time_signature,
                implicit_scaling=self.implicit_scaling,
                )
            measures.append(measure)
        for i, measure in enumerate(measures):
            skip = abjad.Skip(1)
            # allow zero-update iteration
            time_signature = measure.time_signature
            duration = time_signature.duration
            if measure.implicit_scaling:
                implied_prolation = time_signature.implied_prolation
                multiplier = duration.__div__(implied_prolation)
            else:
                multiplier = abjad.Multiplier(duration)
            abjad.attach(multiplier, skip)
            measure[:] = [skip]
            # REMOVE: spanners attach only to leaves:
            #for spanner in measure._get_spanners():
            #    spanner._remove(measure)
        return abjad.select(measures)
Ejemplo n.º 15
0
def test_Skip___init___01():
    """
    Initialize skip from LilyPond input string.
    """

    skip = abjad.Skip("s8.")
    assert isinstance(skip, abjad.Skip)
Ejemplo n.º 16
0
def make_skips(score, time_signatures):
    site = "muda.functions.MakeSkips()"
    tag = abjad.Tag(site)
    print(str(tag))

    if isinstance(time_signatures[0], abjad.TimeSignature):
        time_signatures_abjad = time_signatures
        in_time_signatures = [_.pair for _ in time_signatures]
    else:
        in_time_signatures = time_signatures
        time_signatures_abjad = [
            abjad.TimeSignature(_) for _ in in_time_signatures
        ]

    for time_sig in time_signatures_abjad:
        skip = abjad.Skip(1, multiplier=(time_sig.pair))
        score["Global_Context"].append(skip)

    # select skips to attach TIME SIGNATURES
    for i, element in enumerate(in_time_signatures):
        previous_element = time_signatures[i - 1] if i > 0 else None
        current_element = element

        # if current_element != previous_element:
        a = in_time_signatures.index(current_element)
        abjad.attach(time_signatures_abjad[a],
                     score["Global_Context"][i],
                     tag=tag)
def test_scoretools_Skip___setattr___01():
    r'''Slots constrain skip attributes.
    '''

    skip = abjad.Skip((1, 4))

    assert pytest.raises(AttributeError, "skip.foo = 'bar'")
def test_LilyPondParser__leaves__Skip_01():

    target = abjad.Skip((3, 8))
    parser = abjad.parser.LilyPondParser()
    result = parser("{ %s }" % abjad.lilypond(target))
    assert (abjad.lilypond(target) == abjad.lilypond(result[0])
            and target is not result[0])
Ejemplo n.º 19
0
def test_Skip___setattr___01():
    """
    Slots constrain skip attributes.
    """

    skip = abjad.Skip((1, 4))

    assert pytest.raises(AttributeError, "skip.foo = 'bar'")
Ejemplo n.º 20
0
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)),
        )
    )
Ejemplo n.º 21
0
    def delete(
        self,
        select,
        material_name=None,
        replace_with_rests=False,
        replace_with_skips=False,
    ):
        """Delete leaves by index.

        Use ``material_name`` to delete a leaf in a
        specific material. Use ``replace_with_rests`` or
        ``replace_with_skips`` to replace leaves by rests or skips.
        """

        if isinstance(material_name, str):
            material_name = [material_name]

        if material_name is None:
            selectables = [self.container]
        else:
            selectables = []
            for mat_name in material_name:
                selectable = self.select_material(self.container,
                                                  material_name=mat_name)
                selectables.append(selectable)

        for i, name in enumerate(material_name):
            selectable = self.select_material(self.container, name)
            containers = abjad.select.components(selectable, abjad.Container)
            # print(containers)
            for container in containers:
                if ((not isinstance(container, abjad.Tuplet or abjad.Voice))
                        and (container.name and container.identifier)
                        and (name in container.name)):
                    # print("each container")
                    # print(container)

                    selection = select(container)

                    try:
                        iter(selection)
                    except:
                        selection = [selection]

                    for leaf in selection:
                        # print(leaf)
                        if replace_with_skips is True:
                            abjad.mutate.replace(
                                leaf,
                                abjad.Skip(leaf.written_duration),
                            )
                        elif replace_with_rests is True:
                            abjad.mutate.replace(
                                leaf,
                                abjad.Rest(leaf.written_duration),
                            )
                        else:
                            del leaf
Ejemplo n.º 22
0
    def _make_global_context(self):
        print("Making global context ...")

        for time_signature in self.time_signatures:
            skip = abjad.Skip(1, multiplier=(time_signature))
            abjad.attach(time_signature,
                         skip,
                         tag=abjad.Tag("scaling time signatures"))
            self.score_template["Global Context"].append(skip)
Ejemplo n.º 23
0
def test_Skip___setattr___01():
    """
    Slots constrain skip attributes.
    """

    skip = abjad.Skip((1, 4))

    with pytest.raises(AttributeError):
        skip.foo = "bar"
Ejemplo n.º 24
0
def test_Skip___init___06():

    tuplet = abjad.Tuplet((2, 3), "c'8 c'8 c'8")
    duration = tuplet[0].written_duration
    skip = abjad.Skip(tuplet[0])
    assert isinstance(tuplet[0], abjad.Note)
    assert isinstance(skip, abjad.Skip)
    assert tuplet[0]._parent is tuplet
    assert tuplet[0].written_duration == duration
Ejemplo n.º 25
0
def post_process_voice_one(voice_one, score):
    print("post processing voice one")

    voice_one[-2] = abjad.Skip((3, 4))
    voice_one[-1] = abjad.Skip((3, 4))

    # change staff
    voice_one = score['RH_Voice_One']
    rh_staff = score['Piano_Staff'][0]
    lh_staff = score['Piano_Staff'][1]

    staff_change1 = abjad.StaffChange(lh_staff)
    staff_change2 = abjad.StaffChange(rh_staff)
    abjad.attach(staff_change1, voice_one[6][0])

    # change clef
    clef1 = abjad.Clef("bass")
    abjad.attach(clef1, voice_one[8])

    # tempos
    lento = abjad.MetronomeMark(None, None, "Lento")
    quasi_statico = abjad.MetronomeMark(None, None, "Quasi Statico")
    # metronome mark I
    abjad.attach(lento, voice_one[0])
    # metronome mark II
    abjad.attach(quasi_statico, voice_one[8])
    # metronome mark III
    abjad.attach(lento, voice_one[15][0])

    # metronome mark IV
    abjad.attach(abjad.MetronomeMark(None, None, "subito Quasi Statico"),
                 voice_one[18])
    # metronome mark V
    abjad.attach(lento, voice_one[22])
    # metronome mark VI
    abjad.attach(abjad.MetronomeMark(None, None, "più mosso"), voice_one[25])

    # rehearsal mark
    markI = abjad.RehearsalMark(number=3)
    abjad.attach(markI, voice_one[0])
    scheme = abjad.Scheme("format-mark-box-alphabet")
    abjad.setting(score).markFormatter = scheme
    return voice_one
Ejemplo n.º 26
0
def test_QEventSequence_from_tempo_scaled_leaves_01():

    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), 55)

    leaves = abjad.select.leaves(staff)
    q_events = abjadext.nauert.QEventSequence.from_tempo_scaled_leaves(leaves, tempo)

    assert q_events == abjadext.nauert.QEventSequence(
        (
            abjadext.nauert.PitchedQEvent(
                abjad.Offset(0, 1), (abjad.NamedPitch("c'"),)
            ),
            abjadext.nauert.SilentQEvent(abjad.Offset(12000, 11)),
            abjadext.nauert.PitchedQEvent(
                abjad.Offset(30000, 11), (abjad.NamedPitch("cs'"),)
            ),
            abjadext.nauert.PitchedQEvent(
                abjad.Offset(42000, 11), (abjad.NamedPitch("d'"),)
            ),
            abjadext.nauert.PitchedQEvent(
                abjad.Offset(54000, 11), (abjad.NamedPitch("ef'"),)
            ),
            abjadext.nauert.SilentQEvent(abjad.Offset(60000, 11)),
            abjadext.nauert.PitchedQEvent(
                abjad.Offset(84000, 11), (abjad.NamedPitch("ef'"),)
            ),
            abjadext.nauert.PitchedQEvent(
                abjad.Offset(90000, 11),
                (
                    abjad.NamedPitch("c'"),
                    abjad.NamedPitch("cs'"),
                    abjad.NamedPitch("e'"),
                ),
            ),
            abjadext.nauert.TerminalQEvent(abjad.Offset(102000, 11)),
        )
    )
Ejemplo n.º 27
0
def test_Skip___init___07():
    """
    Initialize skip from beamed note.
    """

    staff = abjad.Staff("c'8 c'8 c'8")
    abjad.beam(staff[:])
    skip = abjad.Skip(staff[0])
    assert isinstance(staff[0], abjad.Note)
    assert isinstance(skip, abjad.Skip)
    assert staff[0]._parent is staff
def test_scoretools_Skip___copy___01():
    r'''Copy skip.
    '''

    skip_1 = abjad.Skip((1, 4))
    skip_2 = copy.copy(skip_1)

    assert isinstance(skip_1, abjad.Skip)
    assert isinstance(skip_2, abjad.Skip)
    assert format(skip_1) == format(skip_2)
    assert skip_1 is not skip_2
Ejemplo n.º 29
0
 def _handle_time_signatures(self):
     if not self.metronome_marks:
         return
     context = self._score["Global_Skips"]
     skips = []
     for item in self.time_signatures:
         skip = abjad.Skip(1, multiplier=item)
         time_signature = abjad.TimeSignature(item)
         abjad.attach(time_signature, skip, context="Score")
         skips.append(skip)
     context.extend(skips)
Ejemplo n.º 30
0
 def _make_skips(written_duration, multiplied_durations):
     import abjad
     skips = []
     written_duration = abjad.Duration(written_duration)
     for multiplied_duration in multiplied_durations:
         multiplied_duration = abjad.Duration(multiplied_duration)
         skip = abjad.Skip(written_duration)
         multiplier = multiplied_duration / written_duration
         abjad.attach(multiplier, skip)
         skips.append(skip)
     return abjad.select(skips)