MetricAccentKernel

class metertools.MetricAccentKernel(kernel=None)

Metric accent kernel.

>>> import abjad
>>> 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)

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.AbjadValueObject.AbjadValueObject" [color=1, group=0, label=AbjadValueObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbjadObject" -> "abjad.tools.abctools.AbjadValueObject.AbjadValueObject"; "abjad.tools.abctools.AbjadObject.AbstractBase" -> "abjad.tools.abctools.AbjadObject.AbjadObject"; } subgraph cluster_metertools { graph [label=metertools]; "abjad.tools.metertools.MetricAccentKernel.MetricAccentKernel" [color=black, fontcolor=white, group=2, label=<<B>MetricAccentKernel</B>>, shape=box, style="filled, rounded"]; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=2, group=1, label=object, shape=box]; } "abjad.tools.abctools.AbjadValueObject.AbjadValueObject" -> "abjad.tools.metertools.MetricAccentKernel.MetricAccentKernel"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Bases

Attribute summary

count_offsets(argument) Count offsets in argument.
duration Gets duration.
from_meter(meter[, denominator, normalize]) Create a metric accent kernel from meter.
kernel The kernel datastructure.
__call__(argument) Calls metrical accent kernal on argument.
__copy__(*arguments) Copies 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.
__format__([format_specification]) Formats Abjad object.
__hash__() Hashes metric accent kernel.
__ne__(argument) Is true when Abjad object does not equal argument.
__repr__() Gets interpreter representation of Abjad object.

Read-only properties

MetricAccentKernel.duration

Gets duration.

MetricAccentKernel.kernel

The kernel datastructure.

Returns dict.

Class & static methods

static MetricAccentKernel.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])
>>> show(score) 
>>> MetricAccentKernel = abjad.MetricAccentKernel
>>> selector = abjad.select().by_leaf(flatten=True)
>>> leaves = selector(score)
>>> 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 MetricAccentKernel.from_meter(meter, denominator=32, normalize=True)

Create a metric accent kernel from meter.

Returns new metric accent kernel.

Special methods

MetricAccentKernel.__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.

MetricAccentKernel.__eq__(argument)

Is true when argument is a metrical accent kernal with a kernal equal to that of this metrical accent kernel. 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.

MetricAccentKernel.__hash__()

Hashes metric accent kernel.

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

Returns integer.

(AbjadObject).__ne__(argument)

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

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.