Measure

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.core" { graph [label="abjad.core"]; node [color=1]; "abjad.core.Component.Component" [URL="../api/abjad/core/Component.html#abjad.core.Component.Component", label=Component, shape=oval, style=bold, target=_top]; "abjad.core.Container.Container" [URL="../api/abjad/core/Container.html#abjad.core.Container.Container", label=Container, target=_top]; "abjad.core.Measure.Measure" [URL="../api/abjad/core/Measure.html#abjad.core.Measure.Measure", color=black, fontcolor=white, label=Measure, target=_top]; "abjad.core.Component.Component" -> "abjad.core.Container.Container"; "abjad.core.Container.Container" -> "abjad.core.Measure.Measure"; } subgraph "cluster_abjad.system" { graph [label="abjad.system"]; node [color=2]; "abjad.system.AbjadObject.AbjadObject" [URL="../api/abjad/core/../system/AbjadObject.html#abjad.system.AbjadObject.AbjadObject", label="Abjad\nObject", target=_top]; } 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.AbjadObject.AbjadObject" -> "abjad.core.Component.Component"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; }

class abjad.core.Measure.Measure(time_signature=None, components=None, identifier='% measure', implicit_scaling=False)

Measure.

>>> measure = abjad.Measure((4, 8), "c'8 d'8 e'8 f'8")
>>> abjad.show(measure) 

Attributes Summary

__copy__ Copies measure.
__delitem__ Deletes measure item i.
__repr__ Gets interpreter representation of measure.
__setitem__ Sets measure item i to argument.
always_format_time_signature Gets and sets flag to indicate whether time signature should appear in LilyPond format even when not expected.
automatically_adjust_time_signature Gets and sets flag to indicate whether time signature should update automatically following mutation.
from_selections Makes a selection of measures from selections.
has_non_power_of_two_denominator Is true when measure time signature denominator is not an integer power of 2.
has_power_of_two_denominator Is true when measure time signature denominator is an integer power of 2.
implicit_scaling Is true when measure should scale contents.
implied_prolation Implied prolation of measure.
is_full Is true when measure duration equals time signature duration.
is_misfilled Is true when measure is either underfull or overfull.
is_overfull I s true when measure duration is greater than time signature duration.
is_underfull Is true when measure duration is less than time signature duration.
measure_number Gets 1-indexed measure number.
scale_and_adjust_time_signature Scales measure by multiplier and adjusts time signature.
target_duration Gets target duration of measure.
time_signature Gets effective time signature of measure.

Special methods

(Container).__contains__(argument)

Is true when argument appears in container.

Return type:bool
__copy__(*arguments)

Copies measure.

Copies indicators.

Does not copy spanners.

Does not copy children.

Returns new component.

__delitem__(i)

Deletes measure item i.

>>> measure = abjad.Measure((4, 8), "c'8 d'8 e'8 f'8")
>>> measure.automatically_adjust_time_signature = True
>>> abjad.show(measure) 
>>> del(measure[1])
>>> abjad.show(measure) 

Returns none.

(Component).__format__(format_specification='')

Formats component.

Returns string.

(Container).__getitem__(argument)

Gets item or slice identified by argument.

Traverses top-level items only.

Return type:Union[Component, Selection]
(Container).__graph__(spanner=None, **keywords)

Graphviz graph representation of container.

Returns Graphviz graph.

(Component).__illustrate__()

Illustrates component.

Returns LilyPond file.

(Container).__iter__()

Iterates container.

Abjad containers are iterables:

>>> import collections
>>> container = abjad.Container()
>>> isinstance(container, collections.Iterable)
True

Abjad containers are not sequences:

>>> import collections
>>> container = abjad.Container()
>>> isinstance(container, collections.Sequence)
False

Yields container elements.

Returns generator.

(Container).__len__()

Gets number of components in container.

Return type:int
(Component).__mul__(n)

Copies component n times and detaches spanners.

Returns list of new components.

__repr__()

Gets interpreter representation of measure.

>>> measure = abjad.Measure((3, 8), "c'8 d'8 e'8")
>>> abjad.show(measure) 
>>> measure
Measure((3, 8), "c'8 d'8 e'8")

Returns string.

(Component).__rmul__(n)

Copies component n times and detach spanners.

Returns list of new components.

__setitem__(i, argument)

Sets measure item i to argument.

>>> measure = abjad.Measure((4, 8), "c'8 d'8 e'8 f'8")
>>> measure.automatically_adjust_time_signature = True
>>> abjad.show(measure) 
>>> measure[1] = abjad.Note("ds'8.")
>>> abjad.show(measure) 

Returns none.


Methods

(Container).append(component)

Appends component to container.

Appends note to container:

>>> container = abjad.Container("c'4 ( d'4 f'4 )")
>>> abjad.show(container) 
>>> container.append(abjad.Note("e'4"))
>>> abjad.show(container) 
Return type:None
(Container).extend(argument)

Extends container with argument.

Extends container with three notes:

>>> container = abjad.Container("c'4 ( d'4 f'4 )")
>>> abjad.show(container) 
>>> notes = [abjad.Note("e'32"), abjad.Note("d'32"), abjad.Note("e'16")]
>>> container.extend(notes)
>>> abjad.show(container) 
Return type:None
(Container).index(component)

Returns index of component in container.

Gets index of last element in container:

>>> container = abjad.Container("c'4 d'4 f'4 e'4")
>>> abjad.show(container) 
>>> note = container[-1]
>>> note
Note("e'4")
>>> container.index(note)
3
Return type:int
(Container).insert(i, component, fracture_spanners=False)

Inserts component at index i in container.

Inserts note. Does not fracture spanners:

>>> container = abjad.Container([])
>>> container.extend("fs16 cs' e' a'")
>>> container.extend("cs''16 e'' cs'' a'")
>>> container.extend("fs'16 e' cs' fs")
>>> slur = abjad.Slur(direction=abjad.Down)
>>> abjad.attach(slur, container[:])
>>> abjad.show(container) 
>>> container.insert(-4, abjad.Note("e'4"), fracture_spanners=False)
>>> abjad.show(container) 

Inserts note. Fractures spanners:

>>> container = abjad.Container([])
>>> container.extend("fs16 cs' e' a'")
>>> container.extend("cs''16 e'' cs'' a'")
>>> container.extend("fs'16 e' cs' fs")
>>> slur = abjad.Slur(direction=abjad.Down)
>>> abjad.attach(slur, container[:])
>>> abjad.show(container) 
>>> container.insert(-4, abjad.Note("e'4"), fracture_spanners=True)
>>> abjad.show(container) 
Return type:None
(Container).pop(i=-1)

Pops component from container at index i.

Pops last element from container:

>>> container = abjad.Container("c'4 ( d'4 f'4 ) e'4")
>>> abjad.show(container) 
>>> container.pop()
Note("e'4")
>>> abjad.show(container) 

Returns component.

(Container).remove(component)

Removes component from container.

Removes note from container:

>>> container = abjad.Container("c'4 ( d'4 f'4 ) e'4")
>>> abjad.show(container) 
>>> note = container[2]
>>> note
Note("f'4")
>>> container.remove(note)
>>> abjad.show(container) 
Return type:None
scale_and_adjust_time_signature(multiplier=None)

Scales measure by multiplier and adjusts time signature.

Scales measure by non-power-of-two multiplier:

>>> measure = abjad.Measure((3, 8), "c'8 d'8 e'8")
>>> measure.implicit_scaling = True
>>> abjad.show(measure) 
>>> measure.scale_and_adjust_time_signature(abjad.Multiplier(2, 3))
>>> abjad.show(measure) 

Returns none.


Class & static methods

classmethod from_selections(selections, time_signatures=None)

Makes a selection of measures from selections.

Returns selections.


Read/write properties

always_format_time_signature

Gets and sets flag to indicate whether time signature should appear in LilyPond format even when not expected.

>>> measure = abjad.Measure((4, 8), "c'8 d'8 e'8 f'8")
>>> measure.always_format_time_signature
False

Set to true when necessary to print the same signature repeatedly.

Defaults to false.

Returns true or false.

automatically_adjust_time_signature

Gets and sets flag to indicate whether time signature should update automatically following mutation.

>>> measure = abjad.Measure((3, 4), "c' d' e'")
>>> abjad.show(measure) 
>>> measure.automatically_adjust_time_signature = True
>>> measure.append('r')
>>> abjad.show(measure) 

Defaults to false.

Returns true or false.

(Container).identifier

Gets and sets bracket comment.

>>> container = abjad.Container(
...     "c'4 d'4 e'4 f'4",
...     identifier='%*% AB',
...     )
>>> abjad.show(container) 
>>> abjad.f(container)
{   %*% AB
    c'4
    d'4
    e'4
    f'4
}   %*% AB
Return type:Optional[str]
implicit_scaling

Is true when measure should scale contents.

Returns true or false.

(Container).is_simultaneous

Is true when container is simultaneous.

Gets simultaneity status of container:

>>> container = abjad.Container()
>>> container.append(abjad.Voice("c'8 d'8 e'8"))
>>> container.append(abjad.Voice('g4.'))
>>> abjad.show(container) 
>>> container.is_simultaneous is None
True

Sets simultaneity status of container:

>>> container = abjad.Container()
>>> container.append(abjad.Voice("c'8 d'8 e'8"))
>>> container.append(abjad.Voice('g4.'))
>>> abjad.show(container) 
>>> container.is_simultaneous = True
>>> abjad.show(container) 
Return type:Optional[bool]
(Container).name

Gets and sets name of container.

Gets container name:

>>> container = abjad.Container("c'4 d'4 e'4 f'4")
>>> abjad.show(container) 
>>> container.name is None
True

Sets container name:

>>> container = abjad.Container(
...     "c'4 d'4 e'4 f'4",
...     name='Special',
...     )
>>> abjad.show(container) 
>>> container.name
'Special'

Container name does not appear in LilyPond output:

>>> abjad.f(container)
{
    c'4
    d'4
    e'4
    f'4
}
Return type:Optional[str]

Read-only properties

(Container).components

Gets components in container.

Return type:tuple
has_non_power_of_two_denominator

Is true when measure time signature denominator is not an integer power of 2.

>>> measure = abjad.Measure((5, 9), "c'8 d' e' f' g'")
>>> measure.implicit_scaling = True
>>> abjad.show(measure) 
>>> measure.has_non_power_of_two_denominator
True

Otherwise false:

>>> measure = abjad.Measure((5, 8), "c'8 d' e' f' g'")
>>> abjad.show(measure) 
>>> measure.has_non_power_of_two_denominator
False

Returns true or false.

has_power_of_two_denominator

Is true when measure time signature denominator is an integer power of 2.

>>> measure = abjad.Measure((5, 8), "c'8 d' e' f' g'")
>>> abjad.show(measure) 
>>> measure.has_power_of_two_denominator
True

Otherwise false:

>>> measure = abjad.Measure((5, 9), "c'8 d' e' f' g'")
>>> measure.implicit_scaling = True
>>> abjad.show(measure) 
>>> measure.has_power_of_two_denominator
False

Returns true or false.

implied_prolation

Implied prolation of measure.

Measures with implicit scaling scale the duration of their contents:

>>> measure = abjad.Measure((5, 12), "c'8 d'8 e'8 f'8 g'8")
>>> measure.implicit_scaling = True
>>> abjad.show(measure) 
>>> measure.implied_prolation
Multiplier(2, 3)
>>> for note in measure:
...     note, abjad.inspect(note).duration()
... 
(Note("c'8"), Duration(1, 12))
(Note("d'8"), Duration(1, 12))
(Note("e'8"), Duration(1, 12))
(Note("f'8"), Duration(1, 12))
(Note("g'8"), Duration(1, 12))

Measures without implicit scaling turned on do not scale the duration of their contents:

>>> measure = abjad.Measure((5, 12), [])
>>> measure.implicit_scaling = False
>>> measure.implied_prolation
Multiplier(1, 1)

Returns positive multiplier.

is_full

Is true when measure duration equals time signature duration.

>>> measure = abjad.Measure((4, 8), "c'8 d'8 e'8 f'8")
>>> abjad.show(measure) 
>>> measure.is_full
True

Returns true or false.

is_misfilled

Is true when measure is either underfull or overfull.

>>> measure = abjad.Measure((3, 4), "c'4 d'4 e'4 f'4")
>>> measure.is_misfilled
True

Otherwise false:

>>> measure = abjad.Measure((3, 4), "c' d' e'")
>>> abjad.show(measure) 
>>> measure.is_misfilled
False

Returns true or false.

is_overfull

I s true when measure duration is greater than time signature duration.

>>> measure = abjad.Measure((3, 4), "c'4 d' e' f'")
>>> measure.is_overfull
True

Returns true or false.

is_underfull

Is true when measure duration is less than time signature duration.

>>> measure = abjad.Measure((3, 4), "c'4 d'")
>>> measure.is_underfull
True

Returns true or false.

measure_number

Gets 1-indexed measure number.

>>> staff = abjad.Staff()
>>> staff.append(abjad.Measure((3, 4), "c' d' e'"))
>>> staff.append(abjad.Measure((2, 4), "f' g'"))
>>> abjad.show(staff) 
>>> staff[0].measure_number
1
>>> staff[1].measure_number
2

Returns positive integer.

target_duration

Gets target duration of measure.

Target duration of measure is always equal to duration of effective time signature.

>>> measure = abjad.Measure((3, 4), "c'4 d'4 e'4")
>>> measure.target_duration
Duration(3, 4)

Returns duration.

time_signature

Gets effective time signature of measure.

>>> measure = abjad.Measure((3, 4), "c'4 d'4 e'4")
>>> measure.time_signature
TimeSignature((3, 4))

Returns time signature or none.