Exemplo n.º 1
0
 def _format_before_leaf(self, leaf):
     from abjad.tools import lilypondnametools
     result = []
     if self._is_my_first_leaf(leaf):
         result.append(r'\stopStaff')
         if isinstance(self.lines, int):
             override = lilypondnametools.LilyPondGrobOverride(
                 context_name='Staff',
                 grob_name='StaffSymbol',
                 is_once=True,
                 property_path='line-count',
                 value=self.lines,
             )
             string = '\n'.join(override._override_format_pieces)
             result.append(string)
         else:
             override = lilypondnametools.LilyPondGrobOverride(
                 context_name='Staff',
                 grob_name='StaffSymbol',
                 is_once=True,
                 property_path='line-positions',
                 value=schemetools.SchemeVector(self.lines),
             )
             string = '\n'.join(override._override_format_pieces)
             result.append(string)
         result.append(r'\startStaff')
     return result
Exemplo n.º 2
0
 def _make_bow_contact_point_overrides(
     self,
     bow_contact_point=None,
     lilypond_format_bundle=None,
 ):
     if bow_contact_point is None:
         return
     override_ = lilypondnametools.LilyPondGrobOverride(
         grob_name='NoteHead',
         is_once=True,
         property_path='stencil',
         value=schemetools.Scheme('ly:text-interface::print'),
     )
     string = override_.override_string
     lilypond_format_bundle.grob_overrides.append(string)
     override_ = lilypondnametools.LilyPondGrobOverride(
         grob_name='NoteHead',
         is_once=True,
         property_path='text',
         value=bow_contact_point.markup,
     )
     string = override_.override_string
     lilypond_format_bundle.grob_overrides.append(string)
     y_offset = float((4 * bow_contact_point.contact_point) - 2)
     override_ = lilypondnametools.LilyPondGrobOverride(
         grob_name='NoteHead',
         is_once=True,
         property_path='Y-offset',
         value=y_offset,
     )
     string = override_.override_string
     lilypond_format_bundle.grob_overrides.append(string)
Exemplo n.º 3
0
 def _get_lilypond_format_bundle(self, component=None):
     lilypond_format_bundle = self._get_basic_lilypond_format_bundle(
         component,
         )
     current_annotations = self._get_annotations(component)
     current_markups = current_annotations[0]
     current_markup = bool(current_markups)
     current_line_segment = current_annotations[1]
     start_spanner = self._spanner_starts_on_leaf(component)
     stop_spanner = self._spanner_stops_on_leaf(component)
     if start_spanner:
         contributions = override(self)._list_format_contributions(
             'override',
             is_once=False,
             )
         lilypond_format_bundle.grob_overrides.extend(contributions)
         string = r'\startTextSpan'
         lilypond_format_bundle.right.spanner_starts.append(string)
     if stop_spanner:
         contributions = override(self)._list_format_contributions(
             'revert',
             )
         lilypond_format_bundle.grob_reverts.extend(contributions)
         string = r'\stopTextSpan'
         lilypond_format_bundle.right.spanner_stops.append(string)
     if current_markups is not None:
         # assign markup to spanner left text
         if start_spanner:
             markup = current_markups[0]
             if current_line_segment:
                 if current_line_segment.left_hspace is not None:
                     hspace = current_line_segment.left_hspace
                     hspace = markuptools.Markup.hspace(hspace)
                     markup = markuptools.Markup.concat([markup, hspace])
             override_ = lilypondnametools.LilyPondGrobOverride(
                 grob_name='TextSpanner',
                 is_once=True,
                 property_path=(
                     'bound-details',
                     'left',
                     'text',
                     ),
                 value=markup,
                 )
             override_string = override_.override_string
             lilypond_format_bundle.grob_overrides.append(override_string)
         # format markup normally
         else:
             current_markup = current_markups[0]
             markup = new(current_markup, direction=Up)
             string = format(markup, 'lilypond')
             lilypond_format_bundle.right.markup.append(string)
     if current_line_segment is not None:
         overrides = current_line_segment._get_lilypond_grob_overrides()
         for override_ in overrides:
             override_string = override_.override_string
             lilypond_format_bundle.grob_overrides.append(override_string)
     return lilypond_format_bundle
Exemplo n.º 4
0
 def _get_lilypond_format_bundle(self, leaf):
     from abjad.tools import lilypondnametools
     from abjad.tools import markuptools
     from abjad.tools import scoretools
     lilypond_format_bundle = self._get_basic_lilypond_format_bundle(leaf)
     prototype = (
         scoretools.Rest,
         scoretools.MultimeasureRest,
         scoretools.Skip,
     )
     if isinstance(leaf, prototype):
         return lilypond_format_bundle
     logical_tie = inspect_(leaf).get_logical_tie()
     if leaf is logical_tie.head:
         previous_leaf = leaf._get_leaf(-1)
         if previous_leaf is not None and \
             not isinstance(previous_leaf, prototype) and \
             inspect_(previous_leaf).get_spanners(type(self)):
             grob_override = lilypondnametools.LilyPondGrobOverride(
                 grob_name='TrillSpanner',
                 is_once=True,
                 property_path=(
                     'bound-details',
                     'left',
                     'text',
                 ),
                 value=markuptools.Markup(r'\null'),
             )
             string = grob_override.override_string
             lilypond_format_bundle.grob_overrides.append(string)
         if self.interval is not None:
             string = r'\pitchedTrill'
             lilypond_format_bundle.opening.spanners.append(string)
             if hasattr(leaf, 'written_pitch'):
                 written_pitch = leaf.written_pitch
             elif hasattr(leaf, 'written_pitches'):
                 if 0 < self.interval.semitones:
                     written_pitch = max(leaf.written_pitches)
                 elif self.interval.semitones < 0:
                     written_pitch = min(leaf.written_pitches)
             trill_pitch = written_pitch.transpose(self.interval)
             string = r'\startTrillSpan {!s}'.format(trill_pitch)
         else:
             string = r'\startTrillSpan'
         lilypond_format_bundle.right.trill_pitches.append(string)
     if leaf is logical_tie.tail:
         next_leaf = leaf._get_leaf(1)
         if next_leaf is not None:
             string = r'<> \stopTrillSpan'
             lilypond_format_bundle.after.commands.append(string)
         else:
             string = r'\stopTrillSpan'
             lilypond_format_bundle.right.spanner_stops.append(string)
     return lilypond_format_bundle
Exemplo n.º 5
0
 def _make_pizzicato_overrides(
     self,
     lilypond_format_bundle=None,
 ):
     style = schemetools.SchemeSymbol('cross')
     override_ = lilypondnametools.LilyPondGrobOverride(
         grob_name='NoteHead',
         is_once=True,
         property_path='style',
         value=style,
     )
     string = override_.override_string
     lilypond_format_bundle.grob_overrides.append(string)
Exemplo n.º 6
0
 def _make_glissando_overrides(
     self,
     bow_motion_technique=None,
     lilypond_format_bundle=None,
 ):
     if bow_motion_technique is not None:
         style = schemetools.SchemeSymbol(
             bow_motion_technique.glissando_style, )
         override_ = lilypondnametools.LilyPondGrobOverride(
             grob_name='Glissando',
             is_once=True,
             property_path='style',
             value=style,
         )
         string = override_.override_string
         lilypond_format_bundle.grob_overrides.append(string)
Exemplo n.º 7
0
 def _make_glissando_overrides(
     self,
     bow_pressure=None,
     bow_motion_technique=None,
     lilypond_format_bundle=None,
     string_contact_point=None,
     ):
     if bow_motion_technique is not None:
         style = schemetools.Scheme(
             bow_motion_technique.glissando_style,
             quoting="'",
             )
         override_ = lilypondnametools.LilyPondGrobOverride(
             grob_name='Glissando',
             is_once=True,
             property_path='style',
             value=style,
             )
         string = '\n'.join(override_._override_format_pieces)
         lilypond_format_bundle.grob_overrides.append(string)
Exemplo n.º 8
0
 def _get_lilypond_grob_overrides(self):
     overrides = []
     if self.arrow_width is not None:
         override_ = lilypondnametools.LilyPondGrobOverride(
             grob_name='TextSpanner',
             is_once=True,
             property_path=('arrow-width', ),
             value=self.arrow_width,
         )
         overrides.append(override_)
     if self.dash_fraction is not None:
         override_ = lilypondnametools.LilyPondGrobOverride(
             grob_name='TextSpanner',
             is_once=True,
             property_path=('dash-fraction', ),
             value=self.dash_fraction,
         )
         overrides.append(override_)
     if self.dash_period is not None:
         override_ = lilypondnametools.LilyPondGrobOverride(
             grob_name='TextSpanner',
             is_once=True,
             property_path=('dash-period', ),
             value=self.dash_period,
         )
         overrides.append(override_)
     if self.left_broken_padding is not None:
         override_ = lilypondnametools.LilyPondGrobOverride(
             grob_name='TextSpanner',
             is_once=True,
             property_path=(
                 'bound-details',
                 'left-broken',
                 'padding',
             ),
             value=self.left_broken_padding,
         )
         overrides.append(override_)
     if self.left_broken_text is not None:
         override_ = lilypondnametools.LilyPondGrobOverride(
             grob_name='TextSpanner',
             is_once=True,
             property_path=(
                 'bound-details',
                 'left-broken',
                 'text',
             ),
             value=self.left_broken_text,
         )
         overrides.append(override_)
     if self.left_padding is not None:
         override_ = lilypondnametools.LilyPondGrobOverride(
             grob_name='TextSpanner',
             is_once=True,
             property_path=(
                 'bound-details',
                 'left',
                 'padding',
             ),
             value=self.left_padding,
         )
         overrides.append(override_)
     if self.left_stencil_align_direction_y is not None:
         override_ = lilypondnametools.LilyPondGrobOverride(
             grob_name='TextSpanner',
             is_once=True,
             property_path=(
                 'bound-details',
                 'left',
                 'stencil-align-dir-y',
             ),
             value=self.left_stencil_align_direction_y,
         )
         overrides.append(override_)
     if self.right_arrow is not None:
         override_ = lilypondnametools.LilyPondGrobOverride(
             grob_name='TextSpanner',
             is_once=True,
             property_path=(
                 'bound-details',
                 'right',
                 'arrow',
             ),
             value=self.right_arrow,
         )
         overrides.append(override_)
     if self.right_broken_arrow is not None:
         override_ = lilypondnametools.LilyPondGrobOverride(
             grob_name='TextSpanner',
             is_once=True,
             property_path=(
                 'bound-details',
                 'right-broken',
                 'arrow',
             ),
             value=self.right_broken_arrow,
         )
         overrides.append(override_)
     if self.right_broken_padding is not None:
         override_ = lilypondnametools.LilyPondGrobOverride(
             grob_name='TextSpanner',
             is_once=True,
             property_path=(
                 'bound-details',
                 'right-broken',
                 'padding',
             ),
             value=self.right_broken_padding,
         )
         overrides.append(override_)
     if self.right_padding is not None:
         override_ = lilypondnametools.LilyPondGrobOverride(
             grob_name='TextSpanner',
             is_once=True,
             property_path=(
                 'bound-details',
                 'right',
                 'padding',
             ),
             value=self.right_padding,
         )
         overrides.append(override_)
     if self.right_stencil_align_direction_y is not None:
         override_ = lilypondnametools.LilyPondGrobOverride(
             grob_name='TextSpanner',
             is_once=True,
             property_path=(
                 'bound-details',
                 'right',
                 'stencil-align-dir-y',
             ),
             value=self.right_stencil_align_direction_y,
         )
         overrides.append(override_)
     if self.style is not None:
         style = schemetools.Scheme(self.style, quoting="'")
         override_ = lilypondnametools.LilyPondGrobOverride(
             grob_name='TextSpanner',
             is_once=True,
             property_path=('style', ),
             value=style,
         )
         overrides.append(override_)
     return overrides
Exemplo n.º 9
0
from abjad.tools import markuptools
from abjad.tools import rhythmmakertools
from abjad.tools import scoretools
from abjad.tools import selectortools
from ersilia.materials import abbreviations


guitar_strummed_music_specifier = consort.MusicSpecifier(
    attachment_handler=consort.AttachmentHandler(
        damped=consort.AttachmentExpression(
            attachments=consort.LeafExpression(
                leaf=scoretools.Note("f'4"),
                attachments=[
                    lilypondnametools.LilyPondGrobOverride(
                        grob_name='NoteHead',
                        is_once=True,
                        property_path='transparent',
                        value=True,
                        ),
                    markuptools.Markup.musicglyph('scripts.coda'),
                    indicatortools.Articulation('accent'),
                    indicatortools.Dynamic('sfz'),
                    ],
                ),
            is_destructive=True,
            selector=selectortools.Selector()
                .by_logical_tie(pitched=True)
                .by_contiguity()
                .by_length('>', 1)
                .by_leaf()
                [-1]
            ),
Exemplo n.º 10
0
 def _get_lilypond_format_bundle(self, component):
     lilypond_format_bundle = self._get_basic_lilypond_format_bundle(
         component, )
     previous_annotations = self._get_previous_annotations(component)
     previous_markups = previous_annotations[0]
     previous_line_segment = previous_annotations[1]
     previous_segment = (previous_markups is not None
                         or previous_line_segment is not None)
     current_annotations = self._get_annotations(component)
     current_markups = current_annotations[0]
     current_markup = bool(current_markups)
     current_line_segment = current_annotations[1]
     current_event = (current_markups is not None
                      or current_line_segment is not None)
     start_spanner, stop_spanner = False, False
     # stop any previous segment
     if previous_segment and current_event:
         stop_spanner = True
     # start spanner if no markup
     if self._is_my_first_leaf(component) and not current_markup:
         start_spanner = True
     # start spanner if existing line segment
     elif current_line_segment:
         start_spanner = True
     # stop spanner if last component
     if self._is_my_last_leaf(component):
         stop_spanner = True
     if start_spanner:
         contributions = override(self)._list_format_contributions(
             'override',
             is_once=False,
         )
         lilypond_format_bundle.grob_overrides.extend(contributions)
         string = r'\startTextSpan'
         lilypond_format_bundle.right.spanner_starts.append(string)
     if stop_spanner:
         contributions = override(self)._list_format_contributions(
             'revert', )
         lilypond_format_bundle.grob_reverts.extend(contributions)
         string = r'\stopTextSpan'
         lilypond_format_bundle.right.spanner_stops.append(string)
     if current_markups is not None:
         # assign markup to spanner left text
         if start_spanner:
             markup = current_markups[0]
             if current_line_segment:
                 if current_line_segment.left_hspace is not None:
                     hspace = current_line_segment.left_hspace
                     hspace = markuptools.Markup.hspace(hspace)
                     markup = markuptools.Markup.concat([markup, hspace])
             override_ = lilypondnametools.LilyPondGrobOverride(
                 grob_name='TextSpanner',
                 is_once=True,
                 property_path=(
                     'bound-details',
                     'left',
                     'text',
                 ),
                 value=markup,
             )
             override_string = '\n'.join(override_._override_format_pieces)
             lilypond_format_bundle.grob_overrides.append(override_string)
         # format markup normally
         else:
             current_markup = current_markups[0]
             markup = new(current_markup, direction=Up)
             string = format(markup, 'lilypond')
             lilypond_format_bundle.right.markup.append(string)
     if current_line_segment is not None:
         overrides = current_line_segment._get_lilypond_grob_overrides()
         for override_ in overrides:
             override_string = '\n'.join(override_._override_format_pieces)
             lilypond_format_bundle.grob_overrides.append(override_string)
     return lilypond_format_bundle