Dynamic

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph "cluster_abjad.indicators" { graph [label="abjad.indicators"]; node [color=1]; "abjad.indicators.Dynamic.Dynamic" [URL="../api/abjad/indicators/Dynamic.html#abjad.indicators.Dynamic.Dynamic", color=black, fontcolor=white, label=Dynamic, target=_top]; } subgraph "cluster_abjad.system" { graph [label="abjad.system"]; node [color=2]; "abjad.system.AbjadObject.AbjadObject" [URL="../api/abjad/indicators/../system/AbjadObject.html#abjad.system.AbjadObject.AbjadObject", label="Abjad\nObject", target=_top]; "abjad.system.AbjadValueObject.AbjadValueObject" [URL="../api/abjad/indicators/../system/AbjadValueObject.html#abjad.system.AbjadValueObject.AbjadValueObject", label="Abjad\nValue\nObject", target=_top]; "abjad.system.AbjadObject.AbjadObject" -> "abjad.system.AbjadValueObject.AbjadValueObject"; } subgraph cluster_builtins { graph [label=builtins]; node [color=3]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } "abjad.system.AbjadValueObject.AbjadValueObject" -> "abjad.indicators.Dynamic.Dynamic"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; }

class abjad.indicators.Dynamic.Dynamic(name='f', *, command=None, direction=None, format_hairpin_stop=None, hide=None, leak=None, name_is_textual=None, ordinal=None, sforzando=None, tweaks=None)

Dynamic.

Initializes from dynamic name:

>>> voice = abjad.Voice("c'8 d'8 e'8 f'8")
>>> dynamic = abjad.Dynamic('f')
>>> abjad.attach(dynamic, voice[0])
>>> abjad.show(voice) 

Initializes from other dynamic:

>>> dynamic_1 = abjad.Dynamic('f')
>>> dynamic_2 = abjad.Dynamic(dynamic_1)
>>> dynamic_1
Dynamic('f')
>>> dynamic_2
Dynamic('f')

Initializes niente:

>>> dynamic = abjad.Dynamic('niente')
>>> format(dynamic, 'lilypond')
''

Simultaneous dynamics in a single staff:

>>> voice_1 = abjad.Voice("e'8 g'8 f'8 a'8")
>>> abjad.attach(abjad.Dynamic('f'), voice_1[0], context='Voice')
>>> abjad.attach(abjad.LilyPondLiteral(r'\voiceOne'), voice_1)
>>> abjad.override(voice_1).dynamic_line_spanner.direction = abjad.Up
>>> voice_2 = abjad.Voice("c'2")
>>> abjad.attach(abjad.LilyPondLiteral(r'\voiceTwo'), voice_2)
>>> abjad.attach(abjad.Dynamic('mf'), voice_2[0], context='Voice')
>>> staff = abjad.Staff([voice_1, voice_2], is_simultaneous=True)
>>> abjad.show(staff) 
>>> for leaf in abjad.select(staff).leaves():
...     leaf, abjad.inspect(leaf).effective(abjad.Dynamic)
... 
(Note("e'8"), Dynamic('f'))
(Note("g'8"), Dynamic('f'))
(Note("f'8"), Dynamic('f'))
(Note("a'8"), Dynamic('f'))
(Note("c'2"), Dynamic('mf'))

Attributes Summary

__eq__ Is true when argument equals dynamic.
__format__ Formats dynamic.
__hash__ Hashes dynamic.
command Gets explicit command.
composite_dynamic_name_to_steady_state_dynamic_name Changes composite name to steady state dynamic name.
context Returns (historically conventional) context 'Voice'.
direction Gets direction for effort dynamics only.
dynamic_name_to_dynamic_ordinal Changes name to dynamic ordinal.
dynamic_ordinal_to_dynamic_name Changes dynamic_ordinal to dynamic name.
effort Is true when double quotes enclose dynamic.
format_hairpin_stop Is true when dynamic formats LilyPond \! hairpin stop.
hide Is true when dynamic should not appear in output (but should still determine effective dynamic).
is_dynamic_name Is true when argument is dynamic name.
leak Is true when dynamic formats LilyPond empty chord <> symbol.
name Gets name.
name_is_textual Is true when name is textual.
ordinal Gets ordinal.
parameter Is true.
sforzando Is true when dynamic name begins in s- and ends in -z.
tweaks Gets tweaks

Special methods

(AbjadValueObject).__copy__(*arguments)

Copies Abjad value object.

Returns new Abjad value object.

__eq__(argument)

Is true when argument equals dynamic.

>>> dynamic_1 = abjad.Dynamic('p')
>>> dynamic_2 = abjad.Dynamic('p')
>>> dynamic_3 = abjad.Dynamic('f')
>>> dynamic_1 == dynamic_1
True
>>> dynamic_1 == dynamic_2
True
>>> dynamic_1 == dynamic_3
False
>>> dynamic_2 == dynamic_1
True
>>> dynamic_2 == dynamic_2
True
>>> dynamic_2 == dynamic_3
False
>>> dynamic_3 == dynamic_1
False
>>> dynamic_3 == dynamic_2
False
>>> dynamic_3 == dynamic_3
True
Return type:bool
__format__(format_specification='')

Formats dynamic.

Gets storage format:

>>> dynamic = abjad.Dynamic('f')
>>> print(format(dynamic))
abjad.Dynamic('f')

Gets LilyPond format:

>>> dynamic = abjad.Dynamic('f')
>>> print(format(dynamic, 'lilypond'))
\f
Return type:str
__hash__()

Hashes dynamic.

Redefined in tandem with __eq__.

Return type:int
(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.


Class & static methods

static composite_dynamic_name_to_steady_state_dynamic_name(name)

Changes composite name to steady state dynamic name.

>>> abjad.Dynamic.composite_dynamic_name_to_steady_state_dynamic_name('sfp')
'p'
>>> abjad.Dynamic.composite_dynamic_name_to_steady_state_dynamic_name('rfz')
'f'
Return type:str
static dynamic_name_to_dynamic_ordinal(name)

Changes name to dynamic ordinal.

>>> abjad.Dynamic.dynamic_name_to_dynamic_ordinal('fff')
4
>>> abjad.Dynamic.dynamic_name_to_dynamic_ordinal('niente')
NegativeInfinity
static dynamic_ordinal_to_dynamic_name(dynamic_ordinal)

Changes dynamic_ordinal to dynamic name.

>>> abjad.Dynamic.dynamic_ordinal_to_dynamic_name(-5)
'pppp'
>>> negative_infinity = abjad.mathtools.NegativeInfinity()
>>> abjad.Dynamic.dynamic_ordinal_to_dynamic_name(negative_infinity)
'niente'
Return type:str
static is_dynamic_name(argument)

Is true when argument is dynamic name.

>>> abjad.Dynamic.is_dynamic_name('f')
True
>>> abjad.Dynamic.is_dynamic_name('sfz')
True
>>> abjad.Dynamic.is_dynamic_name('niente')
True
Return type:bool

Read-only properties

command

Gets explicit command.

>>> abjad.Dynamic('f', command=r'\sub_f').command
'\\sub_f'

Use to override LilyPond output when a custom dynamic has been defined in an external stylesheet. (In the example above, \sub_f is a nonstandard LilyPond dynamic. LilyPond will interpret the output above only when the command \sub_f is defined somewhere in an external stylesheet.)

Return type:Optional[str]
context

Returns (historically conventional) context 'Voice'.

>>> abjad.Dynamic('f').context
'Voice'

Class constant.

Override with abjad.attach(..., context='...').

Return type:str
direction

Gets direction for effort dynamics only.

Effort dynamics default to down:

>>> abjad.Dynamic('"f"').direction
Down

And may be overriden:

>>> abjad.Dynamic('"f"', direction=abjad.Up).direction
Up
Return type:Optional[VerticalAlignment]
effort

Is true when double quotes enclose dynamic.

>>> voice = abjad.Voice("c'4 r d' r e' r f' r")
>>> abjad.attach(abjad.Dynamic('"pp"'), voice[0])
>>> abjad.attach(abjad.Dynamic('"mp"'), voice[2])
>>> abjad.attach(abjad.Dynamic('"mf"'), voice[4])
>>> abjad.attach(abjad.Dynamic('"ff"'), voice[6])
>>> abjad.override(voice).dynamic_line_spanner.staff_padding = 4
>>> abjad.show(voice) 
>>> voice = abjad.Voice("c'4 r d' r e' r f' r")
>>> abjad.attach(abjad.Dynamic('"sf"'), voice[0])
>>> abjad.attach(abjad.Dynamic('"sfz"'), voice[2])
>>> abjad.attach(abjad.Dynamic('"rf"'), voice[4])
>>> abjad.attach(abjad.Dynamic('"rfz"'), voice[6])
>>> abjad.override(voice).dynamic_line_spanner.staff_padding = 4
>>> abjad.show(voice) 
Return type:Optional[bool]
format_hairpin_stop

Is true when dynamic formats LilyPond \! hairpin stop.

Return type:Optional[bool]
hide

Is true when dynamic should not appear in output (but should still determine effective dynamic).

>>> voice = abjad.Voice("c'4 d' e' f'")
>>> abjad.attach(abjad.Dynamic('f'), voice[0])
>>> abjad.attach(abjad.Dynamic('mf', hide=True), voice[2])
>>> abjad.show(voice) 
>>> abjad.f(voice)
\new Voice
{
    c'4
    \f
    d'4
    e'4
    f'4
}
>>> for leaf in abjad.iterate(voice).leaves():
...     leaf, abjad.inspect(leaf).effective(abjad.Dynamic)
... 
(Note("c'4"), Dynamic('f'))
(Note("d'4"), Dynamic('f'))
(Note("e'4"), Dynamic('mf', hide=True))
(Note("f'4"), Dynamic('mf', hide=True))
Return type:Optional[bool]
leak

Is true when dynamic formats LilyPond empty chord <> symbol.

Without leaked stop dynamic:

>>> staff = abjad.Staff("c'4 d' e' r")
>>> start = abjad.Dynamic('mf')
>>> trend = abjad.DynamicTrend('>')
>>> stop = abjad.Dynamic('pp')
>>> abjad.attach(start, staff[0])
>>> abjad.attach(trend, staff[0])
>>> abjad.attach(stop, staff[-2])
>>> abjad.override(staff).dynamic_line_spanner.staff_padding = 4
>>> abjad.show(staff) 

With leaked stop dynamic:

>>> staff = abjad.Staff("c'4 d' e' r")
>>> start = abjad.Dynamic('mf')
>>> trend = abjad.DynamicTrend('>')
>>> stop = abjad.Dynamic('pp', leak=True)
>>> abjad.attach(start, staff[0])
>>> abjad.attach(trend, staff[0])
>>> abjad.attach(stop, staff[-2])
>>> abjad.override(staff).dynamic_line_spanner.staff_padding = 4
>>> abjad.show(staff) 

Leaks format after spanners:

>>> staff = abjad.Staff("c'8 [ d' e' ] f'")
>>> start = abjad.Dynamic('mf')
>>> trend = abjad.DynamicTrend('>')
>>> stop = abjad.Dynamic('pp', leak=True)
>>> abjad.attach(start, staff[0])
>>> abjad.attach(trend, staff[0])
>>> abjad.attach(stop, staff[-2])
>>> abjad.override(staff).dynamic_line_spanner.staff_padding = 4
>>> abjad.show(staff) 

Leak survives copy:

>>> import copy
>>> dynamic = abjad.Dynamic('pp', leak=True)
>>> copy.copy(dynamic)
Dynamic('pp', leak=True, ordinal=-3, sforzando=False)
Return type:Optional[bool]
name

Gets name.

>>> abjad.Dynamic('f').name
'f'
>>> abjad.Dynamic('p').name
'p'
>>> abjad.Dynamic('sffz').name
'sffz'
>>> abjad.Dynamic('sffp').name
'sffp'
>>> abjad.Dynamic('"f"').name
'"f"'

Niente dynamics format like this:

>>> voice = abjad.Voice("c'4 r r c'4")
>>> abjad.attach(abjad.Dynamic('p'), voice[0])
>>> abjad.attach(abjad.Dynamic('niente'), voice[1])
>>> abjad.attach(abjad.Dynamic('p'), voice[3])
>>> abjad.override(voice).dynamic_line_spanner.staff_padding = 4
>>> abjad.show(voice) 
Return type:str
name_is_textual

Is true when name is textual.

>>> abjad.Dynamic('f').name_is_textual is None
True
>>> abjad.Dynamic('niente').name_is_textual
True
>>> dynamic = abjad.Dynamic('appena udibile', name_is_textual=True)
>>> dynamic.name_is_textual
True

Textual dynamics format like this when initialized without an explicit command:

>>> voice = abjad.Voice("c'4 d' e' f'")
>>> dynamic = abjad.Dynamic('appena udibile', name_is_textual=True)
>>> abjad.attach(dynamic, voice[0])
>>> abjad.override(voice).dynamic_line_spanner.staff_padding = 4
>>> abjad.override(voice).dynamic_text.X_extent = (0, 0)
>>> abjad.override(voice).dynamic_text.self_alignment_X = abjad.Left
>>> abjad.show(voice) 

Textual dynamics format like this when initialized with an explicit command:

>>> voice = abjad.Voice("c'4 d' e' f'")
>>> dynamic = abjad.Dynamic(
...     'appena udibile',
...     command=r'\appena_udibile',
...     name_is_textual=True,
...     )
>>> abjad.attach(dynamic, voice[0])

Only LilyPond output is shown here because dynamic commands (like \appena_udibile shown here) are meant to be user-defined (and not included in Abjad):

>>> abjad.f(voice)
\new Voice
{
    c'4
    \appena_udibile
    d'4
    e'4
    f'4
}

REGRESSION. Textual names work with new:

>>> dynamic = abjad.Dynamic('niente')
>>> abjad.new(dynamic)
Dynamic('niente', direction=Down, ordinal=NegativeInfinity, name_is_textual=True, sforzando=False)
>>> dynamic = abjad.Dynamic('appena udibile', name_is_textual=True)
>>> abjad.new(dynamic)
Dynamic('appena udibile', name_is_textual=True, sforzando=False)
Return type:Optional[bool]
ordinal

Gets ordinal.

>>> abjad.Dynamic('f').ordinal
2
>>> abjad.Dynamic('p').ordinal
-2
>>> abjad.Dynamic('niente').ordinal
NegativeInfinity
>>> abjad.Dynamic('"f"').ordinal
2
>>> abjad.Dynamic('"p"').ordinal
-2

User-defined ordinals:

>>> barely_audible = abjad.Dynamic(
...     'barely audible',
...     name_is_textual=True,
...     ordinal=-99,
...     )
>>> barely_audible.ordinal
-99
>>> extremely_loud = abjad.Dynamic(
...     'extremely loud',
...     name_is_textual=True,
...     ordinal=99,
...     )
>>> extremely_loud.ordinal
99

REGRESSION. Textual names without explicit ordinal return none:

>>> dynamic = abjad.Dynamic('appena udibile', name_is_textual=True)
>>> dynamic.ordinal is None
True
parameter

Is true.

>>> abjad.Dynamic('f').parameter
True
Return type:bool
sforzando

Is true when dynamic name begins in s- and ends in -z.

>>> abjad.Dynamic('f').sforzando
False
>>> abjad.Dynamic('sfz').sforzando
True
>>> abjad.Dynamic('sffz').sforzando
True
>>> abjad.Dynamic('sfp').sforzando
False
>>> abjad.Dynamic('sf').sforzando
False
>>> abjad.Dynamic('rfz').sforzando
False
Return type:Optional[bool]
tweaks

Gets tweaks

>>> note = abjad.Note("c'4")
>>> dynamic = abjad.Dynamic('f')
>>> abjad.tweak(dynamic).color = 'blue'
>>> abjad.attach(dynamic, note)
>>> abjad.show(note) 
>>> note = abjad.Note("c'4")
>>> dynamic = abjad.Dynamic(
...     'f',
...     tweaks=[('color', 'blue')],
...     )
>>> abjad.attach(dynamic, note)
>>> abjad.show(note) 
Return type:Optional[LilyPondTweakManager]