コード例 #1
0
ファイル: MetricModulation.py プロジェクト: gsy/gmajor
 def _get_markup(self):
     left_markup = self._get_left_markup()
     equal = Markup('=')
     right_space = Markup.hspace(-0.5)
     right_markup = self._get_right_markup()
     markup = left_markup + equal + right_space + right_markup
     return markup
コード例 #2
0
ファイル: MetricModulation.py プロジェクト: tuchang/abjad
 def _get_markup(self):
     result = self._get_compact_output()
     if result is None:
         left_markup = self._get_left_markup()
         equal = Markup("=")
         right_space = Markup.hspace(-0.5)
         right_markup = self._get_right_markup()
         markup = left_markup + equal + right_space + right_markup
     else:
         markup = Markup(rf"\markup {result}", literal=True)
     return markup
コード例 #3
0
    def markup(self) -> typing.Optional[Markup]:
        r"""
        Gets markup of color fingering.

        ..  container:: example

            First color fingering:

            >>> fingering = abjad.ColorFingering(1)
            >>> print(format(fingering.markup, 'lilypond'))
            \markup {
                \override
                    #'(circle-padding . 0.25)
                    \circle
                        \finger
                            1
                }
            >>> abjad.show(fingering.markup) # doctest: +SKIP

        ..  container:: example

            Second color fingering:

            >>> fingering = abjad.ColorFingering(2)
            >>> print(format(fingering.markup, 'lilypond'))
            \markup {
                \override
                    #'(circle-padding . 0.25)
                    \circle
                        \finger
                            2
                }
            >>> abjad.show(fingering.markup) # doctest: +SKIP

        """
        if self.number is None:
            return None
        markup = Markup(str(self.number))
        markup = markup.finger()
        markup = markup.circle()
        markup = markup.override(("circle-padding", 0.25))
        return markup
コード例 #4
0
ファイル: ColorFingering.py プロジェクト: Abjad/abjad
    def markup(self) -> typing.Optional[Markup]:
        r"""
        Gets markup of color fingering.

        ..  container:: example

            First color fingering:

            >>> fingering = abjad.ColorFingering(1)
            >>> print(format(fingering.markup, 'lilypond'))
            \markup {
                \override
                    #'(circle-padding . 0.25)
                    \circle
                        \finger
                            1
                }
            >>> abjad.show(fingering.markup) # doctest: +SKIP

        ..  container:: example

            Second color fingering:

            >>> fingering = abjad.ColorFingering(2)
            >>> print(format(fingering.markup, 'lilypond'))
            \markup {
                \override
                    #'(circle-padding . 0.25)
                    \circle
                        \finger
                            2
                }
            >>> abjad.show(fingering.markup) # doctest: +SKIP

        """
        if self.number is None:
            return None
        markup = Markup(str(self.number))
        markup = markup.finger()
        markup = markup.circle()
        markup = markup.override(("circle-padding", 0.25))
        return markup
コード例 #5
0
ファイル: MetricModulation.py プロジェクト: Abjad/abjad
 def _get_markup(self):
     result = self._get_compact_output()
     if result is None:
         left_markup = self._get_left_markup()
         equal = Markup("=")
         right_space = Markup.hspace(-0.5)
         right_markup = self._get_right_markup()
         markup = left_markup + equal + right_space + right_markup
     else:
         markup = Markup(rf"\markup {result}", literal=True)
     return markup
コード例 #6
0
ファイル: KeyCluster.py プロジェクト: cablew/abjad
 def _get_lilypond_format_bundle(self, component=None):
     bundle = LilyPondFormatBundle()
     bundle.grob_overrides.append(
         "\\once \\override Accidental.stencil = ##f\n"
         "\\once \\override AccidentalCautionary.stencil = ##f\n"
         "\\once \\override Arpeggio.X-offset = #-2\n"
         "\\once \\override NoteHead.stencil = #ly:text-interface::print\n"
         r"\once \override NoteHead.text = \markup {" + "\n"
         "\t\\filled-box #'(-0.6 . 0.6) #'(-0.7 . 0.7) #0.25\n"
         "}")
     if not self.hide:
         if self.include_black_keys and self.include_white_keys:
             string = r"\center-align \concat { \natural \flat }"
         elif self.include_black_keys:
             string = r"\center-align \flat"
         else:
             string = r"\center-align \natural"
         markup = Markup(string, direction=self.markup_direction)
         markup_format_pieces = markup._get_format_pieces()
         bundle.after.markup.extend(markup_format_pieces)
     return bundle
コード例 #7
0
 def _get_markup(self):
     if self.custom_markup is not None:
         return self.custom_markup
     duration_log = int(math.log(self.reference_duration.denominator, 2))
     stem_height = 1
     markup = Markup.abjad_metronome_mark(
         duration_log,
         self.reference_duration.dot_count,
         stem_height,
         self.units_per_minute,
     )
     return markup
コード例 #8
0
ファイル: StringContactPoint.py プロジェクト: tuchang/abjad
    def markup(self) -> Markup:
        r"""
        Gets markup of string contact point.

        ..  container:: example

            Sul ponticello:

            >>> indicator = abjad.StringContactPoint('sul ponticello')
            >>> abjad.show(indicator.markup) # doctest: +SKIP

            ..  docs::

                >>> abjad.f(indicator.markup)
                \markup {
                    \caps
                        S.P.
                    }

        ..  container:: example

            Sul tasto:

            >>> indicator = abjad.StringContactPoint('sul tasto')
            >>> abjad.show(indicator.markup) # doctest: +SKIP

            ..  docs::

                >>> abjad.f(indicator.markup)
                \markup {
                    \caps
                        S.T.
                    }

        """
        string = self._contact_point_abbreviations[self.contact_point]
        string = string.title()
        markup = Markup(string)
        markup = markup.caps()
        return markup
コード例 #9
0
ファイル: KeyCluster.py プロジェクト: Abjad/abjad
 def _get_lilypond_format_bundle(self, component=None):
     bundle = LilyPondFormatBundle()
     bundle.grob_overrides.append(
         "\\once \\override Accidental.stencil = ##f\n"
         "\\once \\override AccidentalCautionary.stencil = ##f\n"
         "\\once \\override Arpeggio.X-offset = #-2\n"
         "\\once \\override NoteHead.stencil = #ly:text-interface::print\n"
         r"\once \override NoteHead.text = \markup {" + "\n"
         "\t\\filled-box #'(-0.6 . 0.6) #'(-0.7 . 0.7) #0.25\n"
         "}"
     )
     if not self.hide:
         if self.include_black_keys and self.include_white_keys:
             string = r"\center-align \concat { \natural \flat }"
         elif self.include_black_keys:
             string = r"\center-align \flat"
         else:
             string = r"\center-align \natural"
         markup = Markup(string, direction=self.markup_direction)
         markup_format_pieces = markup._get_format_pieces()
         bundle.after.markup.extend(markup_format_pieces)
     return bundle
コード例 #10
0
ファイル: StartMarkup.py プロジェクト: gsy/gmajor
 def __init__(
     self,
     markup: typing.Union[str, Markup] = 'instrument name',
     *,
     context: str = 'Staff',
     format_slot: str = 'before',
 ) -> None:
     assert isinstance(context, str), repr(context)
     self._context = context
     assert isinstance(format_slot, str), repr(format_slot)
     self._format_slot = format_slot
     if isinstance(markup, str):
         markup = Markup(markup)
     assert isinstance(markup, Markup), repr(markup)
     self._markup = markup
コード例 #11
0
ファイル: BowContactPoint.py プロジェクト: aarongrisez/abjad
    def markup(self) -> Markup:
        r"""
        Gets markup of bow contact point.

        ..  container:: example

            One quarter of the way from frog to point:

            >>> indicator = abjad.BowContactPoint((1, 4))
            >>> print(format(indicator.markup, 'lilypond'))
            \markup {
                \center-align
                    \vcenter
                        \fraction
                            1
                            4
                }
            >>> abjad.show(indicator.markup) # doctest: +SKIP

        ..  container:: example

            Three fifths of the way from frog to point:

            >>> indicator = abjad.BowContactPoint((3, 5))
            >>> print(format(indicator.markup, 'lilypond'))
            \markup {
                \center-align
                    \vcenter
                        \fraction
                            3
                            5
                }
            >>> abjad.show(indicator.markup) # doctest: +SKIP

        """
        if self.contact_point is None:
            contact_point = Multiplier(0, 1)
        else:
            contact_point = self.contact_point
        markup = Markup.fraction(
            contact_point.numerator,
            contact_point.denominator,
        )
        markup = markup.vcenter()
        markup = markup.center_align()
        return markup
コード例 #12
0
ファイル: BowContactPoint.py プロジェクト: Abjad/abjad
    def markup(self) -> Markup:
        r"""
        Gets markup of bow contact point.

        ..  container:: example

            One quarter of the way from frog to point:

            >>> indicator = abjad.BowContactPoint((1, 4))
            >>> print(format(indicator.markup, 'lilypond'))
            \markup {
                \center-align
                    \vcenter
                        \fraction
                            1
                            4
                }
            >>> abjad.show(indicator.markup) # doctest: +SKIP

        ..  container:: example

            Three fifths of the way from frog to point:

            >>> indicator = abjad.BowContactPoint((3, 5))
            >>> print(format(indicator.markup, 'lilypond'))
            \markup {
                \center-align
                    \vcenter
                        \fraction
                            3
                            5
                }
            >>> abjad.show(indicator.markup) # doctest: +SKIP

        """
        if self.contact_point is None:
            contact_point = Multiplier(0, 1)
        else:
            contact_point = self.contact_point
        markup = Markup.fraction(
            contact_point.numerator, contact_point.denominator
        )
        markup = markup.vcenter()
        markup = markup.center_align()
        return markup
コード例 #13
0
    def make_tempo_equation_markup(
        reference_duration, units_per_minute, *, decimal=None
    ) -> Markup:
        r"""
        Makes tempo equation markup.

        ..  container:: example

            Integer-valued metronome mark:

            >>> markup = abjad.MetronomeMark.make_tempo_equation_markup(
            ...     (1, 4),
            ...     90,
            ...  )
            >>> abjad.show(markup) # doctest: +SKIP

            ..  docs::

                >>> print(format(markup))
                \markup \abjad-metronome-mark-markup #2 #0 #1 #"90"

        ..  container:: example

            Float-valued metronome mark:

            >>> markup = abjad.MetronomeMark.make_tempo_equation_markup(
            ...     (1, 4),
            ...     90.1,
            ... )
            >>> abjad.show(markup) # doctest: +SKIP

            ..  docs::

                >>> print(format(markup))
                \markup \abjad-metronome-mark-markup #2 #0 #1 #"90.1"

        ..  container:: example

            Rational-valued metronome mark:

            >>> markup = abjad.MetronomeMark.make_tempo_equation_markup(
            ...     abjad.Duration(1, 4),
            ...     abjad.Fraction(272, 3),
            ... )
            >>> abjad.show(markup) # doctest: +SKIP

            ..  docs::

                >>> print(format(markup))
                \markup \abjad-metronome-mark-mixed-number-markup #2 #0 #1 #"90" #"2" #"3"

        """
        reference_duration_ = Duration(reference_duration)
        log = reference_duration_.exponent
        dots = reference_duration_.dot_count
        stem = 1
        if isinstance(
            units_per_minute, Fraction
        ) and not mathtools.is_integer_equivalent_number(units_per_minute):
            if decimal:
                decimal_: typing.Union[float, str]
                if decimal is True:
                    decimal_ = float(units_per_minute)
                else:
                    assert isinstance(decimal, str), repr(decimal)
                    decimal_ = decimal
                markup = Markup(
                    r"\markup \abjad-metronome-mark-markup"
                    f' #{log} #{dots} #{stem} #"{decimal_}"',
                    literal=True,
                )
            else:
                nonreduced = NonreducedFraction(units_per_minute)
                base = int(nonreduced)
                remainder = nonreduced - base
                n, d = remainder.pair
                markup = Markup(
                    r"\markup \abjad-metronome-mark-mixed-number-markup"
                    f" #{log} #{dots} #{stem}"
                    f' #"{base}" #"{n}" #"{d}"',
                    literal=True,
                )
        else:
            markup = Markup(
                r"\markup \abjad-metronome-mark-markup"
                f' #{log} #{dots} #{stem} #"{units_per_minute}"',
                literal=True,
            )
        return markup