示例#1
0
def test_NoteHeadList_append_01():
    """
    Append tweaked note-head to chord.
    """

    chord = abjad.Chord("<c' d'>4")
    note_head = abjad.NoteHead("b'")
    abjad.tweak(note_head).style = "harmonic"
    chord.note_heads.append(note_head)

    assert format(chord) == abjad.String.normalize(r"""
        <
            c'
            d'
            \tweak style #'harmonic
            b'
        >4
        """)

    assert note_head._client is chord
示例#2
0
def test_Chord___deepcopy___01():
    """
    Chord deepchopies note-heads.
    """

    chord_1 = abjad.Chord("<c' e' g'>4")
    abjad.tweak(chord_1.note_heads[0]).color = "red"
    chord_2 = copy.deepcopy(chord_1)

    assert format(chord_1) == abjad.String.normalize(r"""
        <
            \tweak color #red
            c'
            e'
            g'
        >4
        """)

    assert format(chord_2) == abjad.String.normalize(r"""
        <
            \tweak color #red
            c'
            e'
            g'
        >4
        """)

    assert chord_2.note_heads[0]._client is chord_2
    assert chord_2.note_heads[1]._client is chord_2
    assert chord_2.note_heads[2]._client is chord_2

    assert format(chord_1) == format(chord_2)
    assert chord_1 is not chord_2

    assert chord_1.note_heads[0] == chord_2.note_heads[0]
    assert chord_1.note_heads[1] == chord_2.note_heads[1]
    assert chord_1.note_heads[2] == chord_2.note_heads[2]

    assert chord_1.note_heads[0] is not chord_2.note_heads[0]
    assert chord_1.note_heads[1] is not chord_2.note_heads[1]
    assert chord_1.note_heads[2] is not chord_2.note_heads[2]
示例#3
0
def make_desordre_cell(pitches):
    """
    Makes a Désordre cell.
    """

    notes = [abjad.Note(pitch, (1, 8)) for pitch in pitches]
    notes = abjad.Selection(notes)
    abjad.beam(notes)
    abjad.slur(notes)
    clef = abjad.Dynamic('f')
    abjad.attach(clef, notes[0])
    dynamic = abjad.Dynamic('p')
    abjad.attach(dynamic, notes[1])

    # make the lower voice
    lower_voice = abjad.Voice(notes)
    lower_voice.name = 'RH Lower Voice'
    command = abjad.LilyPondLiteral(r'\voiceTwo')
    abjad.attach(command, lower_voice)
    n = int(math.ceil(len(pitches) / 2.))
    chord = abjad.Chord([pitches[0], pitches[0] + 12], (n, 8))
    articulation = abjad.Articulation('>')
    abjad.attach(articulation, chord)

    # make the upper voice
    upper_voice = abjad.Voice([chord])
    upper_voice.name = 'RH Upper Voice'
    command = abjad.LilyPondLiteral(r'\voiceOne')
    abjad.attach(command, upper_voice)

    # combine them together
    container = abjad.Container([lower_voice, upper_voice])
    container.is_simultaneous = True

    # make all 1/8 beats breakable
    leaves = abjad.select(lower_voice).leaves()
    for leaf in leaves[:-1]:
        bar_line = abjad.BarLine('')
        abjad.attach(bar_line, leaf)

    return container
示例#4
0
def test_Chord___copy___04():
    """
    Chord copies tweaked note-heads.
    """

    chord_1 = abjad.Chord("<c' e' g'>4")
    abjad.tweak(chord_1.note_heads[0]).color = "#red"
    chord_2 = copy.copy(chord_1)

    assert abjad.lilypond(chord_1) == abjad.String.normalize(r"""
        <
            \tweak color #red
            c'
            e'
            g'
        >4
        """)

    assert abjad.lilypond(chord_2) == abjad.String.normalize(r"""
        <
            \tweak color #red
            c'
            e'
            g'
        >4
        """)

    assert chord_2.note_heads[0]._client is chord_2
    assert chord_2.note_heads[1]._client is chord_2
    assert chord_2.note_heads[2]._client is chord_2

    assert abjad.lilypond(chord_1) == abjad.lilypond(chord_2)
    assert chord_1 is not chord_2

    assert chord_1.note_heads[0] == chord_2.note_heads[0]
    assert chord_1.note_heads[1] == chord_2.note_heads[1]
    assert chord_1.note_heads[2] == chord_2.note_heads[2]

    assert chord_1.note_heads[0] is not chord_2.note_heads[0]
    assert chord_1.note_heads[1] is not chord_2.note_heads[1]
    assert chord_1.note_heads[2] is not chord_2.note_heads[2]
 def _construct_fretting_tablature(self, logical_tie, fret_combination):
     string_ids = [6, 5, 4, 3, 2, 1]
     staff_positions = [2, 5, 9, 12, 16, 19]
     for i, leaf in enumerate(logical_tie):
         # replace note with chord
         chord = abjad.Chord(staff_positions, leaf.written_duration)
         # first leaf
         if i == 0:
             # replace noteheads
             for j, note_head in enumerate(chord.note_heads):
                 string = string_ids[j]
                 if fret_combination.includes_string(string):
                     fret_placement = \
                         fret_combination.get_fret_placement(string)
                     self._create_tablature_notehead(
                         note_head, fret_placement)
                 else:
                     self._hide_note_head(note_head)
         else:
             self._hide_note_head(chord)
         abjad.mutate(leaf).replace(chord)
def test_remove_repeated_dynamics_03():
    staff = abjad.Staff([
        abjad.Note("c'2"),
        abjad.Chord("<d' f'>2"),
        abjad.Tuplet((2, 3), "g2 a2 b2"),
    ])
    abjad.attach(abjad.Dynamic('ppp'), staff[0])
    abjad.attach(abjad.Dynamic('ppp'), staff[1])
    abjad.attach(abjad.Dynamic('ppp'), staff[2][0])
    assert abjad.lilypond(staff) == abjad.String.normalize(r"""
        \new Staff
        {
            c'2
            \ppp
            <d' f'>2
            \ppp
            \times 2/3
            {
                g2
                \ppp
                a2
                b2
            }
        }
        """)
    auxjad.mutate.remove_repeated_dynamics(staff[:])
    assert abjad.lilypond(staff) == abjad.String.normalize(r"""
        \new Staff
        {
            c'2
            \ppp
            <d' f'>2
            \times 2/3
            {
                g2
                a2
                b2
            }
        }
        """)
示例#7
0
文件: sketches.py 项目: grrrr/rill
    def make_music(self, durations, denominator, divisions, pitches):
        # make rhythm with one tuplet per division
        stack = rmakers.stack(
            rmakers.talea(
                durations,
                denominator,
                extra_counts=None,
            ),
            rmakers.beam(),
        )
        selection = stack(divisions)

#        # attach time signature to first leaf in each tuplet
#        assert len(divisions) == len(selection)
#        for division, tuplet in zip(divisions, selection):
#            time_signature = abjad.TimeSignature(division)
#            leaf = abjad.select(tuplet).leaf(0)
#            abjad.attach(time_signature, leaf)
#
        # apply pitches
        cyclic_tuple = abjad.CyclicTuple(pitches)
        iterator = abjad.iterate(selection).logical_ties(pitched=True)
        iterator = enumerate(iterator)
        for index, logical_tie in iterator:
            pitch = cyclic_tuple[index]
            for old_leaf in logical_tie:
                if isinstance(pitch, int):
                    old_leaf.written_pitch = pitch
                elif isinstance(pitch, list):
                    new_leaf = abjad.Chord(pitch, old_leaf.written_duration)
                    indicators = abjad.inspect(old_leaf).indicators()
                    if indicators != None:
                        for indicator in indicators:
                            abjad.attach(indicator, new_leaf)
                    abjad.mutate(old_leaf).replace(new_leaf)

        # remove trivial 1:1 tuplets
        self.staff.extend(selection)
        command = rmakers.extract_trivial()
        command(selection)
示例#8
0
def test_scoretools_Chord___copy___04():
    r'''Chord copies tweaked note-heads.
    '''

    chord_1 = abjad.Chord("<c' e' g'>4")
    chord_1.note_heads[0].tweak.color = 'red'
    chord_2 = copy.copy(chord_1)

    assert format(chord_1) == abjad.String.normalize(r'''
        <
            \tweak color #red
            c'
            e'
            g'
        >4
        ''')

    assert format(chord_2) == abjad.String.normalize(r'''
        <
            \tweak color #red
            c'
            e'
            g'
        >4
        ''')

    assert chord_2.note_heads[0]._client is chord_2
    assert chord_2.note_heads[1]._client is chord_2
    assert chord_2.note_heads[2]._client is chord_2

    assert format(chord_1) == format(chord_2)
    assert chord_1 is not chord_2

    assert chord_1.note_heads[0] == chord_2.note_heads[0]
    assert chord_1.note_heads[1] == chord_2.note_heads[1]
    assert chord_1.note_heads[2] == chord_2.note_heads[2]

    assert chord_1.note_heads[0] is not chord_2.note_heads[0]
    assert chord_1.note_heads[1] is not chord_2.note_heads[1]
    assert chord_1.note_heads[2] is not chord_2.note_heads[2]
 def convert_abjad_pitches_and_mu_rhythms2abjad_notes(
         self, harmonies: list, delays: list, grid) -> list:
     leading_pulses = grid.leading_pulses
     absolute_leading_pulses = tuple(
         itertools.accumulate([0] + list(leading_pulses)))
     converted_delays = grid.apply_delay(delays)
     absolute_delays = tuple(
         itertools.accumulate([0] + list(converted_delays)))
     # 1. generate notes
     notes = abjad.Measure(abjad.TimeSignature(grid.absolute_meter), [])
     resulting_durations = []
     for harmony, delay, start, end in zip(harmonies, converted_delays,
                                           absolute_delays,
                                           absolute_delays[1:]):
         subnotes = abjad.Voice()
         seperated_by_grid = Instrument.seperate_by_grid(
             delay, start, end, absolute_leading_pulses, leading_pulses,
             grid)
         assert sum(seperated_by_grid) == delay
         for d in seperated_by_grid:
             seperated_by_assignable = Instrument.seperate_by_assignablity(
                 d, grid)
             assert sum(seperated_by_assignable) == d
             for assignable in seperated_by_assignable:
                 resulting_durations.append(assignable)
                 if harmony:
                     chord = abjad.Chord(harmony,
                                         abjad.Duration(assignable))
                 else:
                     chord = abjad.Rest(abjad.Duration(assignable))
                 subnotes.append(chord)
         if len(subnotes) > 1 and len(harmony) > 0:
             abjad.attach(abjad.Tie(), subnotes[:])
         notes.extend(subnotes)
     assert sum(resulting_durations) == sum(converted_delays)
     voice = Instrument.mk_voice(notes)
     # 2. apply beams
     voice = Instrument.apply_beams(voice, resulting_durations,
                                    absolute_leading_pulses)
     return voice
示例#10
0
def test_Staff___getitem___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).wellformed()
    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)
    assert isinstance(staff[-5], abjad.Note)
    assert isinstance(staff[-4], abjad.Rest)
    assert isinstance(staff[-3], abjad.Chord)
    assert isinstance(staff[-2], abjad.Skip)
    assert isinstance(staff[-1], abjad.Tuplet)
示例#11
0
def add_acciaccatura(
    nth_event: int,
    pitch: ji.JIPitch,
    novent_line: lily.NOventLine,
    add_glissando: bool = False,
    use_artifical_harmonic: bool = False,
) -> None:
    if use_artifical_harmonic:
        abjad_note = abjad.Chord(
            _get_artifical_harmonic_pitches(pitch),
            abjad.Duration(1, 8),
        )
        abjad.tweak(abjad_note.note_heads[1]).style = "harmonic"
        pitch = pitch + ji.r(4, 1)

    else:
        abjad_note = abjad.Note(
            lily.convert2abjad_pitch(pitch, globals_.RATIO2PITCHCLASS),
            abjad.Duration(1, 8),
        )
    novent_line[nth_event].acciaccatura = attachments.Acciaccatura(
        [pitch], abjad_note, add_glissando)
示例#12
0
def make_desordre_cell(pitches):
    """
    Makes a Désordre cell.
    """

    notes = [abjad.Note(pitch, (1, 8)) for pitch in pitches]
    notes = abjad.Selection(notes)
    abjad.beam(notes)
    abjad.slur(notes)
    abjad.attach(abjad.Dynamic("f"), notes[0])
    abjad.attach(abjad.Dynamic("p"), notes[1])

    # make the lower voice
    lower_voice = abjad.Voice(notes)
    lower_voice.name = "RH_Lower_Voice"
    command = abjad.LilyPondLiteral(r"\voiceTwo")
    abjad.attach(command, lower_voice)
    n = int(math.ceil(len(pitches) / 2.0))
    chord = abjad.Chord([pitches[0], pitches[0] + 12], (n, 8))
    abjad.attach(abjad.Articulation(">"), chord)

    # make the upper voice
    upper_voice = abjad.Voice([chord])
    upper_voice.name = "RH_Upper_Voice"
    command = abjad.LilyPondLiteral(r"\voiceOne")
    abjad.attach(command, upper_voice)

    # combine them together
    voices = [lower_voice, upper_voice]
    container = abjad.Container(voices, simultaneous=True)

    # make all 1/8 beats breakable
    leaves = abjad.select(lower_voice).leaves()
    for leaf in leaves[:-1]:
        bar_line = abjad.BarLine("")
        abjad.attach(bar_line, leaf)

    return container
示例#13
0
def test_remove_repeated_time_signatures_03():
    staff = abjad.Staff([
        abjad.Note("c'2"),
        abjad.Chord("<d' f'>2"),
        abjad.Tuplet((2, 3), "g2 a2 b2"),
    ])
    abjad.attach(abjad.TimeSignature((2, 2)), staff[0])
    abjad.attach(abjad.TimeSignature((2, 2)), staff[2][0])
    assert abjad.lilypond(staff) == abjad.String.normalize(r"""
        \new Staff
        {
            \time 2/2
            c'2
            <d' f'>2
            \times 2/3
            {
                \time 2/2
                g2
                a2
                b2
            }
        }
        """)
    auxjad.mutate.remove_repeated_time_signatures(staff[:])
    assert abjad.lilypond(staff) == abjad.String.normalize(r"""
        \new Staff
        {
            \time 2/2
            c'2
            <d' f'>2
            \times 2/3
            {
                g2
                a2
                b2
            }
        }
        """)
示例#14
0
def put_gong_to_separate_vox(nth_bar: int, nth_item: int,
                             staff: abjad.Staff) -> None:
    event2separate = abjad.mutate(staff[nth_bar][nth_item]).copy()
    staff[nth_bar][nth_item] = abjad.Container(
        [
            abjad.Voice([
                abjad.Note(
                    event2separate.written_pitches[0],
                    event2separate.written_duration,
                )
            ]),
            abjad.Voice([
                abjad.Chord(
                    event2separate.written_pitches[1:],
                    event2separate.written_duration,
                )
            ]),
        ],
        simultaneous=True,
    )
    for text in (
            r'\set Staff.ottavation = #"8vb"',
            r"\once \override Staff.OttavaBracket.direction = #DOWN",
            r"\set Voice.middleCPosition = #(+ 6 7)",
    ):
        abjad.attach(
            abjad.LilyPondLiteral(text, format_slot="before"),
            staff[nth_bar][nth_item][0][0],
        )

    for text in (
            r"\unset Staff.ottavation",
            r"\unset Voice.middleCPosition",
    ):
        abjad.attach(
            abjad.LilyPondLiteral(text, format_slot="after"),
            staff[nth_bar][nth_item][0][0],
        )
示例#15
0
def test_respell_accidentals_02():
    staff = abjad.Staff()
    for pitch in range(12):
        staff.append(abjad.Chord([pitch, pitch + 1], (1, 16)))
    auxjad.mutate(staff[:]).respell_accidentals()
    assert format(staff) == abjad.String.normalize(
        r"""
        \new Staff
        {
            <c' df'>16
            <cs' d'>16
            <d' ef'>16
            <ds' e'>16
            <e' f'>16
            <f' gf'>16
            <fs' g'>16
            <g' af'>16
            <gs' a'>16
            <a' bf'>16
            <as' b'>16
            <b' c''>16
        }
        """)
示例#16
0
def test_Staff___getitem___08():

    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).wellformed()
    selection = staff[:]
    assert len(selection) == 5
    assert isinstance(selection, abjad.Selection)
    assert isinstance(selection[0], abjad.Note)
    assert isinstance(selection[1], abjad.Rest)
    assert isinstance(selection[2], abjad.Chord)
    assert isinstance(selection[3], abjad.Skip)
    assert isinstance(selection[4], abjad.Tuplet)
    for x in selection:
        assert x._parent == staff
    assert abjad.inspect(staff).wellformed()
示例#17
0
 def _tuple_to_component(self, argument):
     pitch_string = argument[0]
     duration = argument[1]
     if isinstance(argument[0], abjad.Component):
         component = argument[0]
     elif " " in pitch_string:
         component = abjad.Chord([], duration)
         pitches = pitch_string.split()
         for pitch in pitches:
             component.note_heads.append(pitch)
     else:
         component = abjad.Note(pitch_string, duration)
     for indicator in argument[2:]:
         if indicator == "parenthesize":
             if isinstance(component, abjad.Note):
                 component.note_head.is_parenthesized = True
             elif isinstance(component, abjad.Chord):
                 for note_head in component.note_heads:
                     note_head.is_parenthesized = True
         else:
             copied_indicator = copy.deepcopy(indicator)
             abjad.attach(copied_indicator, component)
     return component
示例#18
0
def test_scoretools_Chord___copy___05():
    r'''Chord coipes articulations and markup.
    '''

    chord_1 = abjad.Chord("<ef' cs'' f''>4")
    articulation_1 = abjad.Articulation('staccato')
    abjad.attach(articulation_1, chord_1)
    markup_1 = abjad.Markup('foo', abjad.Up)
    abjad.attach(markup_1, chord_1)

    chord_2 = copy.copy(chord_1)

    assert format(chord_1) == format(chord_2)
    assert chord_1 is not chord_2

    articulation_2 = abjad.inspect(chord_2).get_indicators(
        abjad.Articulation)[0]
    assert articulation_1 == articulation_2
    assert articulation_1 is not articulation_2

    markup_2 = abjad.inspect(chord_2).get_markup()[0]
    assert markup_1 == markup_2
    assert markup_1 is not markup_2
示例#19
0
def listnotes(x):  # Input a chord list
    notelist = []
    for a in x:
        if a[2] == ['r']:
            d = convertduration(a[3])
            if d[0] not in assignable:
                splitd = splitduration(d[0])
                duration1 = simplifyfraction(splitd[0], d[1])
                duration2 = simplifyfraction(splitd[1], d[1])
                notelist.append(ab.Rest(ab.Duration(*duration1)))
                notelist.append(ab.Rest(ab.Duration(*duration2)))
            else:
                notelist.append(ab.Rest(ab.Duration(*d)))
        elif len(a[2]) == 1:
            notelist.append(
                ab.Note(a[2][0] - 148, ab.Duration(*convertduration(a[3]))))
        elif len(a[2]) > 1:
            chordnotes = []
            for b in a[2]:
                chordnotes.append(b - 148)
            notelist.append(
                ab.Chord(chordnotes, ab.Duration(*convertduration(a[3]))))
    return notelist
示例#20
0
def test_Chord___copy___05():
    """
    Chord coipes articulations and markup.
    """

    chord_1 = abjad.Chord("<ef' cs'' f''>4")
    articulation_1 = abjad.Articulation("staccato")
    abjad.attach(articulation_1, chord_1)
    markup_1 = abjad.Markup("foo", direction=abjad.Up)
    abjad.attach(markup_1, chord_1)

    chord_2 = copy.copy(chord_1)

    assert format(chord_1) == format(chord_2)
    assert chord_1 is not chord_2

    articulation_2 = abjad.inspect(chord_2).indicators(abjad.Articulation)[0]
    assert articulation_1 == articulation_2
    assert articulation_1 is not articulation_2

    markup_2 = abjad.inspect(chord_2).markup()[0]
    assert markup_1 == markup_2
    assert markup_1 is not markup_2
    def _make_measures_seg_5(
        self,
        durations,
        rhythm_maker,
        pitches,
    ):

        if rhythm_maker is not None:
            measures = rhythm_maker(durations)
            measures = abjad.Container(measures)

        if pitches is not None:
            logical_ties = abjad.select(measures).leaves().logical_ties()
            for i, logical_tie in enumerate(logical_ties):
                index = i % len(pitches)
                pitch = pitches[index]

                for note in logical_tie:
                    if isinstance(note, abjad.Rest):
                        pass
                    else:
                        note = abjad.Chord()
        return measures
def test_LilyPondParser__misc__chord_repetition_02():

    target = abjad.Staff(
        [
            abjad.Chord([0, 4, 7], (1, 8)),
            abjad.Chord([0, 4, 7], (1, 8)),
            abjad.Chord([0, 4, 7], (1, 4)),
            abjad.Chord([0, 4, 7], (3, 16)),
            abjad.Chord([0, 4, 7], (1, 16)),
            abjad.Chord([0, 4, 7], (1, 4)),
        ]
    )

    dynamic = abjad.Dynamic("p")
    abjad.attach(dynamic, target[0])
    articulation = abjad.Articulation("staccatissimo")
    abjad.attach(articulation, target[2])
    markup = abjad.Markup("text", direction=abjad.Up)
    abjad.attach(markup, target[3])
    articulation = abjad.Articulation("staccatissimo")
    abjad.attach(articulation, target[-1])

    assert abjad.lilypond(target) == abjad.String.normalize(
        r"""
        \new Staff
        {
            <c' e' g'>8
            \p
            <c' e' g'>8
            <c' e' g'>4
            - \staccatissimo
            <c' e' g'>8.
            ^ \markup { text }
            <c' e' g'>16
            <c' e' g'>4
            - \staccatissimo
        }
        """
    )

    string = r"""\new Staff { <c' e' g'>8\p q q4-! q8.^"text" q16 q4-! }"""
    parser = abjad.parser.LilyPondParser()
    result = parser(string)
    assert abjad.lilypond(target) == abjad.lilypond(result) and target is not result
示例#23
0
def test_Staff___delitem___03():

    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 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)
    del (staff[3])
    assert len(staff) == 4
    assert isinstance(staff[0], abjad.Note)
    assert isinstance(staff[1], abjad.Rest)
    assert isinstance(staff[2], abjad.Chord)
    assert isinstance(staff[3], abjad.Tuplet)
    del (staff[-2])
    assert len(staff) == 3
    assert isinstance(staff[0], abjad.Note)
    assert isinstance(staff[1], abjad.Rest)
    assert isinstance(staff[2], abjad.Tuplet)
    del (staff[2])
    assert len(staff) == 2
    assert isinstance(staff[0], abjad.Note)
    assert isinstance(staff[1], abjad.Rest)
    del (staff[0])
    assert len(staff) == 1
    assert isinstance(staff[0], abjad.Rest)
    del (staff[-1])
    assert len(staff) == 0
示例#24
0
def test_respell_augmented_unisons_02():
    staff = abjad.Staff()
    for pitch in range(12):
        staff.append(abjad.Chord([pitch, pitch + 1], (1, 16)))
    auxjad.mutate.respell_augmented_unisons(staff[:])
    assert abjad.lilypond(staff) == abjad.String.normalize(
        r"""
        \new Staff
        {
            <c' df'>16
            <cs' d'>16
            <d' ef'>16
            <ds' e'>16
            <e' f'>16
            <f' gf'>16
            <fs' g'>16
            <g' af'>16
            <gs' a'>16
            <a' bf'>16
            <as' b'>16
            <b' c''>16
        }
        """
    )
示例#25
0
    def __handle_insert_command(self, command: InsertCommand) -> List[Command]:
        """Attempt to parse whatever the InsertCommand contains. Return either [] if
        successful or a command that sets the status line text to what happened."""
        text = command.text

        if len(text) == 0:
            return

        try:
            # objects to add
            objects = []

            for item in text.split(";"):
                item = item.strip()

                if item[0] == "r":
                    obj = abjad.Rest(item)
                elif item[0] == "<":
                    obj = abjad.Chord(item)
                else:
                    obj = abjad.Note(item)

                objects.append(obj)

            for obj in objects:
                self.score.insert(self.position, obj)
                self.position += 1

            self.changed_since_saving = True
            self.previous_repeatable_command = command

        except Exception as e:
            return [
                SetStatusLineTextCommand("The string could not be parsed.",
                                         Position.CENTER)
            ]
示例#26
0
def test_lilypondparsertools_LilyPondParser__misc__chord_repetition_02():

    target = abjad.Staff([
        abjad.Chord([0, 4, 7], (1, 8)),
        abjad.Chord([0, 4, 7], (1, 8)),
        abjad.Chord([0, 4, 7], (1, 4)),
        abjad.Chord([0, 4, 7], (3, 16)),
        abjad.Chord([0, 4, 7], (1, 16)),
        abjad.Chord([0, 4, 7], (1, 4))
    ])

    dynamic = abjad.Dynamic('p')
    abjad.attach(dynamic, target[0])
    articulation = abjad.Articulation('staccatissimo')
    abjad.attach(articulation, target[2])
    markup = abjad.Markup('text', abjad.Up)
    abjad.attach(markup, target[3])
    articulation = abjad.Articulation('staccatissimo')
    abjad.attach(articulation, target[-1])

    assert format(target) == abjad.String.normalize(r'''
        \new Staff
        {
            <c' e' g'>8
            \p
            <c' e' g'>8
            <c' e' g'>4
            -\staccatissimo
            <c' e' g'>8.
            ^ \markup { text }
            <c' e' g'>16
            <c' e' g'>4
            -\staccatissimo
        }
        ''')

    string = r'''\new Staff { <c' e' g'>8\p q q4-| q8.^"text" q16 q4-| }'''
    parser = abjad.lilypondparsertools.LilyPondParser()
    result = parser(string)
    assert format(target) == format(result) and target is not result
示例#27
0
# -*- encoding: utf-8 -*-
import os
import abjad
from organi.tools import SegmentMaker

# TIME SIGNATURES
time_signatures = [(4, 4)]

# ORGAN NOTATION
rest_organ = abjad.Rest("r1")
abjad.attach(abjad.Fermata("verylongfermata"), rest_organ)
rest_organ_voice_four = abjad.Rest("r1")

# CHORD ZERO ELECTRONICS
chord_zero_electronics = abjad.Chord(
    "<cqs' f' gs' c'' e'' ftqs'' gqs'' gs''" +
    " b'' cs''' ctqs''' f''' fs''' ftqs''' gs'''>1")

# laisses vibrer
laissez_vibrer = abjad.LaissezVibrer()
abjad.attach(laissez_vibrer, chord_zero_electronics)

# tempo mark
mark = abjad.MetronomeMark(None, None, "Statico")
abjad.attach(mark, chord_zero_electronics)

# fermata
abjad.attach(abjad.Fermata("verylongfermata"), chord_zero_electronics)

# remove includes to collect segments
includes = ['../../stylesheets/stylesheet.ily']
示例#28
0
import abjad

chord = [-12, -5, 2, 9, 16]

new_chord = abjad.Chord(chord, 1)

new_chord.note_heads[4].is_parenthesized = True

#staff = abjad.Staff(new_chord)

abjad.show(new_chord)
示例#29
0
    with open(file_path, 'r') as file:

        lower_staff_components = []
        upper_staff_components = []

        lines = file.readlines()

        if len(lines) > 0:

            for line in lines:

                c = Chord.from_string(line)

                lower_pitches = [p for p in c.pitches if p.midi_number < 60]
                lower_abjad_chord = abjad.Chord([], abjad.Duration(1, 1))
                if len(lower_pitches) > 0:
                    for i in range(0, len(lower_pitches)):
                        lower_abjad_chord.note_heads.extend(
                            [lower_pitches[i].midi_number - 60])
                        if lower_pitches[i].is_harmonic_tone == False:
                            abjad.tweak(lower_abjad_chord.note_heads[i]
                                        ).style = 'harmonic'
                    lower_staff_components.append(lower_abjad_chord)
                else:
                    lower_staff_components.append(
                        abjad.Rest(abjad.Duration(1, 1)))

                upper_pitches = [p for p in c.pitches if p.midi_number >= 60]
                upper_abjad_chord = abjad.Chord([], abjad.Duration(1, 1))
                if len(upper_pitches) > 0:
示例#30
0
def test_scoretools_NoteHeadList___len___01():

    assert len(abjad.Chord('<>4').note_heads) == 0
    assert len(abjad.Chord("<ef'>4").note_heads) == 1
    assert len(abjad.Chord("<ef' cs''>4").note_heads) == 2
    assert len(abjad.Chord("<ef' cs'' f''>4").note_heads) == 3