Ejemplo n.º 1
0
def test_setting_02():
    """
    Works with leaf metronome mark interface.

    Includes LilyPond \set command.
    """

    staff = abjad.Staff("c'8 d'8 e'8 f'8")
    score = abjad.Score([staff])
    moment = abjad.SchemeMoment(24)
    leaves = abjad.select(score).leaves()
    abjad.setting(leaves[1]).score.tempo_wholes_per_minute = moment

    assert format(score) == abjad.String.normalize(r"""
        \new Score
        <<
            \new Staff
            {
                c'8
                \set Score.tempoWholesPerMinute = #(ly:make-moment 24 1)
                d'8
                e'8
                f'8
            }
        >>
        """)
Ejemplo n.º 2
0
def make_sketch_lilypond_file(component):
    abjad.override(component).bar_line.stencil = False
    abjad.override(component).bar_number.stencil = False
    abjad.override(component).beam.positions = abjad.SchemePair((4, 4))
    abjad.override(component).spacing_spanner.strict_grace_spacing = True
    abjad.override(component).spacing_spanner.strict_note_spacing = True
    abjad.override(component).spacing_spanner.uniform_stretching = True
    abjad.override(component).stem.length = 8.25
    abjad.override(component).text_script.outside_staff_padding = 1
    abjad.override(component).time_signature.stencil = False
    abjad.override(component).tuplet_bracket.bracket_visibility = True
    abjad.override(component).tuplet_bracket.minimum_length = 3
    abjad.override(component).tuplet_bracket.outside_staff_padding = 1.5
    abjad.override(component).tuplet_bracket.padding = 1.5
    abjad.override(component).tuplet_bracket.springs_and_rods = \
        abjad.Scheme('ly:spanner::set-spacing-rods', verbatim=True)
    abjad.override(component).tuplet_bracket.staff_padding = 2.25
    abjad.override(component).tuplet_number.text = \
        abjad.Scheme('tuplet-number::calc-fraction-text', verbatim=True)
    abjad.setting(component).proportional_notation_duration = \
        abjad.SchemeMoment((1, 24))
    abjad.setting(component).tuplet_full_length = True
    lilypond_file = abjad.LilyPondFile.new(component)
    lilypond_file.layout_block.indent = 0
    lilypond_file.paper_block.system_system_spacing = abjad.Scheme(
        "#'((basic-distance . 28)(minimum-distance . 1)(padding . 4)(stretchability . 1))",
        verbatim=True)
    return lilypond_file
Ejemplo n.º 3
0
def test_LilyPondSettingNameManager___setattr___08():
    """
    Define LilyPond proportionalNotationDuration context abjad.setting.
    """

    score = abjad.Score([abjad.Staff("c'8 d'8 e'8 f'8")])
    moment = abjad.SchemeMoment(abjad.Fraction(1, 56))
    abjad.setting(score).proportional_notation_duration = moment

    assert format(score) == abjad.String.normalize(r"""
        \new Score
        \with
        {
            proportionalNotationDuration = #(ly:make-moment 1 56)
        }
        <<
            \new Staff
            {
                c'8
                d'8
                e'8
                f'8
            }
        >>
        """)

    assert abjad.inspect(score).wellformed()
Ejemplo n.º 4
0
def test_setting_01():
    """
    Works with score metronome mark interface.

    Does not include LilyPond \set command.
    """

    staff = abjad.Staff("c'8 d'8 e'8 f'8")
    score = abjad.Score([staff])
    abjad.setting(score).tempo_wholes_per_minute = abjad.SchemeMoment(24)

    assert format(score) == abjad.String.normalize(r"""
        \new Score
        \with
        {
            tempoWholesPerMinute = #(ly:make-moment 24 1)
        }
        <<
            \new Staff
            {
                c'8
                d'8
                e'8
                f'8
            }
        >>
        """)
Ejemplo n.º 5
0
def make_desordre_lilypond_file(score):
    """
    Makes Désordre LilyPond file.
    """
    lilypond_file = abjad.LilyPondFile.new(music=score,
                                           default_paper_size=("a4", "letter"),
                                           global_staff_size=14)

    lilypond_file.layout_block.indent = 0
    lilypond_file.layout_block.ragged_right = True
    lilypond_file.layout_block.merge_differently_dotted = True
    lilypond_file.layout_block.merge_differently_headed = True

    context_block = abjad.ContextBlock(source_lilypond_type="Score")
    lilypond_file.layout_block.items.append(context_block)
    context_block.remove_commands.append("Bar_number_engraver")
    context_block.remove_commands.append("Default_bar_line_engraver")
    context_block.remove_commands.append("Timing_translator")
    abjad.override(context_block).beam.breakable = True
    abjad.override(context_block).glissando.breakable = True
    abjad.override(context_block).note_column.ignore_collision = True
    abjad.override(context_block).spacing_spanner.uniform_stretching = True
    abjad.override(context_block).text_script.staff_padding = 4
    abjad.override(context_block).text_spanner.breakable = True
    abjad.override(context_block).tuplet_bracket.bracket_visibility = True
    abjad.override(context_block).tuplet_bracket.minimum_length = 3
    abjad.override(context_block).tuplet_bracket.padding = 2
    scheme = abjad.Scheme("ly:spanner::set-spacing-rods")
    abjad.override(context_block).tuplet_bracket.springs_and_rods = scheme
    scheme = abjad.Scheme("tuplet-number::calc-fraction-text")
    abjad.override(context_block).tuplet_number.text = scheme
    abjad.setting(context_block).autoBeaming = False
    moment = abjad.SchemeMoment((1, 12))
    abjad.setting(context_block).proportionalNotationDuration = moment
    abjad.setting(context_block).tupletFullLength = True

    context_block = abjad.ContextBlock(source_lilypond_type="Staff")
    lilypond_file.layout_block.items.append(context_block)
    # LilyPond CAUTION: Timing_translator must appear
    #                   before Default_bar_line_engraver!
    context_block.consists_commands.append("Timing_translator")
    context_block.consists_commands.append("Default_bar_line_engraver")
    scheme = abjad.Scheme("'numbered")
    abjad.override(context_block).time_signature.style = scheme

    context_block = abjad.ContextBlock(source_lilypond_type="RhythmicStaff")
    lilypond_file.layout_block.items.append(context_block)
    # LilyPond CAUTION: Timing_translator must appear
    #                   before Default_bar_line_engraver!
    context_block.consists_commands.append("Timing_translator")
    context_block.consists_commands.append("Default_bar_line_engraver")
    scheme = abjad.Scheme("'numbered")
    abjad.override(context_block).time_signature.style = scheme
    pair = (-2, 4)
    abjad.override(context_block).vertical_axis_group.minimum_Y_extent = pair
    context_block = abjad.ContextBlock(source_lilypond_type="Voice")
    lilypond_file.layout_block.items.append(context_block)
    context_block.remove_commands.append("Forbid_line_break_engraver")

    return lilypond_file
Ejemplo n.º 6
0
    def make_score(self):
        r'''Makes MIDI playback score from scale.

        ..  container:: example

            >>> scale = abjad.tonalanalysistools.Scale(('E', 'major'))
            >>> score = scale.make_score()
            >>> abjad.show(score) # doctest: +SKIP

            ..  docs::

                >>> abjad.f(score)
                \new Score
                \with
                {
                    tempoWholesPerMinute = #(ly:make-moment 30 1)
                }
                <<
                    \new Staff
                    {
                        \key e \major
                        e'8
                        fs'8
                        gs'8
                        a'8
                        b'8
                        cs''8
                        ds''8
                        e''8
                        ds''8
                        cs''8
                        b'8
                        a'8
                        gs'8
                        fs'8
                        e'4
                    }
                >>

        Returns score.
        '''
        import abjad
        ascending_notes = self.make_notes(8, abjad.Duration(1, 8))
        descending_notes = copy.deepcopy(ascending_notes[:-1])
        descending_notes = list(descending_notes)
        descending_notes.reverse()
        descending_notes = abjad.select(descending_notes)
        notes = ascending_notes + descending_notes
        notes[-1].written_duration = abjad.Duration(1, 4)
        staff = abjad.Staff(notes)
        key_signature = copy.copy(self.key_signature)
        abjad.attach(key_signature, staff[0])
        score = abjad.Score([staff])
        abjad.setting(score).tempo_wholes_per_minute = abjad.SchemeMoment(30)
        return score
Ejemplo n.º 7
0
 def configure_score(self, score):
     r'''Configures `score`.
     '''
     moment = abjad.SchemeMoment((1, 56))
     abjad.setting(score).proportional_notation_duration = moment
     abjad.setting(score).tuplet_full_length = True
     abjad.override(score).bar_line.stencil = False
     abjad.override(score).bar_number.transparent = True
     abjad.override(score).spacing_spanner.uniform_stretching = True
     abjad.override(score).spacing_spanner.strict_note_spacing = True
     abjad.override(score).time_signature.stencil = False
     abjad.override(score).tuplet_bracket.padding = 2
     abjad.override(score).tuplet_bracket.staff_padding = 4
     scheme = abjad.Scheme('tuplet-number::calc-fraction-text')
     abjad.override(score).tuplet_number.text = scheme
Ejemplo n.º 8
0
    def __illustrate__(self,
                       markup_direction=enums.Up,
                       figure_name=None,
                       **keywords):
        """
        Illustrates segment.

        Returns LilyPond file.
        """
        import abjad
        notes = []
        for item in self:
            note = abjad.Note(item, Duration(1, 8))
            notes.append(note)
        markup = None
        if self._equivalence_markup:
            markup = self._equivalence_markup
        if isinstance(figure_name, str):
            figure_name = abjad.Markup(figure_name)
        if figure_name is not None:
            markup = figure_name
        if markup is not None:
            direction = markup_direction
            markup = abjad.new(markup, direction=direction)
            abjad.attach(markup, notes[0])
        voice = abjad.Voice(notes)
        staff = abjad.Staff([voice])
        score = abjad.Score([staff])
        score.add_final_bar_line()
        abjad.override(score).bar_line.transparent = True
        abjad.override(score).bar_number.stencil = False
        abjad.override(score).beam.stencil = False
        abjad.override(score).flag.stencil = False
        abjad.override(score).stem.stencil = False
        abjad.override(score).time_signature.stencil = False
        string = r'\override Score.BarLine.transparent = ##f'
        command = abjad.LilyPondLiteral(string, 'after')
        last_leaf = abjad.select(score).leaves()[-1]
        abjad.attach(command, last_leaf)
        moment = abjad.SchemeMoment((1, 12))
        abjad.setting(score).proportional_notation_duration = moment
        lilypond_file = abjad.LilyPondFile.new(music=score)
        if 'title' in keywords:
            title = keywords.get('title')
            if not isinstance(title, abjad.Markup):
                title = abjad.Markup(title)
            lilypond_file.header_block.title = title
        if 'subtitle' in keywords:
            markup = abjad.Markup(keywords.get('subtitle'))
            lilypond_file.header_block.subtitle = markup
        command = abjad.LilyPondLiteral(r'\accidentalStyle forget')
        lilypond_file.layout_block.items.append(command)
        lilypond_file.layout_block.indent = 0
        string = 'markup-system-spacing.padding = 8'
        command = abjad.LilyPondLiteral(string)
        lilypond_file.paper_block.items.append(command)
        string = 'system-system-spacing.padding = 10'
        command = abjad.LilyPondLiteral(string)
        lilypond_file.paper_block.items.append(command)
        string = 'top-markup-spacing.padding = 4'
        command = abjad.LilyPondLiteral(string)
        lilypond_file.paper_block.items.append(command)
        return lilypond_file
Ejemplo n.º 9
0
def make_tableaux_chart(fundamental_patterns, subdivisions):
    print("instantiating parser, staff group, and patterns ...")
    parser = abjad.rhythmtrees.RhythmTreeParser()
    print("beginning loop ...")
    for i, fundamental_pattern in enumerate(fundamental_patterns):
        print(fundamental_pattern)
        print("gathering pattern ...")
        print("permuting pattern ...")
        for permutation in list(
                set([_ for _ in itertools.permutations(fundamental_pattern)])):
            permutation = list(permutation)
            print(permutation)
            title = fr"Mutations of {permutation}"
            final_patterns = []
            parsed_patterns = abjad.Staff(lilypond_type="RhythmicStaff")
            for num_indices in range(len(permutation) + 1):
                print("gathing number of possible dividable beats ...")
                if num_indices == 0:
                    print("do not subdivide!")
                    print("converting to string ...")
                    subgrouped_permutation = (
                        f"(1 {evans.nested_list_to_rtm(permutation)})")
                    print("gathing number of rotatable positions ...")
                    l_ = -1
                    for symbol in subgrouped_permutation:
                        if symbol.isdigit():
                            l_ = l_ + 1
                    for y in range(l_):
                        print("rotating ...")
                        rotation = evans.rotate_tree(
                            rtm_string=subgrouped_permutation, n=y)
                        print(rotation)
                        print("funneling rotation to 1 ...")
                        for funnel in evans.funnel_inner_tree_to_x(
                                rtm_string=rotation, x=1):
                            print("caching funnel ...")
                            print(funnel)
                            final_patterns.append(funnel)
                else:
                    print("subdivide!")
                    print("gathering possible subdivisions ...")
                    for division_group in itertools.combinations_with_replacement(
                            subdivisions, num_indices):
                        division_group = list(division_group)
                        print("gathering possible subdivision locations ...")
                        possible_indices = [_ for _ in range(len(permutation))]
                        for index_group in itertools.combinations(
                                possible_indices, num_indices):
                            index_group = list(index_group)
                            print("adding subgroups ...")
                            subdivided_permutation = add_subgroups(
                                input_list=permutation,
                                index_list=index_group,
                                subgroup_list=division_group,
                            )
                            print("converting to string ...")
                            subgrouped_permutation = evans.nested_list_to_rtm(
                                subdivided_permutation)
                            print(subgrouped_permutation)
                            print("gathing number of rotatable positions ...")
                            l_ = -1
                            for symbol in subgrouped_permutation:
                                if symbol.isdigit():
                                    l_ = l_ + 1
                            for y in range(l_):
                                print("rotating ...")
                                rotation = evans.rotate_tree(
                                    rtm_string=subgrouped_permutation, n=y)
                                print(rotation)
                                print("funneling rotation to 1 ...")
                                for funnel in evans.funnel_inner_tree_to_x(
                                        rtm_string=rotation, x=1):
                                    print("caching funnel ...")
                                    print(funnel)
                                    final_patterns.append(funnel)
            print("parsing cached funnels ...")
            for pattern in final_patterns:
                print(pattern)
                pair = (1, 2)
                time_signature = abjad.TimeSignature(pair)
                rhythm_tree_list = parser(pattern)
                rhythm_tree_container = rhythm_tree_list[0]
                r = rhythm_tree_container(pair)
                m = abjad.Markup(fr"\markup {pattern}",
                                 direction=abjad.Up,
                                 literal=True)
                abjad.attach(m, abjad.select(r).leaves()[0])
                abjad.attach(time_signature, abjad.select(r).leaves()[0])
                print("adding parsed funnel to staff ...")
                parsed_patterns.extend(r)
            print("adding staff to staff group ...")
            score = abjad.Score([parsed_patterns])
            scheme = abjad.SchemeMoment((1, 50))
            abjad.setting(score).proportional_notation_duration = scheme
            new_brackets = evans.NoteheadBracketMaker()
            for staff in abjad.select(score).components(abjad.Staff):
                new_brackets(staff)
            abjad.override(score).TupletBracket.bracket_visibility = True
            print("rendering staff group ...")
            file = abjad.LilyPondFile(
                items=[
                    score,
                    abjad.Block(name="layout"),
                    abjad.Block(name="header")
                ],
                includes=[
                    "/Users/evansdsg2/abjad/docs/source/_stylesheets/abjad.ily"
                ],
                global_staff_size=14,
                default_paper_size=("11x17landscape", "portrait"),
            )
            file.layout_block.items.append("indent = 0")
            file.header_block.items.append("tagline = ##f")
            file.header_block.items.append(f'title = "{title}"')
            abjad.show(file)
Ejemplo n.º 10
0
        leaf1 = iterable[i]
        leaf2 = iterable[i + 1]
        pitch1 = leaf1.written_pitch
        pitch2 = leaf2.written_pitch
        interval = abjad.NamedInterval.from_pitch_carriers(pitch1, pitch2)
        inverted_interval = abjad.NamedInterval("P1") - interval
        new_pitch = inverted_interval.transpose(leaf1.written_pitch)
        new_leaf = copy.copy(leaf1)
        new_leaf.written_pitch = new_pitch
        out.append(new_leaf)
    return out


staff1 = abjad.Staff(
    "a'8 f'8 d'8 a'8 f'8 d'8 d''8 bf'8 g'8 bf'8 g'8 e'8 g'8 e'8 cs'8 g'8 e'8 cs'8 a'8 f'8 d'8",
    name="first_staff",
)
new_leaves = adjacent_interval_inversion(staff1)
staff2 = abjad.Staff(new_leaves, name="second_staff")
score = abjad.Score([abjad.StaffGroup([staff1, staff2], name="my_group")],
                    name="my_score")
moment = abjad.SchemeMoment((1, 20))
abjad.setting(score).proportional_notation_duration = moment
file = abjad.LilyPondFile(
    items=[score],
    includes=["/Users/evansdsg2/abjad/docs/source/_stylesheets/abjad.ily"],
    global_staff_size=16,
)
abjad.show(file)
abjad.play(score)