meter

Tools for modeling musical meter.

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.meter" { graph [label="abjad.meter"]; node [color=1]; "abjad.meter.Meter" [URL="../api/abjad/meter.html#abjad.meter.Meter", color=black, fontcolor=white, label=Meter, target=_top]; "abjad.meter.MeterList" [URL="../api/abjad/meter.html#abjad.meter.MeterList", color=black, fontcolor=white, label="Meter\nList", target=_top]; "abjad.meter.MetricAccentKernel" [URL="../api/abjad/meter.html#abjad.meter.MetricAccentKernel", color=black, fontcolor=white, label="Metric\nAccent\nKernel", target=_top]; "abjad.meter.OffsetCounter" [URL="../api/abjad/meter.html#abjad.meter.OffsetCounter", color=black, fontcolor=white, label="Offset\nCounter", target=_top]; } subgraph "cluster_abjad.system" { graph [label="abjad.system"]; node [color=2]; "abjad.system.AbjadObject.AbjadObject" [URL="../api/abjad/system/AbjadObject.html#abjad.system.AbjadObject.AbjadObject", label="Abjad\nObject", target=_top]; "abjad.system.AbjadValueObject.AbjadValueObject" [URL="../api/abjad/system/AbjadValueObject.html#abjad.system.AbjadValueObject.AbjadValueObject", label="Abjad\nValue\nObject", target=_top]; "abjad.system.AbjadObject.AbjadObject" -> "abjad.system.AbjadValueObject.AbjadValueObject"; } subgraph "cluster_abjad.utilities" { graph [label="abjad.utilities"]; node [color=3]; "abjad.utilities.TypedCollection.TypedCollection" [URL="../api/abjad/utilities/TypedCollection.html#abjad.utilities.TypedCollection.TypedCollection", label="Typed\nCollection", shape=oval, style=bold, target=_top]; "abjad.utilities.TypedCounter.TypedCounter" [URL="../api/abjad/utilities/TypedCounter.html#abjad.utilities.TypedCounter.TypedCounter", label="Typed\nCounter", target=_top]; "abjad.utilities.TypedList.TypedList" [URL="../api/abjad/utilities/TypedList.html#abjad.utilities.TypedList.TypedList", label="Typed\nList", target=_top]; "abjad.utilities.TypedCollection.TypedCollection" -> "abjad.utilities.TypedCounter.TypedCounter"; "abjad.utilities.TypedCollection.TypedCollection" -> "abjad.utilities.TypedList.TypedList"; } subgraph cluster_builtins { graph [label=builtins]; node [color=4]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } subgraph "cluster_collections.abc" { graph [label="collections.abc"]; node [color=5]; "collections.abc.Collection" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Collection", label=Collection, shape=oval, style=bold, target=_top]; "collections.abc.Container" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Container", label=Container, shape=oval, style=bold, target=_top]; "collections.abc.Iterable" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Iterable", label=Iterable, shape=oval, style=bold, target=_top]; "collections.abc.Mapping" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Mapping", label=Mapping, shape=oval, style=bold, target=_top]; "collections.abc.MutableMapping" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.MutableMapping", label="Mutable\nMapping", shape=oval, style=bold, target=_top]; "collections.abc.MutableSequence" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.MutableSequence", label="Mutable\nSequence", shape=oval, style=bold, target=_top]; "collections.abc.Reversible" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Reversible", label=Reversible, shape=oval, style=bold, target=_top]; "collections.abc.Sequence" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Sequence", label=Sequence, shape=oval, style=bold, target=_top]; "collections.abc.Sized" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Sized", label=Sized, shape=oval, style=bold, target=_top]; "collections.abc.Collection" -> "collections.abc.Mapping"; "collections.abc.Collection" -> "collections.abc.Sequence"; "collections.abc.Container" -> "collections.abc.Collection"; "collections.abc.Iterable" -> "collections.abc.Collection"; "collections.abc.Iterable" -> "collections.abc.Reversible"; "collections.abc.Mapping" -> "collections.abc.MutableMapping"; "collections.abc.Reversible" -> "collections.abc.Sequence"; "collections.abc.Sequence" -> "collections.abc.MutableSequence"; "collections.abc.Sized" -> "collections.abc.Collection"; } "abjad.system.AbjadObject.AbjadObject" -> "abjad.utilities.TypedCollection.TypedCollection"; "abjad.system.AbjadValueObject.AbjadValueObject" -> "abjad.meter.Meter"; "abjad.system.AbjadValueObject.AbjadValueObject" -> "abjad.meter.MetricAccentKernel"; "abjad.utilities.TypedCounter.TypedCounter" -> "abjad.meter.OffsetCounter"; "abjad.utilities.TypedList.TypedList" -> "abjad.meter.MeterList"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; "builtins.object" -> "collections.abc.Container"; "builtins.object" -> "collections.abc.Iterable"; "builtins.object" -> "collections.abc.Sized"; "collections.abc.MutableMapping" -> "abjad.utilities.TypedCounter.TypedCounter"; "collections.abc.MutableSequence" -> "abjad.utilities.TypedList.TypedList"; }


Classes

Meter Meter.
MeterList Meter list.
MetricAccentKernel Metric accent kernel.
OffsetCounter Offset counter.
class abjad.meter.Meter(argument=None, decrease_monotonic=True, preferred_boundary_depth=None)

Meter.

Meter models a common practice understanding of beats and other levels of rhythmic organization structured as a tree. Meter structure corresponds to the monotonically increasing sequence of factors in the numerator of a given time signature. Successively deeper levels of the tree divide time by successive factors.

Duple meter:

>>> meter = abjad.Meter((2, 4))
>>> meter
Meter('(2/4 (1/4 1/4))')
>>> print(meter.pretty_rtm_format)
(2/4 (
    1/4
    1/4))
>>> graph(meter) 

2/4 comprises two beats.

Triple meter:

>>> meter = abjad.Meter((3, 4))
>>> print(meter.pretty_rtm_format)
(3/4 (
    1/4
    1/4
    1/4))
>>> graph(meter) 

3/4 comprises three beats.

Quadruple meter:

>>> meter = abjad.Meter((4, 4))
>>> meter
Meter('(4/4 (1/4 1/4 1/4 1/4))')
>>> print(meter.pretty_rtm_format)
(4/4 (
    1/4
    1/4
    1/4
    1/4))
>>> graph(meter) 

4/4 comprises four beats.

Compound triple meter:

>>> meter = abjad.Meter((6, 8))
>>> print(meter.pretty_rtm_format)
(6/8 (
    (3/8 (
        1/8
        1/8
        1/8))
    (3/8 (
        1/8
        1/8
        1/8))))
>>> graph(meter) 

6/8 comprises two beats of three parts each.

Another compound triple meter:

>>> meter = abjad.Meter((12, 8))
>>> print(meter.pretty_rtm_format)
(12/8 (
    (3/8 (
        1/8
        1/8
        1/8))
    (3/8 (
        1/8
        1/8
        1/8))
    (3/8 (
        1/8
        1/8
        1/8))
    (3/8 (
        1/8
        1/8
        1/8))))
>>> graph(meter) 

12/8 comprises four beats of three parts each.

An asymmetric meter:

>>> meter = abjad.Meter((5, 4))
>>> print(meter.pretty_rtm_format)
(5/4 (
    (3/4 (
        1/4
        1/4
        1/4))
    (2/4 (
        1/4
        1/4))))
>>> graph(meter) 

5/4 comprises two unequal beats. By default unequal beats are arranged from greatest to least.

Another asymmetric meter:

>>> meter = abjad.Meter((7, 4))
>>> print(meter.pretty_rtm_format)
(7/4 (
    (3/4 (
        1/4
        1/4
        1/4))
    (2/4 (
        1/4
        1/4))
    (2/4 (
        1/4
        1/4))))
>>> graph(meter) 

7/4 comprises three unequal beats. Beats are arranged from greatest to least by default.

The same asymmetric meter structured differently:

>>> meter = abjad.Meter(
...     (7, 4),
...     decrease_monotonic=False,
...     )
>>> print(meter.pretty_rtm_format)
(7/4 (
    (2/4 (
        1/4
        1/4))
    (2/4 (
        1/4
        1/4))
    (3/4 (
        1/4
        1/4
        1/4))))
>>> graph(meter) 

7/4 with beats arragned from least to greatest.

Meter interpreted by default as containing two compound beats:

>>> meter = abjad.Meter((6, 4))
>>> meter
Meter('(6/4 ((3/4 (1/4 1/4 1/4)) (3/4 (1/4 1/4 1/4))))')
>>> print(meter.pretty_rtm_format)
(6/4 (
    (3/4 (
        1/4
        1/4
        1/4))
    (3/4 (
        1/4
        1/4
        1/4))))
>>> graph(meter) 

Same meter customized to contain four compound beats:

>>> parser = abjad.rhythmtrees.RhythmTreeParser()
>>> meter = abjad.Meter('(6/4 ((3/8 (1/8 1/8 1/8)) (3/8 (1/8 1/8 1/8)) (3/8 (1/8 1/8 1/8)) (3/8 (1/8 1/8 1/8))))')
>>> meter
Meter('(6/4 ((3/8 (1/8 1/8 1/8)) (3/8 (1/8 1/8 1/8)) (3/8 (1/8 1/8 1/8)) (3/8 (1/8 1/8 1/8))))')
>>> print(meter.pretty_rtm_format)
(6/4 (
    (3/8 (
        1/8
        1/8
        1/8))
    (3/8 (
        1/8
        1/8
        1/8))
    (3/8 (
        1/8
        1/8
        1/8))
    (3/8 (
        1/8
        1/8
        1/8))))
>>> graph(meter) 

Prime divisions greater than 3 are converted to sequences of 2 and 3 summing to that prime. Summands are arranged from greatest to least by default. This means that 5 becomes 3+2 and 7 becomes 3+2+2 in the examples above.


Attributes Summary

__eq__ Is true when argument is a meter with an rtm format equal to that of this meter.
__format__ Formats meter.
__graph__ Gets Graphviz format of meter.
__hash__ Hashes meter.
__iter__ Iterates meter.
__str__ Gets string representation of meter.
decrease_monotonic Is true when meter divides large primes into collections of 2 and 3 that decrease monotonically.
denominator Gets denominator of meter.
depthwise_offset_inventory Gets depthwise offset inventory of meter.
duration Gets duration of meter.
fit_meters Finds the best-matching sequence of meters for the offsets contained in argument.
generate_offset_kernel_to_denominator Generates a dictionary of all offsets in a meter up to denominator.
implied_time_signature Gets implied time signature of meter.
is_compound Is true when meter is compound.
is_simple Is true when meter is simple.
numerator Gets numerator of meter.
pair Gets pair of numerator and denominator of meter.
preferred_boundary_depth Gets preferred boundary depth of meter.
pretty_rtm_format Gets pretty RTM format of meter.
root_node Gets root node of meter.
rtm_format Gets RTM format of meter.

Special methods

(AbjadValueObject).__copy__(*arguments)

Copies Abjad value object.

Returns new Abjad value object.

__eq__(argument)

Is true when argument is a meter with an rtm format equal to that of this meter.

Returns true or false.

__format__(format_specification='')

Formats meter.

Gets storage format of 7/4:

>>> meter = abjad.Meter((7, 4))
>>> print(format(meter))
abjad.Meter(
    '(7/4 ((3/4 (1/4 1/4 1/4)) (2/4 (1/4 1/4)) (2/4 (1/4 1/4))))'
    )

Returns string.

__graph__(**keywords)

Gets Graphviz format of meter.

Graphs 7/4:

>>> meter = abjad.Meter((7, 4))
>>> meter_graph = meter.__graph__()
>>> graph(meter_graph) 

Returns Graphviz graph.

__hash__()

Hashes meter.

Returns integer.

__iter__()

Iterates meter.

Iterates 5/4:

>>> meter = abjad.Meter((5, 4))
>>> for x in meter:
...    x
... 
(NonreducedFraction(0, 4), NonreducedFraction(1, 4))
(NonreducedFraction(1, 4), NonreducedFraction(2, 4))
(NonreducedFraction(2, 4), NonreducedFraction(3, 4))
(NonreducedFraction(0, 4), NonreducedFraction(3, 4))
(NonreducedFraction(3, 4), NonreducedFraction(4, 4))
(NonreducedFraction(4, 4), NonreducedFraction(5, 4))
(NonreducedFraction(3, 4), NonreducedFraction(5, 4))
(NonreducedFraction(0, 4), NonreducedFraction(5, 4))

Yields pairs.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

__str__()

Gets string representation of meter.

Gets string representation of meters over 8:

>>> for numerator in range(1, 9):
...     meter = abjad.Meter((numerator, 8))
...     print(str(meter))
... 
1/8
2/8
3/8
4/8
5/8
6/8
7/8
8/8

Returns string.


Methods

generate_offset_kernel_to_denominator(denominator, normalize=True)

Generates a dictionary of all offsets in a meter up to denominator.

Keys are the offsets and the values are the normalized weights of those offsets.

>>> meter = abjad.Meter((4, 4))
>>> kernel = meter.generate_offset_kernel_to_denominator(8)
>>> for offset, weight in sorted(kernel.kernel.items()):
...     print('{!s}\t{!s}'.format(offset, weight))
... 
0	3/16
1/8	1/16
1/4	1/8
3/8	1/16
1/2	1/8
5/8	1/16
3/4	1/8
7/8	1/16
1	3/16

This is useful for testing how strongly a collection of offsets responds to a given meter.

Returns dictionary.


Class & static methods

static fit_meters(argument, meters, denominator=32, discard_final_orphan_downbeat=True, maximum_run_length=None, starting_offset=None)

Finds the best-matching sequence of meters for the offsets contained in argument.

>>> meters = [(3, 4), (4, 4), (5, 4)]
>>> meters = [abjad.Meter(_) for _ in meters]

Matches a series of hypothetical 4/4 measures:

>>> argument = [(0, 4), (4, 4), (8, 4), (12, 4), (16, 4)]
>>> for x in abjad.Meter.fit_meters(
...     argument, meters):
...     print(x.implied_time_signature)
... 
4/4
4/4
4/4
4/4

Matches a series of hypothetical 5/4 measures:

>>> argument = [(0, 4), (3, 4), (5, 4), (10, 4), (15, 4), (20, 4)]
>>> for x in abjad.Meter.fit_meters(
...     argument, meters):
...     print(x.implied_time_signature)
... 
3/4
4/4
3/4
5/4
5/4

Coerces offsets from argument via MetricAccentKernel.count_offsets().

Coerces Meters from meters via MeterList.

Returns list.


Read-only properties

decrease_monotonic

Is true when meter divides large primes into collections of 2 and 3 that decrease monotonically.

An asymmetric meter with beats arranged greatest to least:

>>> meter = abjad.Meter(
...     (7, 4),
...     decrease_monotonic=True,
...     )
>>> meter.decrease_monotonic
True
>>> print(meter.pretty_rtm_format)
(7/4 (
    (3/4 (
        1/4
        1/4
        1/4))
    (2/4 (
        1/4
        1/4))
    (2/4 (
        1/4
        1/4))))

This is default beahvior.

The same asymmetric meter with unequal beats arranged least to greatest:

>>> meter = abjad.Meter(
...     (7, 4),
...     decrease_monotonic=False,
...     )
>>> meter.decrease_monotonic
False
>>> print(meter.pretty_rtm_format)
(7/4 (
    (2/4 (
        1/4
        1/4))
    (2/4 (
        1/4
        1/4))
    (3/4 (
        1/4
        1/4
        1/4))))

Returns true or false.

denominator

Gets denominator of meter.

>>> meter = abjad.Meter((7, 4))
>>> meter.denominator
4

Returns positive integer.

depthwise_offset_inventory

Gets depthwise offset inventory of meter.

>>> meter = abjad.Meter((7, 4))
>>> for depth, offsets in enumerate(
...     meter.depthwise_offset_inventory):
...     print(depth, offsets)
... 
0 (Offset(0, 1), Offset(7, 4))
1 (Offset(0, 1), Offset(3, 4), Offset(5, 4), Offset(7, 4))
2 (Offset(0, 1), Offset(1, 4), Offset(1, 2), Offset(3, 4), Offset(1, 1), Offset(5, 4), Offset(3, 2), Offset(7, 4))

Returns dictionary.

duration

Gets duration of meter.

>>> meter = abjad.Meter((7, 4))
>>> meter.duration
Duration(7, 4)

Returns duration.

implied_time_signature

Gets implied time signature of meter.

>>> abjad.Meter((4, 4)).implied_time_signature
TimeSignature((4, 4))

Returns time signature.

is_compound

Is true when meter is compound.

Compound meters written over 4:

>>> for numerator in range(1, 13):
...     meter = abjad.Meter((numerator, 4))
...     string = True if meter.is_compound else ''
...     print(str(meter), string)
... 
1/4 
2/4 
3/4 
4/4 
5/4 
6/4 True
7/4 
8/4 
9/4 True
10/4 
11/4 
12/4 True

Compound meters written over 8:

>>> for numerator in range(1, 13):
...     meter = abjad.Meter((numerator, 8))
...     string = True if meter.is_compound else ''
...     print(str(meter), string)
... 
1/8 
2/8 
3/8 
4/8 
5/8 
6/8 True
7/8 
8/8 
9/8 True
10/8 
11/8 
12/8 True

Compound meters defined equal to those meters with a numerator divisible by 3 (but not equal to 3).

Returns true or false.

is_simple

Is true when meter is simple.

Simple meters written over 4:

>>> for numerator in range(1, 13):
...     meter = abjad.Meter((numerator, 4))
...     string = True if meter.is_simple else ''
...     print(str(meter), string)
... 
1/4 True
2/4 True
3/4 True
4/4 True
5/4 True
6/4 
7/4 True
8/4 True
9/4 
10/4 True
11/4 True
12/4 

Simple meters written over 8:

>>> for numerator in range(1, 13):
...     meter = abjad.Meter((numerator, 8))
...     string = True if meter.is_simple else ''
...     print(str(meter), string)
... 
1/8 True
2/8 True
3/8 True
4/8 True
5/8 True
6/8 
7/8 True
8/8 True
9/8 
10/8 True
11/8 True
12/8 

Simple meters defined equal to those meters with a numerator not divisible by 3.

Meters with numerator equal to 3 are also defined as simple.

Returns true or false.

numerator

Gets numerator of meter.

>>> meter = abjad.Meter((7, 4))
>>> meter.numerator
7

Returns positive integer.

pair

Gets pair of numerator and denominator of meter.

>>> meter = abjad.Meter((6, 4))
>>> meter.pair
(6, 4)

Returns pair.

preferred_boundary_depth

Gets preferred boundary depth of meter.

No preferred boundary depth:

>>> abjad.Meter((6, 8)).preferred_boundary_depth is None
True

Customized preferred boundary depth:

>>> meter = abjad.Meter(
...     (6, 8),
...     preferred_boundary_depth=1,
...     )
>>> meter.preferred_boundary_depth
1

Used by mutate().rewrite_meter().

Defaults to none.

Set to integer or none.

Returns integer or none.

pretty_rtm_format

Gets pretty RTM format of meter.

>>> meter = abjad.Meter((7, 4))
>>> print(meter.pretty_rtm_format)
(7/4 (
    (3/4 (
        1/4
        1/4
        1/4))
    (2/4 (
        1/4
        1/4))
    (2/4 (
        1/4
        1/4))))

Returns string.

root_node

Gets root node of meter.

>>> meter = abjad.Meter((7, 4))
>>> print(format(meter.root_node))
abjad.rhythmtrees.RhythmTreeContainer(
    children=(
        abjad.rhythmtrees.RhythmTreeContainer(
            children=(
                abjad.rhythmtrees.RhythmTreeLeaf(
                    preprolated_duration=abjad.Duration(1, 4),
                    is_pitched=True,
                    ),
                abjad.rhythmtrees.RhythmTreeLeaf(
                    preprolated_duration=abjad.Duration(1, 4),
                    is_pitched=True,
                    ),
                abjad.rhythmtrees.RhythmTreeLeaf(
                    preprolated_duration=abjad.Duration(1, 4),
                    is_pitched=True,
                    ),
                ),
            preprolated_duration=abjad.NonreducedFraction(3, 4),
            ),
        abjad.rhythmtrees.RhythmTreeContainer(
            children=(
                abjad.rhythmtrees.RhythmTreeLeaf(
                    preprolated_duration=abjad.Duration(1, 4),
                    is_pitched=True,
                    ),
                abjad.rhythmtrees.RhythmTreeLeaf(
                    preprolated_duration=abjad.Duration(1, 4),
                    is_pitched=True,
                    ),
                ),
            preprolated_duration=abjad.NonreducedFraction(2, 4),
            ),
        abjad.rhythmtrees.RhythmTreeContainer(
            children=(
                abjad.rhythmtrees.RhythmTreeLeaf(
                    preprolated_duration=abjad.Duration(1, 4),
                    is_pitched=True,
                    ),
                abjad.rhythmtrees.RhythmTreeLeaf(
                    preprolated_duration=abjad.Duration(1, 4),
                    is_pitched=True,
                    ),
                ),
            preprolated_duration=abjad.NonreducedFraction(2, 4),
            ),
        ),
    preprolated_duration=abjad.NonreducedFraction(7, 4),
    )

Returns rhythm tree node.

rtm_format

Gets RTM format of meter.

>>> meter = abjad.Meter((7, 4))
>>> meter.rtm_format
'(7/4 ((3/4 (1/4 1/4 1/4)) (2/4 (1/4 1/4)) (2/4 (1/4 1/4))))'

Returns string.

class abjad.meter.MeterList(items=None, item_class=None, keep_sorted=False)

Meter list.

>>> meters = abjad.MeterList([
...     (3, 4), (5, 16), (7, 8),
...     ])
>>> abjad.f(meters)
abjad.MeterList(
    [
        abjad.Meter(
            '(3/4 (1/4 1/4 1/4))'
            ),
        abjad.Meter(
            '(5/16 ((3/16 (1/16 1/16 1/16)) (2/16 (1/16 1/16))))'
            ),
        abjad.Meter(
            '(7/8 ((3/8 (1/8 1/8 1/8)) (2/8 (1/8 1/8)) (2/8 (1/8 1/8))))'
            ),
        ]
    )
>>> abjad.show(meters, scale=0.5) 

Attributes Summary

__illustrate__ Illustrates meters.

Special methods

(TypedCollection).__contains__(item)

Is true when typed collection contains item.

Returns true or false.

(TypedList).__delitem__(i)

Aliases list.__delitem__().

Returns none.

(TypedCollection).__eq__(argument)

Is true when argument is a typed collection with items that compare equal to those of this typed collection.

Returns true or false.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to '' or 'storage'. Interprets '' equal to 'storage'.

Returns string.

(TypedList).__getitem__(argument)

Gets item or slice identified by argument.

Returns item or slice.

(TypedCollection).__hash__()

Hashes typed collection.

Redefined in tandem with __eq__.

(TypedList).__iadd__(argument)

Adds argument in place to typed list.

>>> dynamic_list = abjad.TypedList(item_class=abjad.Dynamic)
>>> dynamic_list.append('ppp')
>>> dynamic_list += ['p', 'mp', 'mf', 'fff']
>>> abjad.f(dynamic_list)
abjad.TypedList(
    [
        abjad.Dynamic('ppp'),
        abjad.Dynamic('p'),
        abjad.Dynamic('mp'),
        abjad.Dynamic('mf'),
        abjad.Dynamic('fff'),
        ],
    item_class=abjad.Dynamic,
    )

Returns typed list.

__illustrate__(denominator=16, range_=None, scale=None)

Illustrates meters.

>>> meters = abjad.MeterList([
...     (3, 4), (5, 16), (7, 8),
...     ])
>>> abjad.show(meters, scale=0.5) 

Returns LilyPond file.

(TypedCollection).__iter__()

Iterates typed collection.

Returns generator.

(TypedCollection).__len__()

Gets length of typed collection.

Returns nonnegative integer.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

(TypedList).__reversed__()

Aliases list.__reversed__().

Returns generator.

(TypedList).__setitem__(i, argument)

Sets item i equal to argument.

Sets item:

>>> pitch_list = abjad.TypedList(
...     item_class=abjad.NamedPitch,
...     )
>>> pitch_list.append(0)
>>> pitch_list.append("d'")
>>> pitch_list.append(('e', 4))
>>> pitch_list.append(abjad.NamedPitch("f'"))
>>> pitch_list[-1] = 'gqs,'
>>> abjad.f(pitch_list)
abjad.TypedList(
    [
        abjad.NamedPitch("c'"),
        abjad.NamedPitch("d'"),
        abjad.NamedPitch("e'"),
        abjad.NamedPitch('gqs,'),
        ],
    item_class=abjad.NamedPitch,
    )

Sets slice:

>>> pitch_list[-1:] = ["f'", "g'", "a'", "b'", "c''"]
>>> abjad.f(pitch_list)
abjad.TypedList(
    [
        abjad.NamedPitch("c'"),
        abjad.NamedPitch("d'"),
        abjad.NamedPitch("e'"),
        abjad.NamedPitch("f'"),
        abjad.NamedPitch("g'"),
        abjad.NamedPitch("a'"),
        abjad.NamedPitch("b'"),
        abjad.NamedPitch("c''"),
        ],
    item_class=abjad.NamedPitch,
    )

Returns none.


Methods

(TypedList).append(item)

Appends item to typed list.

>>> integer_list = abjad.TypedList(item_class=int)
>>> integer_list.append('1')
>>> integer_list.append(2)
>>> integer_list.append(3.4)
>>> integer_list[:]
[1, 2, 3]

Returns none.

(MutableSequence).clear() → None -- remove all items from S
(TypedList).count(item)

Gets count of item in typed list.

>>> integer_list = abjad.TypedList(item_class=int)
>>> integer_list.extend([0, 0., '0', 99])
>>> integer_list.count(0)
3
>>> integer_list.count(1)
0
>>> integer_list.count(99)
1

Returns nonnegative integer.

(TypedList).extend(items)

Extends typed list with items.

>>> integer_list = abjad.TypedList(item_class=int)
>>> integer_list.extend(['0', 1.0, 2, 3.14159])
>>> integer_list
TypedList([0, 1, 2, 3], item_class=int)

Returns none.

(TypedList).index(item)

Gets index of item in typed list.

>>> pitch_list = abjad.TypedList(
...     item_class=abjad.NamedPitch,
...     )
>>> pitch_list.extend(['cqf', "as'", 'b,', 'dss'])
>>> pitch_list.index(abjad.NamedPitch('cqf'))
0
>>> pitch_list.index(abjad.NamedPitch("as'"))
1
>>> pitch_list.index('b,')
2
>>> pitch_list.index('dss')
3

Returns nonnegative integer.

(TypedList).insert(i, item)

Insert item into typed list.

Inserts into typed list.

>>> integer_list = abjad.TypedList(item_class=int)
>>> integer_list.extend(['1', 2, 4.3])
>>> integer_list
TypedList([1, 2, 4], item_class=int)
>>> integer_list.insert(0, '0')
>>> integer_list
TypedList([0, 1, 2, 4], item_class=int)
>>> integer_list.insert(1, '9')
>>> integer_list
TypedList([0, 9, 1, 2, 4], item_class=int)

Returns none.

(TypedList).pop(i=-1)

Pops item i from typed list.

Returns item.

(TypedList).remove(item)

Removes item from typed list.

>>> integer_list = abjad.TypedList(item_class=int)
>>> integer_list.extend(('0', 1.0, 2, 3.14159))
>>> integer_list[:]
[0, 1, 2, 3]
>>> integer_list.remove('1')
>>> integer_list[:]
[0, 2, 3]

Returns none.

(TypedList).reverse()

Reverses items in typed list.

(TypedList).sort(cmp=None, key=None, reverse=False)

Sorts items in typed list.


Read/write properties

(TypedList).keep_sorted

Is true when typed list keeps items sorted.

Defaults to none.

Set to true, false or none.

Returns true, false or none.


Read-only properties

(TypedCollection).item_class

Gets item class of collection.

Collection coerces items according to item_class.

Returns class.

(TypedCollection).items

Gets items in collection.

Returns list.

class abjad.meter.MetricAccentKernel(kernel=None)

Metric accent kernel.

>>> hierarchy = abjad.Meter((7, 8))
>>> kernel = hierarchy.generate_offset_kernel_to_denominator(8)
>>> kernel
MetricAccentKernel(
    {
        Offset(0, 1): Multiplier(3, 14),
        Offset(1, 8): Multiplier(1, 14),
        Offset(1, 4): Multiplier(1, 14),
        Offset(3, 8): Multiplier(1, 7),
        Offset(1, 2): Multiplier(1, 14),
        Offset(5, 8): Multiplier(1, 7),
        Offset(3, 4): Multiplier(1, 14),
        Offset(7, 8): Multiplier(3, 14),
        }
    )

Call the kernel against an expression from which offsets can be counted to receive an impulse-response:

>>> offsets = [(0, 8), (1, 8), (1, 8), (3, 8)]
>>> kernel(offsets)
Multiplier(1, 2)

Attributes Summary

__call__ Calls metrical accent kernal on argument.
__eq__ Is true when argument is a metrical accent kernal with a kernal equal to that of this metrical accent kernel.
__hash__ Hashes metric accent kernel.
count_offsets Count offsets in argument.
duration Gets duration.
from_meter Create a metric accent kernel from meter.
kernel The kernel datastructure.

Special methods

__call__(argument)

Calls metrical accent kernal on argument.

>>> upper_staff = abjad.Staff("c'8 d'4. e'8 f'4.")
>>> lower_staff = abjad.Staff(r'\clef bass c4 b,4 a,2')
>>> score = abjad.Score([upper_staff, lower_staff])
>>> kernel = abjad.MetricAccentKernel.from_meter((4, 4))
>>> kernel(score)
Multiplier(10, 33)

Returns float.

(AbjadValueObject).__copy__(*arguments)

Copies Abjad value object.

Returns new Abjad value object.

__eq__(argument)

Is true when argument is a metrical accent kernal with a kernal equal to that of this metrical accent kernel.

Returns true or false.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to '' or 'storage'. Interprets '' equal to 'storage'.

Returns string.

__hash__()

Hashes metric accent kernel.

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

Returns integer.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.


Class & static methods

static count_offsets(argument)

Count offsets in argument.

>>> upper_staff = abjad.Staff("c'8 d'4. e'8 f'4.")
>>> lower_staff = abjad.Staff(r'\clef bass c4 b,4 a,2')
>>> score = abjad.Score([upper_staff, lower_staff])
>>> abjad.show(score) 
>>> MetricAccentKernel = abjad.MetricAccentKernel
>>> leaves = abjad.select(score).leaves()
>>> counter = abjad.MetricAccentKernel.count_offsets(leaves)
>>> for offset, count in sorted(counter.items()):
...     offset, count
... 
(Offset(0, 1), 2)
(Offset(1, 8), 2)
(Offset(1, 4), 2)
(Offset(1, 2), 4)
(Offset(5, 8), 2)
(Offset(1, 1), 2)
>>> a = abjad.Timespan(0, 10)
>>> b = abjad.Timespan(5, 15)
>>> c = abjad.Timespan(15, 20)
>>> counter = MetricAccentKernel.count_offsets((a, b, c))
>>> for offset, count in sorted(counter.items()):
...     offset, count
... 
(Offset(0, 1), 1)
(Offset(5, 1), 1)
(Offset(10, 1), 1)
(Offset(15, 1), 2)
(Offset(20, 1), 1)

Returns counter.

static from_meter(meter, denominator=32, normalize=True)

Create a metric accent kernel from meter.

Returns new metric accent kernel.


Read-only properties

duration

Gets duration.

kernel

The kernel datastructure.

Returns dict.

class abjad.meter.OffsetCounter(items=None)

Offset counter.

>>> timespans = abjad.TimespanList([
...     abjad.Timespan(0, 16),
...     abjad.Timespan(5, 12),
...     abjad.Timespan(-2, 8),
...     ])
>>> timespan_operand = abjad.Timespan(6, 10)
>>> timespans = timespans - timespan_operand
>>> offset_counter = abjad.OffsetCounter(timespans)
>>> abjad.f(offset_counter)
abjad.OffsetCounter(
    {
        abjad.Offset(-2, 1): 1,
        abjad.Offset(0, 1): 1,
        abjad.Offset(5, 1): 1,
        abjad.Offset(6, 1): 3,
        abjad.Offset(10, 1): 2,
        abjad.Offset(12, 1): 1,
        abjad.Offset(16, 1): 1,
        }
    )
>>> abjad.show(offset_counter, scale=0.5) 

Attributes Summary

__illustrate__ Illustrates offset counter.

Special methods

(TypedCounter).__add__(argument)

Adds typed counter to argument.

Returns new typed counter.

(TypedCounter).__and__(argument)

Logical AND of typed counter and argument.

Returns new typed counter.

(TypedCollection).__contains__(item)

Is true when typed collection contains item.

Returns true or false.

(TypedCounter).__delitem__(item)

Deletes item from typed counter.

Returns none.

(TypedCollection).__eq__(argument)

Is true when argument is a typed collection with items that compare equal to those of this typed collection.

Returns true or false.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to '' or 'storage'. Interprets '' equal to 'storage'.

Returns string.

(TypedCounter).__getitem__(argument)

Gets item or slice identified by argument.

Returns item or slice.

(TypedCollection).__hash__()

Hashes typed collection.

Redefined in tandem with __eq__.

__illustrate__(range_=None, scale=None)

Illustrates offset counter.

>>> timespans = abjad.TimespanList([
...     abjad.Timespan(0, 16),
...     abjad.Timespan(5, 12),
...     abjad.Timespan(-2, 8),
...     ])
>>> timespan_operand = abjad.Timespan(6, 10)
>>> timespans = timespans - timespan_operand
>>> offset_counter = abjad.OffsetCounter(timespans)
>>> abjad.show(offset_counter, scale=0.5) 

Returns LilyPond file.

(TypedCollection).__iter__()

Iterates typed collection.

Returns generator.

(TypedCollection).__len__()

Gets length of typed collection.

Returns nonnegative integer.

(TypedCounter).__or__(argument)

Logical OR of typed counter and argument.

Returns new typed counter.

(TypedCounter).__radd__(argument)

Adds argument to typed counter.

Returns new typed counter.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

(TypedCounter).__setitem__(item, value)

Sets typed counter item to value.

Returns none.

(TypedCounter).__sub__(argument)

Subtracts argument from typed counter.

Returns new typed counter.


Methods

(TypedCounter).clear()

Clears typed counter.

Returns none.

(TypedCounter).copy()

Copies typed counter.

Returns new typed counter.

(TypedCounter).elements()

Elements in typed counter.

(Mapping).get(k[, d]) → D[k] if k in D, else d. d defaults to None.
(TypedCounter).items()

Items in typed counter.

Returns tuple.

(TypedCounter).keys()

Iterates keys in typed counter.

(TypedCounter).most_common(n=None)

Please document.

(MutableMapping).pop(k[, d]) → v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised.

(MutableMapping).popitem() → (k, v), remove and return some (key, value) pair

as a 2-tuple; but raise KeyError if D is empty.

(MutableMapping).setdefault(k[, d]) → D.get(k,d), also set D[k]=d if k not in D
(TypedCounter).subtract(iterable=None, **keywords)

Subtracts iterable from typed counter.

(TypedCounter).update(iterable=None, **keywords)

Updates typed counter with iterable.

(TypedCounter).values()

Iterates values in typed counter.

(TypedCounter).viewitems()

Please document.

(TypedCounter).viewkeys()

Please document.

(TypedCounter).viewvalues()

Please document.


Read-only properties

(TypedCollection).item_class

Gets item class of collection.

Collection coerces items according to item_class.

Returns class.