Hairpin

class spannertools.Hairpin(descriptor='<', direction=None, include_rests=False, overrides=None)

Hairpin.

Example 1. Crescendo:

>>> staff = Staff("r4 c'8 d'8 e'8 f'8 r4")
>>> hairpin = spannertools.Hairpin(
...     descriptor='p < f',
...     include_rests=False,
...     )
>>> attach(hairpin, staff[:])
>>> show(staff) 

Example 2. Decrescendo:

>>> staff = Staff("r4 c'8 d'8 e'8 f'8 r4")
>>> hairpin = spannertools.Hairpin(
...     descriptor='f > p',
...     include_rests=False,
...     )
>>> attach(hairpin, staff[:])
>>> show(staff) 

Example 3. Crescendo dal niente:

>>> staff = Staff("c'4 d' e' f'")
>>> hairpin = spannertools.Hairpin(
...     descriptor='niente < f',
...     include_rests=False,
...     )
>>> attach(hairpin, staff[:])
>>> show(staff) 

Example 4. Decrescendo al niente:

>>> staff = Staff("c'4 d' e' f'")
>>> hairpin = spannertools.Hairpin(
...     descriptor='f > niente',
...     include_rests=False,
...     )
>>> attach(hairpin, staff[:])
>>> show(staff) 

Todo

Make niente hairpins work with include_rests=True.

Lineage

digraph InheritanceGraph { graph [background=transparent, bgcolor=transparent, color=lightslategrey, fontname=Arial, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, root="__builtin__.object", splines=spline, style="dotted, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=12, penwidth=2, style="filled, rounded"]; edge [color=lightsteelblue2, penwidth=2]; subgraph cluster_abctools { graph [label=abctools]; "abjad.tools.abctools.AbjadObject.AbjadObject" [color=1, group=0, label=AbjadObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" [color=1, group=0, label=AbstractBase, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" -> "abjad.tools.abctools.AbjadObject.AbjadObject"; } subgraph cluster_spannertools { graph [label=spannertools]; "abjad.tools.spannertools.Crescendo.Crescendo" [color=3, group=2, label=Crescendo, shape=box]; "abjad.tools.spannertools.Decrescendo.Decrescendo" [color=3, group=2, label=Decrescendo, shape=box]; "abjad.tools.spannertools.Hairpin.Hairpin" [color=black, fontcolor=white, group=2, label=<<B>Hairpin</B>>, shape=box, style="filled, rounded"]; "abjad.tools.spannertools.Spanner.Spanner" [color=3, group=2, label=Spanner, shape=box]; "abjad.tools.spannertools.Hairpin.Hairpin" -> "abjad.tools.spannertools.Crescendo.Crescendo"; "abjad.tools.spannertools.Hairpin.Hairpin" -> "abjad.tools.spannertools.Decrescendo.Decrescendo"; "abjad.tools.spannertools.Spanner.Spanner" -> "abjad.tools.spannertools.Hairpin.Hairpin"; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=2, group=1, label=object, shape=box]; } "abjad.tools.abctools.AbjadObject.AbjadObject" -> "abjad.tools.spannertools.Spanner.Spanner"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Bases

Attribute summary

components Gets components in spanner.
descriptor Gets descriptor of hairpin.
direction Gets direction.
include_rests Gets include-rests flag of hairpin.
name Gets spanner name.
overrides Gets overrides.
shape_string Gets shape string of hairpin.
start_dynamic Gets start dynamic string of hairpin.
stop_dynamic Gets stop dynamic string of hairpin.
__contains__(expr) Is true when spanner contains expr.
__copy__(\*args) Copies spanner.
__eq__(expr) Is true when ID of expr equals ID of Abjad object.
__format__([format_specification]) Formats Abjad object.
__getitem__(expr) Gets item from spanner.
__hash__() Hashes Abjad object.
__len__() Gets number of components in spanner.
__lt__(expr) Is true when spanner is less than expr.
__ne__(expr) Is true when Abjad object does not equal expr.
__repr__() Gets interpreter representation of Abjad object.

Read-only properties

(Spanner).components

Gets components in spanner.

Returns selection.

Hairpin.descriptor

Gets descriptor of hairpin.

Example 1. Gets descriptor of crescendo:

>>> staff = Staff("r4 c'8 d'8 e'8 f'8 r4")
>>> hairpin = spannertools.Hairpin(descriptor='p < f')
>>> attach(hairpin, staff[:])
>>> show(staff) 
>>> hairpin.descriptor
'p < f'

Returns string.

Hairpin.direction

Gets direction.

Example 1. Positions hairpin above staff:

>>> staff = Staff("r4 c'8 d'8 e'8 f'8 r4")
>>> hairpin = spannertools.Hairpin(
...     descriptor='p < f',
...     direction=Up,
...     )
>>> attach(hairpin, staff[:])
>>> show(staff) 

Defaults to none.

Set to up, down or none.

Returns up, down or none.

Hairpin.include_rests

Gets include-rests flag of hairpin.

Example 1. Crescendo includes rests:

>>> staff = Staff("r4 c'8 d'8 e'8 f'8 r4")
>>> hairpin = spannertools.Hairpin(
...     descriptor='p < f',
...     include_rests=True,
...     )
>>> attach(hairpin, staff[:])
>>> show(staff) 

Returns true or false.

(Spanner).name

Gets spanner name.

Returns string.

(Spanner).overrides

Gets overrides.

Returns dict.

Hairpin.shape_string

Gets shape string of hairpin.

Example 1. Gets shape string of crescendo:

>>> staff = Staff("r4 c'8 d'8 e'8 f'8 r4")
>>> hairpin = spannertools.Hairpin(descriptor='p < f')
>>> attach(hairpin, staff[:])
>>> show(staff) 
>>> hairpin.shape_string
'<'

Returns string.

Hairpin.start_dynamic

Gets start dynamic string of hairpin.

Example 1. Gets start dynamic of crescendo:

>>> staff = Staff("r4 c'8 d'8 e'8 f'8 r4")
>>> hairpin = spannertools.Hairpin(descriptor='p < f')
>>> attach(hairpin, staff[:])
>>> show(staff) 
>>> hairpin.start_dynamic
Dynamic(name='p')

Returns dynamic or none.

Hairpin.stop_dynamic

Gets stop dynamic string of hairpin.

Example 1. Gets stop dynamic of crescendo:

>>> staff = Staff("r4 c'8 d'8 e'8 f'8 r4")
>>> hairpin = spannertools.Hairpin(descriptor='p < f')
>>> attach(hairpin, staff[:])
>>> show(staff) 
>>> hairpin.stop_dynamic
Dynamic(name='f')

Returns dynamic or none.

Special methods

(Spanner).__contains__(expr)

Is true when spanner contains expr. Otherwise false.

Returns true or false.

(Spanner).__copy__(*args)

Copies spanner.

Does not copy spanner components.

Returns new spanner.

(AbjadObject).__eq__(expr)

Is true when ID of expr equals ID of Abjad object. Otherwise false.

Returns true or false.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to ‘’ or ‘storage’. Interprets ‘’ equal to ‘storage’.

Returns string.

(Spanner).__getitem__(expr)

Gets item from spanner.

Returns component.

(AbjadObject).__hash__()

Hashes Abjad object.

Required to be explicitly redefined on Python 3 if __eq__ changes.

Returns integer.

(Spanner).__len__()

Gets number of components in spanner.

Returns nonnegative integer.

(Spanner).__lt__(expr)

Is true when spanner is less than expr. Otherwise false.

Trivial comparison to allow doctests to work.

Returns true or false.

(AbjadObject).__ne__(expr)

Is true when Abjad object does not equal expr. Otherwise false.

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.