예제 #1
0
 def _create_staff_group(instrument_name, name, short_name):
     if instrument_name in instrument_categories['woodwinds']:
         instrument = instruments[instrument_name]
         template = surge.tools.templates.WoodwindStaffGroupTemplate(
             instrument
         )
         staff_group = template()
     elif instrument_name in instrument_categories['plucked strings']:
         instrument = instruments[instrument_name]
         template = surge.tools.templates.GuitarStaffGroupTemplate(
             instrument
         )
         staff_group = template()
     elif instrument_name in instrument_categories['bowed strings']:
         instrument = instruments[instrument_name]
         template = surge.tools.templates.BowedStringStaffGroupTemplate(
             instrument
         )
         staff_group = template()
     else:
         raise Exception(
             "Sorry, " +
             instrument_name +
             " does not belong to a valid instrument category."
         )
     abjad.setting(staff_group).instrument_name = abjad.Markup(name)
     abjad.setting(staff_group).short_instrument_name = \
         abjad.Markup(short_name)
     return staff_group
예제 #2
0
 def _populate_context_setting_format_contributions(component, bundle):
     import abjad
     result = []
     manager = LilyPondFormatManager
     if isinstance(component, abjad.Context):
         for name, value in vars(abjad.setting(component)).items():
             string = manager.format_lilypond_context_setting_in_with_block(
                 name, value)
             result.append(string)
     else:
         contextualizer = abjad.setting(component)
         variables = vars(contextualizer)
         for name, value in variables.items():
             # if we've found a leaf context namespace
             if name.startswith('_'):
                 for x, y in vars(value).items():
                     if not x.startswith('_'):
                         string = \
                             manager.format_lilypond_context_setting_inline(
                                 x, y, name)
                         result.append(string)
             # otherwise we've found a default leaf context setting
             else:
                 # parse default context setting
                 string = manager.format_lilypond_context_setting_inline(
                     name, value)
                 result.append(string)
     result.sort()
     bundle.context_settings.extend(result)
예제 #3
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
예제 #4
0
파일: Duration.py 프로젝트: Abjad/abjad
    def _make_markup_score_block(selection):
        import abjad

        selection = copy.deepcopy(selection)
        staff = abjad.Staff(selection)
        staff.lilypond_type = "RhythmicStaff"
        staff.remove_commands.append("Time_signature_engraver")
        staff.remove_commands.append("Staff_symbol_engraver")
        abjad.override(staff).stem.direction = abjad.Up
        abjad.override(staff).stem.length = 5
        abjad.override(staff).tuplet_bracket.bracket_visibility = True
        abjad.override(staff).tuplet_bracket.direction = abjad.Up
        abjad.override(staff).tuplet_bracket.minimum_length = 4
        abjad.override(staff).tuplet_bracket.padding = 1.25
        abjad.override(staff).tuplet_bracket.shorten_pair = (-1, -1.5)
        scheme = abjad.Scheme("ly:spanner::set-spacing-rods")
        abjad.override(staff).tuplet_bracket.springs_and_rods = scheme
        abjad.override(staff).tuplet_number.font_size = 0
        scheme = abjad.Scheme("tuplet-number::calc-fraction-text")
        abjad.override(staff).tuplet_number.text = scheme
        abjad.setting(staff).tuplet_full_length = True
        layout_block = abjad.Block(name="layout")
        layout_block.indent = 0
        layout_block.ragged_right = True
        score = abjad.Score([staff])
        abjad.override(score).spacing_spanner.spacing_increment = 0.5
        abjad.setting(score).proportional_notation_duration = False
        return score, layout_block
예제 #5
0
    def _populate_context_setting_format_contributions(component, bundle):
        import abjad

        result = []
        manager = LilyPondFormatManager
        if isinstance(component, abjad.Context):
            for name, value in vars(abjad.setting(component)).items():
                string = manager.format_lilypond_context_setting_in_with_block(
                    name, value
                )
                result.append(string)
        else:
            contextualizer = abjad.setting(component)
            variables = vars(contextualizer)
            for name, value in variables.items():
                # if we've found a leaf context namespace
                if name.startswith("_"):
                    for x, y in vars(value).items():
                        if not x.startswith("_"):
                            string = manager.format_lilypond_context_setting_inline(
                                x, y, name
                            )
                            result.append(string)
                # otherwise we've found a default leaf context setting
                else:
                    # parse default context setting
                    string = manager.format_lilypond_context_setting_inline(
                        name, value
                    )
                    result.append(string)
        result.sort()
        bundle.context_settings.extend(result)
예제 #6
0
파일: Duration.py 프로젝트: gsy/gmajor
 def _make_markup_score_block(selection):
     import abjad
     selection = copy.deepcopy(selection)
     staff = abjad.Staff(selection)
     staff.lilypond_type = 'RhythmicStaff'
     staff.remove_commands.append('Time_signature_engraver')
     staff.remove_commands.append('Staff_symbol_engraver')
     abjad.override(staff).stem.direction = abjad.Up
     abjad.override(staff).stem.length = 5
     abjad.override(staff).tuplet_bracket.bracket_visibility = True
     abjad.override(staff).tuplet_bracket.direction = abjad.Up
     abjad.override(staff).tuplet_bracket.minimum_length = 4
     abjad.override(staff).tuplet_bracket.padding = 1.25
     abjad.override(staff).tuplet_bracket.shorten_pair = (-1, -1.5)
     scheme = abjad.Scheme('ly:spanner::set-spacing-rods')
     abjad.override(staff).tuplet_bracket.springs_and_rods = scheme
     abjad.override(staff).tuplet_number.font_size = 0
     scheme = abjad.Scheme('tuplet-number::calc-fraction-text')
     abjad.override(staff).tuplet_number.text = scheme
     abjad.setting(staff).tuplet_full_length = True
     layout_block = abjad.Block(name='layout')
     layout_block.indent = 0
     layout_block.ragged_right = True
     score = abjad.Score([staff])
     abjad.override(score).spacing_spanner.spacing_increment = 0.5
     abjad.setting(score).proportional_notation_duration = False
     return score, layout_block
예제 #7
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
예제 #8
0
    def _set_instrument_name(instr_staff: abjad.Staff,
                             instr_obj: abjad.Instrument,
                             is_first_verse: bool) -> None:
        if is_first_verse:
            abjad.setting(instr_staff).instrument_name = instr_obj.markup
        else:
            abjad.setting(instr_staff).instrument_name = instr_obj.short_markup

        abjad.setting(
            instr_staff).short_instrument_name = instr_obj.short_markup
    def __call__(self):
        name = self.instrument.instrument_name.title()
        short_name = self.instrument.short_instrument_name.title()

        bowing_rhythm_staff = abjad.scoretools.Staff(
            [], context_name='RhythmStaff', name='Bowing Rhythm')

        string_space_staff = abjad.scoretools.Staff(
            [],
            context_name='StringSpaceStaff',
            is_simultaneous=True,
            name='String Space')

        fingering_rhythm_staff = abjad.scoretools.Staff(
            [], context_name='RhythmStaff', name='Fingering Rhythm')

        # combine

        staff_list = [
            bowing_rhythm_staff, string_space_staff, fingering_rhythm_staff
        ]

        for staff in staff_list:
            abjad.annotate(staff, 'instrument', name)

        abjad.setting(string_space_staff).instrument_name = abjad.Markup(name)
        abjad.setting(string_space_staff).instrument_name = \
            abjad.Markup(short_name)

        instrument_staff_group = abjad.scoretools.StaffGroup(
            staff_list,
            context_name='BowedStringInstrumentStaffGroup',
            name=name + ' Staff Group')

        # set stem direction

        abjad.override(bowing_rhythm_staff).stem.direction = \
            abjad.schemetools.Scheme('UP')

        abjad.override(fingering_rhythm_staff).stem.direction = \
            abjad.schemetools.Scheme('DOWN')

        # Bar Line visibility
        abjad.override(bowing_rhythm_staff).bar_line.transparent = True
        abjad.override(fingering_rhythm_staff).bar_line.transparent = True

        # set padding

        override.staff_space_after(bowing_rhythm_staff, 2)
        override.staff_space_after(string_space_staff, 2)
        override.staff_space_after(fingering_rhythm_staff, 10)

        return instrument_staff_group
예제 #10
0
def test_lilypondproxytools_LilyPondSettingNameManager___eq___01():

    note_1 = abjad.Note("c'4")
    abjad.setting(note_1).voice.auto_beaming = False
    abjad.setting(note_1).staff.tuplet_full_length = True

    note_2 = abjad.Note("c'4")
    abjad.setting(note_2).voice.auto_beaming = False
    abjad.setting(note_2).staff.tuplet_full_length = True

    note_3 = abjad.Note("c'4")
    abjad.setting(note_3).voice.auto_beaming = True

    context_setting_component_plug_in_1 = abjad.setting(note_1)
    context_setting_component_plug_in_2 = abjad.setting(note_2)
    context_setting_component_plug_in_3 = abjad.setting(note_3)

    assert      context_setting_component_plug_in_1 == context_setting_component_plug_in_1
    assert      context_setting_component_plug_in_1 == context_setting_component_plug_in_2
    assert not context_setting_component_plug_in_1 == context_setting_component_plug_in_3
    assert      context_setting_component_plug_in_2 == context_setting_component_plug_in_1
    assert      context_setting_component_plug_in_2 == context_setting_component_plug_in_2
    assert not context_setting_component_plug_in_2 == context_setting_component_plug_in_3
    assert not context_setting_component_plug_in_3 == context_setting_component_plug_in_1
    assert not context_setting_component_plug_in_3 == context_setting_component_plug_in_2
    assert      context_setting_component_plug_in_3 == context_setting_component_plug_in_3
def test_lilypondproxytools_LilyPondNameManager___eq___01():

    note_1 = abjad.Note("c'4")
    abjad.setting(note_1).voice.auto_beaming = False
    abjad.setting(note_1).voice.tuplet_full_length = True

    note_2 = abjad.Note("c'4")
    abjad.setting(note_2).voice.auto_beaming = False
    abjad.setting(note_2).voice.tuplet_full_length = True

    note_3 = abjad.Note("c'4")
    abjad.setting(note_3).voice.auto_beaming = True

    context_proxy_1 = abjad.setting(note_1).voice
    context_proxy_2 = abjad.setting(note_2).voice
    context_proxy_3 = abjad.setting(note_3).voice

    assert      context_proxy_1 == context_proxy_1
    assert      context_proxy_1 == context_proxy_2
    assert not context_proxy_1 == context_proxy_3
    assert      context_proxy_2 == context_proxy_1
    assert      context_proxy_2 == context_proxy_2
    assert not context_proxy_2 == context_proxy_3
    assert not context_proxy_3 == context_proxy_1
    assert not context_proxy_3 == context_proxy_2
    assert      context_proxy_3 == context_proxy_3
def test_LilyPondNameManager___eq___01():

    note_1 = abjad.Note("c'4")
    abjad.setting(note_1).voice.auto_beaming = False
    abjad.setting(note_1).voice.tuplet_full_length = True

    note_2 = abjad.Note("c'4")
    abjad.setting(note_2).voice.auto_beaming = False
    abjad.setting(note_2).voice.tuplet_full_length = True

    note_3 = abjad.Note("c'4")
    abjad.setting(note_3).voice.auto_beaming = True

    context_proxy_1 = abjad.setting(note_1).voice
    context_proxy_2 = abjad.setting(note_2).voice
    context_proxy_3 = abjad.setting(note_3).voice

    assert context_proxy_1 == context_proxy_1
    assert context_proxy_1 == context_proxy_2
    assert not context_proxy_1 == context_proxy_3
    assert context_proxy_2 == context_proxy_1
    assert context_proxy_2 == context_proxy_2
    assert not context_proxy_2 == context_proxy_3
    assert not context_proxy_3 == context_proxy_1
    assert not context_proxy_3 == context_proxy_2
    assert context_proxy_3 == context_proxy_3
def test_LilyPondSettingNameManager___setattr___13():
    """
    Define LilyPond tupletFullLength context abjad.setting.
    """

    staff = abjad.Staff([])
    abjad.setting(staff).tuplet_full_length = True

    assert format(staff) == abjad.String.normalize(
        r"""
        \new Staff
        \with
        {
            tupletFullLength = ##t
        }
        {
        }
        """
    )

    assert not len(staff)

    abjad.setting(staff).tuplet_full_length = False

    assert format(staff) == abjad.String.normalize(
        r"""
        \new Staff
        \with
        {
            tupletFullLength = ##f
        }
        {
        }
        """
    )

    assert not len(staff)

    del abjad.setting(staff).tuplet_full_length

    assert format(staff) == abjad.String.normalize(
        r"""
        \new Staff
        {
        }
        """
    )

    assert not len(staff)
예제 #14
0
    def __call__(self):

        # Violin
        violin_staff = abjad.Staff(
            [abjad.Voice(name='Violin Voice')],
            name='Violin Staff',
            lilypond_type='ViolinStaff',
        )
        violin_tag = abjad.LilyPondLiteral(r"\tag #'violin",
                                           format_slot='before')
        abjad.attach(violin_tag, violin_staff)
        abjad.setting(violin_staff).midi_instrument = abjad.scheme.Scheme(
            'violin', force_quotes=True)

        # Viola
        viola_staff = abjad.Staff(
            [abjad.Voice(name='Viola Voice')],
            name='Viola Staff',
            lilypond_type='ViolaStaff',
        )
        viola_tag = abjad.LilyPondLiteral(r"\tag #'viola",
                                          format_slot='before')
        abjad.attach(viola_tag, viola_staff)
        abjad.setting(viola_staff).midi_instrument = abjad.scheme.Scheme(
            'viola', force_quotes=True)

        # Cello
        cello_staff = abjad.Staff(
            [abjad.Voice(name='Cello Voice')],
            name='Cello Staff',
            lilypond_type='CelloStaff',
        )
        cello_tag = abjad.LilyPondLiteral(r"\tag #'cello",
                                          format_slot='before')
        abjad.attach(cello_tag, cello_staff)
        abjad.setting(cello_staff).midi_instrument = abjad.scheme.Scheme(
            'cello', force_quotes=True)

        # Everything else
        staff_group = abjad.StaffGroup(
            [violin_staff, viola_staff, cello_staff],
            name='Trio Staff Group',
        )
        score = abjad.Score(
            [staff_group],
            name='Trio Score',
        )

        return score
예제 #15
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
def test_LilyPondSettingNameManager___setattr___10():
    """
    Define LilyPond shortInstrumentName context abjad.setting.
    """

    staff = abjad.Staff("c'8 d'8 e'8 f'8")
    abjad.setting(staff).short_instrument_name = abjad.Markup(r"\circle { V }")

    assert format(staff) == abjad.String.normalize(
        r"""
        \new Staff
        \with
        {
            shortInstrumentName = \markup {
                \circle
                    {
                        V
                    }
                }
        }
        {
            c'8
            d'8
            e'8
            f'8
        }
        """
    )

    assert abjad.inspect(staff).wellformed()
def test_LilyPondSettingNameManager___setattr___09():
    """
    Define LilyPond shortInstrumentName context abjad.setting.
    """

    staff = abjad.Staff("c'8 d'8 e'8 f'8")
    abjad.setting(staff).short_instrument_name = "Vni. I"

    assert format(staff) == abjad.String.normalize(
        r"""
        \new Staff
        \with
        {
            shortInstrumentName = #"Vni. I"
        }
        {
            c'8
            d'8
            e'8
            f'8
        }
        """
    )

    assert abjad.inspect(staff).wellformed()
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()
def test_LilyPondSettingNameManager___setattr___05():
    """
    Define LilyPond fontSize context abjad.setting.
    """

    staff = abjad.Staff("c'8 d'8 e'8 f'8")
    abjad.setting(staff).font_size = -3

    assert format(staff) == abjad.String.normalize(
        r"""
        \new Staff
        \with
        {
            fontSize = #-3
        }
        {
            c'8
            d'8
            e'8
            f'8
        }
        """
    )

    assert abjad.inspect(staff).wellformed()
def test_lilypondproxytools_LilyPondSettingNameManager___setattr___04():
    """
    Define LilyPond currentBarNumber context abjad.setting.
    """

    staff = abjad.Staff()
    staff.append(abjad.Measure((2, 8), "c'8 d'8"))
    staff.append(abjad.Measure((2, 8), "e'8 f'8"))
    abjad.setting(staff[0]).score.current_bar_number = 12

    assert format(staff) == abjad.String.normalize(
        r"""
        \new Staff
        {
            {   % measure
                \set Score.currentBarNumber = #12
                \time 2/8
                c'8
                d'8
            }   % measure
            {   % measure
                e'8
                f'8
            }   % measure
        }
        """
        )

    assert abjad.inspect(staff).is_well_formed()
예제 #21
0
def test_scoretools_Voice___copy___01():
    r'''Voices copy name, engraver removals, engraver consists,
    grob abjad.overrides and context abjad.settings. Voices do not copy
    components.
    '''

    voice_1 = abjad.Voice("c'8 d'8 e'8 f'8")
    voice_1.name = 'SopranoVoice'
    voice_1.remove_commands.append('Forbid_line_break_engraver')
    voice_1.consists_commands.append('Time_signature_engraver')
    abjad.override(voice_1).note_head.color = 'red'
    abjad.setting(voice_1).tuplet_full_length = True
    voice_2 = copy.copy(voice_1)

    assert format(voice_2) == abjad.String.normalize(
        r'''
        \context Voice = "SopranoVoice"
        \with
        {
            \remove Forbid_line_break_engraver
            \consists Time_signature_engraver
            \override NoteHead.color = #red
            tupletFullLength = ##t
        }
        {
        }
        '''
        )
def test_lilypondproxytools_LilyPondSettingNameManager___setattr___06():
    """
    Define LilyPond instrumentName context abjad.setting.
    """

    staff = abjad.Staff("c'8 d'8 e'8 f'8")
    abjad.setting(staff).instrument_name = 'Violini I'

    assert format(staff) == abjad.String.normalize(
        r"""
        \new Staff
        \with
        {
            instrumentName = #"Violini I"
        }
        {
            c'8
            d'8
            e'8
            f'8
        }
        """
        )

    assert abjad.inspect(staff).is_well_formed()
예제 #23
0
def test_LilyPondSettingNameManager___setattr___10():
    """
    Define LilyPond shortInstrumentName context abjad.setting.
    """

    staff = abjad.Staff("c'8 d'8 e'8 f'8")
    abjad.setting(staff).short_instrument_name = abjad.Markup(r'\circle { V }')

    assert format(staff) == abjad.String.normalize(r"""
        \new Staff
        \with
        {
            shortInstrumentName = \markup {
                \circle
                    {
                        V
                    }
                }
        }
        {
            c'8
            d'8
            e'8
            f'8
        }
        """)

    assert abjad.inspect(staff).wellformed()
예제 #24
0
파일: test_setting.py 프로젝트: Abjad/abjad
def test_setting_02():
    r"""
    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
            }
        >>
        """
    )
def test_LilyPondSettingNameManager___setattr___11():
    """
    Define LilyPond suggestAccidentals context abjad.setting.
    """

    staff = abjad.Staff("c'8 d'8 e'8 f'8")
    abjad.setting(staff).suggest_accidentals = True

    assert format(staff) == abjad.String.normalize(
        r"""
        \new Staff
        \with
        {
            suggestAccidentals = ##t
        }
        {
            c'8
            d'8
            e'8
            f'8
        }
        """
    )

    assert abjad.inspect(staff).wellformed()
def test_LilyPondSettingNameManager___setattr___01():
    """
    Define LilyPond autoBeaming context abjad.setting.
    """

    staff = abjad.Staff("c'8 d'8 e'8 f'8")
    abjad.setting(staff).auto_beaming = True

    assert format(staff) == abjad.String.normalize(
        r"""
        \new Staff
        \with
        {
            autoBeaming = ##t
        }
        {
            c'8
            d'8
            e'8
            f'8
        }
        """
    )

    assert abjad.inspect(staff).wellformed()
def test_lilypondproxytools_LilyPondSettingNameManager___setattr___07():
    """
    Define LilyPond instrumentName context abjad.setting.
    """

    staff = abjad.Staff("c'8 d'8 e'8 f'8")
    abjad.setting(staff).instrument_name = abjad.Markup(r'\circle { V }')

    assert format(staff) == abjad.String.normalize(
        r"""
        \new Staff
        \with
        {
            instrumentName = \markup {
                \circle
                    {
                        V
                    }
                }
        }
        {
            c'8
            d'8
            e'8
            f'8
        }
        """
        )

    assert abjad.inspect(staff).is_well_formed()
def test_LilyPondSettingNameManager___setattr___04():
    """
    Define LilyPond currentBarNumber context abjad.setting.
    """

    staff = abjad.Staff()
    staff.append(abjad.Container("c'8 d'8"))
    staff.append(abjad.Container("e'8 f'8"))
    abjad.setting(staff[0]).score.current_bar_number = 12

    assert format(staff) == abjad.String.normalize(
        r"""
        \new Staff
        {
            {
                \set Score.currentBarNumber = #12
                c'8
                d'8
            }
            {
                e'8
                f'8
            }
        }
        """
    )

    assert abjad.inspect(staff).wellformed()
예제 #29
0
파일: test_setting.py 프로젝트: Abjad/abjad
def test_setting_01():
    r"""
    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
            }
        >>
        """
    )
예제 #30
0
파일: part.py 프로젝트: Abjad/abjad
def configure_score(score):
    """
    Configures score.
    """
    # configure bell staff
    bell_staff = score["Bell Staff"]
    leaf = abjad.inspect(bell_staff).leaf(0)
    clef = abjad.Clef("treble")
    abjad.attach(clef, leaf)
    bells = abjad.Instrument(
        name="Campana in La", short_name="Camp.", pitch_range="[C4, C6]"
    )
    abjad.attach(bells, leaf)
    mark = abjad.MetronomeMark((1, 4), (112, 120))
    abjad.attach(mark, leaf)
    # time_signature = abjad.TimeSignature((6, 4))
    # abjad.attach(time_signature, leaf)
    # configure first violin staff
    first_violin_staff = score["First Violin Staff"]
    leaf = abjad.inspect(first_violin_staff).leaf(0)
    clef = abjad.Clef("treble")
    abjad.attach(clef, leaf)
    violin = abjad.Violin(
        markup=abjad.Markup("Violin I"), short_markup=abjad.Markup("Vl. I")
    )
    abjad.attach(violin, leaf)
    # configure second violin staff
    second_violin_staff = score["Second Violin Staff"]
    leaf = abjad.inspect(second_violin_staff).leaf(0)
    clef = abjad.Clef("treble")
    abjad.attach(clef, leaf)
    violin = abjad.Violin(
        markup=abjad.Markup("Violin II"), short_markup=abjad.Markup("Vl. II")
    )
    abjad.attach(violin, leaf)
    # configure viola staff
    leaf = abjad.inspect(score["Viola Staff"]).leaf(0)
    clef = abjad.Clef("alto")
    abjad.attach(clef, leaf)
    viola = abjad.Viola()
    abjad.attach(viola, leaf)
    # configure cello staff
    leaf = abjad.inspect(score["Cello Staff"]).leaf(0)
    clef = abjad.Clef("bass")
    abjad.attach(clef, leaf)
    cello = abjad.Cello()
    abjad.attach(cello, leaf)
    # configure bass staff
    leaf = abjad.inspect(score["Bass Staff"]).leaf(0)
    clef = abjad.Clef("bass")
    abjad.attach(clef, leaf)
    contrabass = abjad.Contrabass(short_markup=abjad.Markup("Cb."))
    abjad.attach(contrabass, leaf)
    # configure score
    vector = abjad.SpacingVector(0, 0, 8, 0)
    abjad.override(score).vertical_axis_group.staff_staff_spacing = vector
    abjad.override(score).staff_grouper.staff_staff_spacing = vector
    abjad.override(score).staff_symbol.thickness = 0.5
    scheme = abjad.Scheme("format-mark-box-numbers")
    abjad.setting(score).mark_formatter = scheme
예제 #31
0
def test_Voice___copy___01():
    """
    Voices copy name, engraver removals, engraver consists, grob overrides and
    context settings. Voices do not copy components.
    """

    voice_1 = abjad.Voice("c'8 d'8 e'8 f'8")
    voice_1.name = "SopranoVoice"
    voice_1.remove_commands.append("Forbid_line_break_engraver")
    voice_1.consists_commands.append("Time_signature_engraver")
    abjad.override(voice_1).note_head.color = "red"
    abjad.setting(voice_1).tuplet_full_length = True
    voice_2 = copy.copy(voice_1)

    assert format(voice_2) == abjad.String.normalize(
        r"""
        \context Voice = "SopranoVoice"
        \with
        {
            \remove Forbid_line_break_engraver
            \consists Time_signature_engraver
            \override NoteHead.color = #red
            tupletFullLength = ##t
        }
        {
        }
        """
    )
예제 #32
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()
예제 #33
0
def make_conductor_part():
    """Renders a conductor part as PDF"""
    flat = flatten_list(time_signatures)
    measures = make_spacer_skip_measures(flat)
    for i, tempo in tempo_map:
        abjad.attach(tempo, measures[i])
    stage_indices = []
    total = 0
    for n in measures_per_stage:
        stage_indices.append(total)
        total += n
    for letter_number, i in enumerate(stage_indices):
        rehearsal_mark = abjad.indicatortools.RehearsalMark(
            number=letter_number + 1)
        abjad.attach(rehearsal_mark, measures[i][0])
    staff = abjad.Staff(measures, context_name='RhythmicStaff')
    score = abjad.Score([staff])
    scheme = abjad.schemetools.Scheme('format-mark-box-alphabet')
    abjad.setting(score).markFormatter = scheme
    stylesheet_path = os.path.join(
        '..',
        'stylesheets',
        'stylesheet_conductor.ily',
    )
    lilypond_file = abjad.LilyPondFile.new(score,
                                           default_paper_size=('letter',
                                                               'portrait'),
                                           global_staff_size=16,
                                           includes=[stylesheet_path],
                                           use_relative_includes=True)
    return lilypond_file
예제 #34
0
파일: ferneyhough.py 프로젝트: Abjad/abjad
 def configure_score(self, score):
     """
     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
예제 #35
0
def test_LilyPondSettingNameManager___setattr___04():
    """
    Define LilyPond currentBarNumber context abjad.setting.
    """

    staff = abjad.Staff()
    staff.append(abjad.Container("c'8 d'8"))
    staff.append(abjad.Container("e'8 f'8"))
    abjad.setting(staff[0]).score.current_bar_number = 12

    assert format(staff) == abjad.String.normalize(r"""
        \new Staff
        {
            {
                \set Score.currentBarNumber = #12
                c'8
                d'8
            }
            {
                e'8
                f'8
            }
        }
        """)

    assert abjad.inspect(staff).wellformed()
예제 #36
0
def test_lilypondproxytools_LilyPondGrobNameManager___setattr___17():
    r'''Override LilyPond InstrumentName grob.
    '''

    staff = abjad.Staff("c'8 d'8 e'8 f'8")
    abjad.setting(staff).instrument_name = abjad.Markup(r'\circle { V }')
    abjad.override(staff).instrument_name.color = 'red'

    assert format(staff) == abjad.String.normalize(
        r'''
        \new Staff
        \with
        {
            \override InstrumentName.color = #red
            instrumentName = \markup {
                \circle
                    {
                        V
                    }
                }
        }
        {
            c'8
            d'8
            e'8
            f'8
        }
        ''', )

    assert abjad.inspect(staff).is_well_formed()
def make_conductor_part():
    """Renders a conductor part as PDF"""
    flat = flatten_list(time_signatures)
    measures = make_spacer_skip_measures(flat)
    for i, tempo in tempo_map:
        abjad.attach(tempo, measures[i])
    stage_indices = []
    total = 0
    for n in measures_per_stage:
        stage_indices.append(total)
        total += n
    for letter_number, i in enumerate(stage_indices):
        rehearsal_mark = abjad.indicatortools.RehearsalMark(
            number=letter_number + 1
        )
        abjad.attach(rehearsal_mark, measures[i][0])
    staff = abjad.Staff(measures, context_name='RhythmicStaff')
    score = abjad.Score([staff])
    scheme = abjad.schemetools.Scheme('format-mark-box-alphabet')
    abjad.setting(score).markFormatter = scheme
    stylesheet_path = os.path.join(
        '..',
        'stylesheets',
        'stylesheet_conductor.ily',
    )
    lilypond_file = abjad.LilyPondFile.new(
        score,
        default_paper_size=('letter', 'portrait'),
        global_staff_size=16,
        includes=[stylesheet_path],
        use_relative_includes=True
    )
    return lilypond_file
def test_LilyPondGrobNameManager___setattr___12():
    """
    Override LilyPond InstrumentName grob.
    """

    staff = abjad.Staff("c'8 d'8 e'8 f'8")
    abjad.setting(staff).instrument_name = abjad.Markup(r"\circle { V }")
    abjad.override(staff).instrument_name.color = "red"

    assert format(staff) == abjad.String.normalize(
        r"""
        \new Staff
        \with
        {
            \override InstrumentName.color = #red
            instrumentName = \markup {
                \circle
                    {
                        V
                    }
                }
        }
        {
            c'8
            d'8
            e'8
            f'8
        }
        """
    )

    assert abjad.inspect(staff).wellformed()
예제 #39
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
            }
        >>
        """)
예제 #40
0
def test_half_piano_pedal_06():
    staff = abjad.Staff(r"c'4 d'4 e'4 f'4")
    auxjad.half_piano_pedal(
        staff[:],
        until_the_end=True,
    )
    abjad.setting(staff).pedal_sustain_style = "#'mixed"
    assert format(staff) == abjad.String.normalize(r"""
        \new Staff
        \with
        {
            pedalSustainStyle = #'mixed
        }
        {
            \once \override Staff.SustainPedal.stencil =
                #(lambda (grob) (grob-interpret-markup grob
                    #{
                        \markup {
                            \larger "½"
                            \concat {
                                \musicglyph "pedal.Ped"
                                \musicglyph "pedal.."
                            }
                            \raise #-0.3 "→"
                        }
                    #}))
            c'4
            \sustainOn
            d'4
            e'4
            f'4
            \sustainOff
        }
        """)
예제 #41
0
def test_Voice___copy___01():
    """
    Voices copy name, engraver removals, engraver consists, grob overrides and
    context settings. Voices do not copy components.
    """

    voice_1 = abjad.Voice("c'8 d'8 e'8 f'8")
    voice_1.name = "SopranoVoice"
    voice_1.remove_commands.append("Forbid_line_break_engraver")
    voice_1.consists_commands.append("Time_signature_engraver")
    abjad.override(voice_1).note_head.color = "red"
    abjad.setting(voice_1).tuplet_full_length = True
    voice_2 = copy.copy(voice_1)

    assert abjad.lilypond(voice_2) == abjad.String.normalize(
        r"""
        \context Voice = "SopranoVoice"
        \with
        {
            \remove Forbid_line_break_engraver
            \consists Time_signature_engraver
            \override NoteHead.color = #red
            tupletFullLength = ##t
        }
        {
        }
        """
    )
예제 #42
0
def test_LilyPondGrobNameManager___setattr___12():
    """
    Override LilyPond InstrumentName grob.
    """

    staff = abjad.Staff("c'8 d'8 e'8 f'8")
    abjad.setting(staff).instrument_name = abjad.Markup(r"\circle { V }")
    abjad.override(staff).instrument_name.color = "red"

    assert format(staff) == abjad.String.normalize(r"""
        \new Staff
        \with
        {
            \override InstrumentName.color = #red
            instrumentName = \markup {
                \circle
                    {
                        V
                    }
                }
        }
        {
            c'8
            d'8
            e'8
            f'8
        }
        """)

    assert abjad.inspect(staff).wellformed()
예제 #43
0
    def __copy__(self, *arguments):
        r'''Shallow copies component.

        Copies indicators.

        Does not copy spanners.

        Does not copy children.

        Returns new component.
        '''
        import abjad
        new_component = type(self)(*self.__getnewargs__())
        if getattr(self, '_lilypond_grob_name_manager', None) is not None:
            manager = copy.copy(abjad.override(self))
            new_component._lilypond_grob_name_manager = manager
        if getattr(self, '_lilypond_setting_name_manager', None) is not None:
            manager = copy.copy(abjad.setting(self))
            new_component._lilypond_setting_name_manager = manager
        for wrapper in abjad.inspect(self).annotations():
            new_wrapper = copy.copy(wrapper)
            abjad.attach(new_wrapper, new_component)
        for wrapper in abjad.inspect(self).wrappers():
            if wrapper.spanner is None:
                new_wrapper = copy.copy(wrapper)
                abjad.attach(new_wrapper, new_component)
        return new_component
예제 #44
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
            }
        >>
        """)
예제 #45
0
파일: trio.py 프로젝트: Abjad/intensive
def add_midi_instruments(score):
    violin_staff = score['Violin Staff']
    abjad.setting(violin_staff).midi_instrument = abjad.scheme.Scheme(
        'violin', force_quotes=True)
    viola_staff = score['Viola Staff']
    abjad.setting(viola_staff).midi_instrument = abjad.scheme.Scheme(
        'viola', force_quotes=True)
    cello_staff = score['Cello Staff']
    abjad.setting(cello_staff).midi_instrument = abjad.scheme.Scheme(
        'cello', force_quotes=True)
    abjad.attach(abjad.Clef('alto'), viola_staff[0][0])
    abjad.attach(abjad.Clef('bass'), cello_staff[0][0])
    abjad.attach(abjad.Clef('treble'), violin_staff[0][0])
    abjad.attach(abjad.instruments.Cello(), cello_staff[0][0])
    abjad.attach(abjad.instruments.Viola(), viola_staff[0][0])
    abjad.attach(abjad.instruments.Violin(), violin_staff[0][0])
    return score
예제 #46
0
 def add_midi_instruments(self, score):
     violin_staff = score['Violin Staff']
     abjad.setting(violin_staff).midi_instrument = abjad.scheme.Scheme(
         'violin', force_quotes=True)
     viola_staff = score['Viola Staff']
     abjad.setting(viola_staff).midi_instrument = abjad.scheme.Scheme(
         'viola', force_quotes=True)
     cello_staff = score['Cello Staff']
     abjad.setting(cello_staff).midi_instrument = abjad.scheme.Scheme(
         'cello', force_quotes=True)
     abjad.attach(abjad.Clef('alto'), viola_staff[0][0])
     abjad.attach(abjad.Clef('bass'), cello_staff[0][0])
     abjad.attach(abjad.Clef('treble'), violin_staff[0][0])
     abjad.attach(abjad.instruments.Cello(), cello_staff[0][0])
     abjad.attach(abjad.instruments.Viola(), viola_staff[0][0])
     abjad.attach(abjad.instruments.Violin(), violin_staff[0][0])
     return score
예제 #47
0
    def __call__(self):

        # Violin
        violin_staff = abjad.Staff(
            [abjad.Voice(name='Violin Voice')],
            name='Violin Staff',
            lilypond_type='ViolinStaff',
            )
        violin_tag = abjad.LilyPondLiteral(r"\tag #'violin", format_slot='before')
        abjad.attach(violin_tag, violin_staff)
        abjad.setting(violin_staff).midi_instrument = abjad.scheme.Scheme(
            'violin', force_quotes=True)

        # Viola
        viola_staff = abjad.Staff(
            [abjad.Voice(name='Viola Voice')],
            name='Viola Staff',
            lilypond_type='ViolaStaff',
            )
        viola_tag = abjad.LilyPondLiteral(r"\tag #'viola", format_slot='before')
        abjad.attach(viola_tag, viola_staff)
        abjad.setting(viola_staff).midi_instrument = abjad.scheme.Scheme(
            'viola', force_quotes=True)

        # Cello
        cello_staff = abjad.Staff(
            [abjad.Voice(name='Cello Voice')],
            name='Cello Staff',
            lilypond_type='CelloStaff',
            )
        cello_tag = abjad.LilyPondLiteral(r"\tag #'cello", format_slot='before')
        abjad.attach(cello_tag, cello_staff)
        abjad.setting(cello_staff).midi_instrument = abjad.scheme.Scheme(
            'cello', force_quotes=True)

        # Everything else
        staff_group = abjad.StaffGroup(
            [violin_staff, viola_staff, cello_staff],
            name='Trio Staff Group',
            )
        score = abjad.Score(
            [staff_group],
            name='Trio Score',
            )

        return score
예제 #48
0
def configure_score(score):
    """
    Configures score.
    """
    # configure bell staff
    bell_staff = score["Bell Staff"]
    leaf = abjad.inspect(bell_staff).leaf(0)
    clef = abjad.Clef("treble")
    abjad.attach(clef, leaf)
    bells = abjad.Instrument(name="Campana in La",
                             short_name="Camp.",
                             pitch_range="[C4, C6]")
    abjad.attach(bells, leaf)
    mark = abjad.MetronomeMark((1, 4), (112, 120))
    abjad.attach(mark, leaf)
    # time_signature = abjad.TimeSignature((6, 4))
    # abjad.attach(time_signature, leaf)
    # configure first violin staff
    first_violin_staff = score["First Violin Staff"]
    leaf = abjad.inspect(first_violin_staff).leaf(0)
    clef = abjad.Clef("treble")
    abjad.attach(clef, leaf)
    violin = abjad.Violin(markup=abjad.Markup("Violin I"),
                          short_markup=abjad.Markup("Vl. I"))
    abjad.attach(violin, leaf)
    # configure second violin staff
    second_violin_staff = score["Second Violin Staff"]
    leaf = abjad.inspect(second_violin_staff).leaf(0)
    clef = abjad.Clef("treble")
    abjad.attach(clef, leaf)
    violin = abjad.Violin(markup=abjad.Markup("Violin II"),
                          short_markup=abjad.Markup("Vl. II"))
    abjad.attach(violin, leaf)
    # configure viola staff
    leaf = abjad.inspect(score["Viola Staff"]).leaf(0)
    clef = abjad.Clef("alto")
    abjad.attach(clef, leaf)
    viola = abjad.Viola()
    abjad.attach(viola, leaf)
    # configure cello staff
    leaf = abjad.inspect(score["Cello Staff"]).leaf(0)
    clef = abjad.Clef("bass")
    abjad.attach(clef, leaf)
    cello = abjad.Cello()
    abjad.attach(cello, leaf)
    # configure bass staff
    leaf = abjad.inspect(score["Bass Staff"]).leaf(0)
    clef = abjad.Clef("bass")
    abjad.attach(clef, leaf)
    contrabass = abjad.Contrabass(short_markup=abjad.Markup("Cb."))
    abjad.attach(contrabass, leaf)
    # configure score
    vector = abjad.SpacingVector(0, 0, 8, 0)
    abjad.override(score).vertical_axis_group.staff_staff_spacing = vector
    abjad.override(score).staff_grouper.staff_staff_spacing = vector
    abjad.override(score).staff_symbol.thickness = 0.5
    scheme = abjad.Scheme("format-mark-box-numbers")
    abjad.setting(score).mark_formatter = scheme
예제 #49
0
 def _configure_rehearsal_mark(self):
     mark_num = self.rehearsal_mark
     voices = self._music_voices
     for voice in voices:
         leaf = abjad.inspect(voice).leaf(0)
         abjad.attach(abjad.RehearsalMark(number=mark_num), leaf)
     scheme = abjad.Scheme('format-mark-box-alphabet')
     score = self._score
     abjad.setting(score).markFormatter = scheme
예제 #50
0
 def _get_format_pieces(self):
     import abjad
     indent = abjad.LilyPondFormatManager.indent
     result = []
     string = '{} {{'.format(self._escaped_name)
     result.append(string)
     manager = abjad.LilyPondFormatManager
     # CAUTION: source context name must come before type_ to allow
     # context redefinition.
     if self.source_lilypond_type is not None:
         string = indent + r'\{}'.format(self.source_lilypond_type)
         result.append(string)
     if self.name is not None:
         string = indent + r'\name {}'.format(self.name)
         result.append(string)
     if self.type_ is not None:
         string = indent + r'\type {}'.format(self.type_)
         result.append(string)
     if self.alias is not None:
         string = indent + r'\alias {}'.format(self.alias)
         result.append(string)
     for statement in self.remove_commands:
         string = indent + r'\remove {}'.format(statement)
         result.append(string)
     # CAUTION: LilyPond \consists statements are order-significant!
     for statement in self.consists_commands:
         string = indent + r'\consists {}'.format(statement)
         result.append(string)
     for statement in self.accepts_commands:
         string = indent + r'\accepts {}'.format(statement)
         result.append(string)
     overrides = abjad.override(self)._list_format_contributions('override')
     for statement in overrides:
         string = indent + statement
         result.append(string)
     setting_contributions = []
     for key, value in abjad.setting(self)._get_attribute_tuples():
         setting_contribution = \
             manager.format_lilypond_context_setting_in_with_block(
                 key, value)
         setting_contributions.append(setting_contribution)
     for setting_contribution in sorted(setting_contributions):
         string = indent + setting_contribution
         result.append(string)
     for item in self.items:
         if isinstance(item, str):
             string = indent + '{}'.format(item)
             result.append(string)
         elif '_get_format_pieces' in dir(item):
             pieces = item._get_format_pieces()
             pieces = [indent + item for item in pieces]
             result.extend(pieces)
         else:
             pass
     result.append('}')
     return result
예제 #51
0
def test_LilyPondSettingNameManager___setattr___13():
    """
    Define LilyPond tupletFullLength context abjad.setting.
    """

    staff = abjad.Staff([])
    abjad.setting(staff).tuplet_full_length = True

    assert format(staff) == abjad.String.normalize(r"""
        \new Staff
        \with
        {
            tupletFullLength = ##t
        }
        {
        }
        """)

    assert not len(staff)

    abjad.setting(staff).tuplet_full_length = False

    assert format(staff) == abjad.String.normalize(r"""
        \new Staff
        \with
        {
            tupletFullLength = ##f
        }
        {
        }
        """)

    assert not len(staff)

    del (abjad.setting(staff).tuplet_full_length)

    assert format(staff) == abjad.String.normalize(r"""
        \new Staff
        {
        }
        """)

    assert not len(staff)
예제 #52
0
파일: Scale.py 프로젝트: tchiwinpiti/abjad
    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
예제 #53
0
def test_LilyPondSettingNameManager___setattr___02():
    """
    Remove LilyPond autoBeaming context abjad.setting.
    """

    staff = abjad.Staff("c'8 d'8 e'8 f'8")
    abjad.setting(staff).auto_beaming = True
    del (abjad.setting(staff).auto_beaming)

    assert format(staff) == abjad.String.normalize(r"""
        \new Staff
        {
            c'8
            d'8
            e'8
            f'8
        }
        """)

    assert abjad.inspect(staff).wellformed()
def test_lilypondproxytools_LilyPondSettingNameManager___setattr___02():
    """
    Remove LilyPond autoBeaming context abjad.setting.
    """

    staff = abjad.Staff("c'8 d'8 e'8 f'8")
    abjad.setting(staff).auto_beaming = True
    del(abjad.setting(staff).auto_beaming)

    assert format(staff) == abjad.String.normalize(
        r"""
        \new Staff
        {
            c'8
            d'8
            e'8
            f'8
        }
        """
        )

    assert abjad.inspect(staff).is_well_formed()
예제 #55
0
파일: trio.py 프로젝트: Abjad/intensive
def prettify_score(score):
    abjad.override(score).spacing_spanner.strict_grace_spacing = True
    abjad.override(score).spacing_spanner.strict_note_spacing = True
    abjad.override(score).spacing_spanner.uniform_stretching = True
    abjad.override(score).stem.length = 8.25
    abjad.override(score).text_script.outside_staff_padding = 1
    abjad.override(score).tuplet_bracket.bracket_visibility = True
    abjad.override(score).tuplet_bracket.minimum_length = 3
    abjad.override(score).tuplet_bracket.outside_staff_padding = 1.5
    abjad.override(score).tuplet_bracket.padding = 1.5
    abjad.override(score).tuplet_bracket.springs_and_rods = \
        abjad.scheme.Scheme('ly:spanner::set-spacing-rods', verbatim=True)
    abjad.override(score).tuplet_bracket.staff_padding = 2.25
    abjad.override(score).tuplet_number.text = \
        abjad.scheme.Scheme('tuplet-number::calc-fraction-text', verbatim=True)
    abjad.setting(score).proportional_notation_duration = \
        abjad.scheme.SchemeMoment((1, 24))
    abjad.setting(score).tuplet_full_length = True
    lilypond_file = abjad.lilypondfile.LilyPondFile.new(score)
    lilypond_file.layout_block.indent = abjad.lilypondfile.LilyPondDimension(20, 'mm')
    lilypond_file.layout_block.short_indent = abjad.lilypondfile.LilyPondDimension(15, 'mm')
    return lilypond_file
예제 #56
0
 def _copy_override_and_set_from_leaf(self, leaf):
     import abjad
     if getattr(leaf, '_lilypond_grob_name_manager', None) is not None:
         self._lilypond_grob_name_manager = copy.copy(abjad.override(leaf))
     if getattr(leaf, '_lilypond_setting_name_manager', None) is not None:
         self._lilypond_setting_name_manager = copy.copy(
             abjad.setting(leaf))
     new_indicators = []
     for indicator in leaf._indicator_wrappers:
         new_indicator = copy.copy(indicator)
         new_indicators.append(new_indicator)
     for new_indicator in new_indicators:
         abjad.attach(new_indicator, self)
예제 #57
0
def test_Rest___copy___03():
    """
    Copy rest with LilyPond grob overrides and LilyPond context settings.
    """

    rest_1 = abjad.Rest((1, 4))
    abjad.override(rest_1).staff.note_head.color = "red"
    abjad.override(rest_1).accidental.color = "red"
    abjad.setting(rest_1).tuplet_full_length = True
    rest_2 = copy.copy(rest_1)

    assert isinstance(rest_1, abjad.Rest)
    assert isinstance(rest_2, abjad.Rest)
    assert format(rest_1) == format(rest_2)
    assert rest_1 is not rest_2
예제 #58
0
def test_Chord___copy___03():
    """
    Chord copies LilyPond grob overrides and LilyPond context settings.
    """

    chord_1 = abjad.Chord("<ef' cs'' f''>4")
    abjad.override(chord_1).staff.note_head.color = "red"
    abjad.override(chord_1).accidental.color = "red"
    abjad.setting(chord_1).tuplet_full_length = True
    chord_2 = copy.copy(chord_1)

    assert isinstance(chord_1, abjad.Chord)
    assert isinstance(chord_2, abjad.Chord)
    assert format(chord_1) == format(chord_2)
    assert chord_1 is not chord_2
예제 #59
0
def test_Note___copy___03():
    """
    Copy note with LilyPond grob abjad.overrides and LilyPond context settings.
    """

    note_1 = abjad.Note(12, (1, 4))
    abjad.override(note_1).staff.note_head.color = "red"
    abjad.override(note_1).accidental.color = "red"
    abjad.setting(note_1).tuplet_full_length = True
    note_2 = copy.copy(note_1)

    assert isinstance(note_1, abjad.Note)
    assert isinstance(note_2, abjad.Note)
    assert format(note_1) == format(note_2)
    assert note_1 is not note_2