def __init__( self, *, direction: enums.VerticalAlignment = None, tweaks: LilyPondTweakManager = None, ) -> None: direction_ = String.to_tridirectional_lilypond_symbol(direction) self._direction = direction_ if tweaks is not None: assert isinstance(tweaks, LilyPondTweakManager), repr(tweaks) self._tweaks = LilyPondTweakManager.set_tweaks(self, tweaks)
def __init__( self, *, direction: enums.VerticalAlignment = None, tweaks: LilyPondTweakManager = None, ) -> None: direction_ = String.to_tridirectional_lilypond_symbol(direction) self._direction = direction_ if tweaks is not None: assert isinstance(tweaks, LilyPondTweakManager), repr(tweaks) self._tweaks = LilyPondTweakManager.set_tweaks(self, tweaks)
def _get_lilypond_format(self): if self.command: string = self.command elif self.effort: string = self._format_effort_dynamic() elif self.name_is_textual: string = self._format_textual(self.direction, self.name) else: string = rf"\{self.name}" if self.direction is not None: direction_ = self.direction direction = String.to_tridirectional_lilypond_symbol(direction_) string = f"{direction} {string}" return string
def __str__(self) -> str: r""" Gets string representation of staccato. .. container:: example >>> str(abjad.Staccato()) '\\staccato' """ string = r"\staccato" if self.direction is None: return string direction = String.to_tridirectional_lilypond_symbol(self.direction) assert isinstance(direction, String), repr(direction) return fr"{direction} {string}"
def __init__( self, *, command: str = r'\startTextSpan', concat_hspace_left: typings.Number = 0.5, concat_hspace_right: typings.Number = None, direction: enums.VerticalAlignment = None, left_broken_text: typing.Union[bool, LilyPondLiteral, markups.Markup] = None, left_text: typing.Union[LilyPondLiteral, markups.Markup] = None, right_padding: typings.Number = None, right_text: typing.Union[LilyPondLiteral, markups.Markup] = None, style: str = None, tweaks: typing.Union[typing.List[typing.Tuple], LilyPondTweakManager] = None, ) -> None: assert isinstance(command, str), repr(command) assert command.startswith('\\'), repr(command) self._command = command if concat_hspace_left is not None: assert isinstance(concat_hspace_left, (int, float)) self._concat_hspace_left = concat_hspace_left if concat_hspace_right is not None: assert isinstance(concat_hspace_right, (int, float)) self._concat_hspace_right = concat_hspace_right direction_ = String.to_tridirectional_lilypond_symbol(direction) self._direction = direction_ if left_broken_text is not None: assert isinstance(left_broken_text, (bool, markups.Markup)) self._left_broken_text = left_broken_text if left_text is not None: prototype = (LilyPondLiteral, markups.Markup) assert isinstance(left_text, prototype), repr(left_text) self._left_text = left_text if right_padding is not None: assert isinstance(right_padding, (int, float)), repr(right_padding) self._right_padding = right_padding if right_text is not None: prototype = (LilyPondLiteral, markups.Markup) assert isinstance(right_text, prototype), repr(right_text) self._right_text = right_text if style is not None: assert style in self._styles, repr(style) self._style = style self._tweaks = None LilyPondTweakManager.set_tweaks(self, tweaks)
def __init__( self, *, command: str = r"\startTextSpan", concat_hspace_left: typings.Number = 0.5, concat_hspace_right: typings.Number = None, direction: enums.VerticalAlignment = None, left_broken_text: typing.Union[bool, str, markups.Markup] = None, left_text: typing.Union[str, markups.Markup] = None, right_padding: typings.Number = None, right_text: typing.Union[str, markups.Markup] = None, style: str = None, tweaks: LilyPondTweakManager = None, ) -> None: assert isinstance(command, str), repr(command) assert command.startswith("\\"), repr(command) self._command = command if concat_hspace_left is not None: assert isinstance(concat_hspace_left, (int, float)) self._concat_hspace_left = concat_hspace_left if concat_hspace_right is not None: assert isinstance(concat_hspace_right, (int, float)) self._concat_hspace_right = concat_hspace_right direction_ = String.to_tridirectional_lilypond_symbol(direction) self._direction = direction_ if left_broken_text is not None: assert isinstance(left_broken_text, (bool, markups.Markup)) self._left_broken_text = left_broken_text if left_text is not None: prototype = (str, markups.Markup) assert isinstance(left_text, prototype), repr(left_text) self._left_text = left_text if right_padding is not None: assert isinstance(right_padding, (int, float)), repr(right_padding) self._right_padding = right_padding if right_text is not None: prototype = (str, markups.Markup) assert isinstance(right_text, prototype), repr(right_text) self._right_text = right_text if style is not None: assert style in self._styles, repr(style) self._style = style if tweaks is not None: assert isinstance(tweaks, LilyPondTweakManager), repr(tweaks) self._tweaks = LilyPondTweakManager.set_tweaks(self, tweaks)
def __str__(self) -> str: """ Gets string representation of articulation. """ if self.name: string = self._shortcut_to_word.get(self.name) if not string: string = self.name if self.direction is None: direction = String("-") else: direction_ = String.to_tridirectional_lilypond_symbol( self.direction) assert isinstance(direction_, String), repr(direction) direction = direction_ return fr"{direction} \{string}" else: return ""
def __init__( self, shape='<', *, direction: enums.VerticalAlignment = None, left_broken: bool = None, tweaks: LilyPondTweakManager = None, ) -> None: direction_ = String.to_tridirectional_lilypond_symbol(direction) self._direction = direction_ if left_broken is not None: left_broken = bool(left_broken) self._left_broken = left_broken assert shape in self._known_shapes, repr(shape) self._shape = shape if tweaks is not None: assert isinstance(tweaks, LilyPondTweakManager), repr(tweaks) self._tweaks = LilyPondTweakManager.set_tweaks(self, tweaks)
def __init__( self, shape="<", *, direction: enums.VerticalAlignment = None, left_broken: bool = None, tweaks: LilyPondTweakManager = None, ) -> None: direction_ = String.to_tridirectional_lilypond_symbol(direction) self._direction = direction_ if left_broken is not None: left_broken = bool(left_broken) self._left_broken = left_broken assert shape in self._known_shapes, repr(shape) self._shape = shape if tweaks is not None: assert isinstance(tweaks, LilyPondTweakManager), repr(tweaks) self._tweaks = LilyPondTweakManager.set_tweaks(self, tweaks)
def __str__(self) -> str: """ Gets string representation of articulation. """ if self.name: string = self._shortcut_to_word.get(self.name) if not string: string = self.name if self.direction is None: direction = String("-") else: direction_ = String.to_tridirectional_lilypond_symbol( self.direction ) assert isinstance(direction_, String), repr(direction) direction = direction_ return fr"{direction} \{string}" else: return ""
def _format_effort_dynamic(self): name = self.name.strip('"') before = {"f": -0.4, "m": -0.1, "p": -0.1, "r": -0.1, "s": -0.3, "z": -0.2}[ name[0] ] after = {"f": -0.2, "m": -0.1, "p": -0.25, "r": 0, "s": 0, "z": -0.2}[name[-1]] direction = self.direction direction = String.to_tridirectional_lilypond_symbol(direction) strings = [] strings.append(f"{direction} #(make-dynamic-script") strings.append(" (markup") strings.append(" #:whiteout") strings.append(" #:line (") strings.append(' #:general-align Y -2 #:normal-text #:larger "“"') strings.append(f" #:hspace {before}") strings.append(f' #:dynamic "{name}"') strings.append(f" #:hspace {after}") strings.append(' #:general-align Y -2 #:normal-text #:larger "”"') strings.append(" )") strings.append(" )") strings.append(" )") string = "\n".join(strings) return string
def __init__( self, *, direction: typing.Union[str, enums.VerticalAlignment] = None, left_broken: bool = None, repeat: typing.Union[bool, typings.IntegerPair, DurationInequality, ] = None, right_broken: bool = None, ) -> None: Spanner.__init__(self) direction = String.to_tridirectional_lilypond_symbol(direction) self._direction = direction if left_broken is not None: left_broken = bool(left_broken) self._left_broken = left_broken repeat_ = repeat repeat_ = self._coerce_inequality(repeat) if repeat_ is not None: assert isinstance(repeat_, (bool, DurationInequality)) self._repeat = repeat_ if right_broken is not None: right_broken = bool(right_broken) self._right_broken = right_broken
def _format_effort_dynamic(self): name = self.name.strip('"') before = { 'f': -0.4, 'm': -0.1, 'p': -0.1, 'r': -0.1, 's': -0.3, 'z': -0.2, }[name[0]] after = { 'f': -0.2, 'm': -0.1, 'p': -0.25, 'r': 0, 's': 0, 'z': -0.2, }[name[-1]] direction = self.direction direction = String.to_tridirectional_lilypond_symbol(direction) strings = [] strings.append(f'{direction} #(make-dynamic-script') strings.append(' (markup') strings.append(' #:whiteout') strings.append(' #:line (') strings.append( ' #:general-align Y -2 #:normal-text #:larger "“"') strings.append(f' #:hspace {before}') strings.append(f' #:dynamic "{name}"') strings.append(f' #:hspace {after}') strings.append( ' #:general-align Y -2 #:normal-text #:larger "”"') strings.append(' )') strings.append(' )') strings.append(' )') string = '\n'.join(strings) return string