MetricModulation

class indicatortools.MetricModulation(left_rhythm=None, right_rhythm=None, left_markup=None, right_markup=None)

Metric modulation.

Example 1. With notes:

>>> metric_modulation = indicatortools.MetricModulation(
...     left_rhythm=Note("c'4"),
...     right_rhythm=Note("c'4."),
...     )
>>> show(metric_modulation) 

Example 2. With tuplets:

>>> metric_modulation = indicatortools.MetricModulation(
...     left_rhythm=Tuplet((4, 5), "c'4"),
...     right_rhythm=Note("c'4"),
...     )
>>> show(metric_modulation) 

Example 3. With tuplets again:

>>> metric_modulation = indicatortools.MetricModulation(
...     left_rhythm=Note("c16."),
...     right_rhythm=Tuplet((2, 3), "c8"),
...     )
>>> show(metric_modulation) 

Example 4. With ties:

>>> notes = scoretools.make_notes([0], [Duration(5, 16)])
>>> metric_modulation = indicatortools.MetricModulation(
...     left_rhythm=Note("c'4"),
...     right_rhythm=notes,
...     )
>>> show(metric_modulation) 

Example 5. With ties and tuplets:

>>> notes = scoretools.make_notes([0], [Duration(5, 16)])
>>> tuplet = Tuplet((2, 3), notes)
>>> metric_modulation = indicatortools.MetricModulation(
...     left_rhythm=Note("c'4"),
...     right_rhythm=tuplet,
...     )
>>> show(metric_modulation) 

Example 6. Attach metric modulations to generate score output:

>>> staff = Staff("c'4 d'4 e'4 f'4 e'4 d'4")
>>> attach(TimeSignature((3, 4)), staff)
>>> score = Score([staff])
>>> metric_modulation = indicatortools.MetricModulation(
...     left_rhythm=Note("c4"),
...     right_rhythm=Note("c8."),
...     )
>>> attach(metric_modulation, staff[3])
>>> override(staff).text_script.staff_padding = 2.5
>>> show(score) 

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_indicatortools { graph [label=indicatortools]; "abjad.tools.indicatortools.MetricModulation.MetricModulation" [color=black, fontcolor=white, group=2, label=<<B>MetricModulation</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.indicatortools.MetricModulation.MetricModulation"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Bases

Attribute summary

default_scope Gets default scope of metric modulation.
left_markup Gets left markup of metric modulation.
left_rhythm Gets left rhythm of metric modulation.
ratio Gets ratio of metric modulation.
right_markup Gets right markup of metric modulation.
right_rhythm Gets right tempo of metric modulation.
__copy__(*arguments) Copies Abjad value object.
__eq__(argument) Is true argument is another metric modulation with the same ratio as this metric modulation.
__format__([format_specification]) Formats metric modulation.
__hash__() Hashes metric modulation.
__illustrate__() Illustrates metric modulation.
__ne__(argument) Is true when Abjad object does not equal argument.
__repr__() Gets interpreter representation of Abjad object.
__str__() Gets string representation of metric modulation.

Read-only properties

MetricModulation.default_scope

Gets default scope of metric modulation.

>>> metric_modulation = indicatortools.MetricModulation(
...     left_rhythm=Note("c'4"),
...     right_rhythm=Note("c'4."),
...     )
>>> metric_modulation.default_scope is None
True

Todo

Metric modulations should be score-scope.

Returns none (but should return score).

MetricModulation.left_markup

Gets left markup of metric modulation.

>>> metric_modulation = indicatortools.MetricModulation(
...     left_rhythm=Note("c'4"),
...     right_rhythm=Note("c'4."),
...     )
>>> metric_modulation.left_markup

Returns markup or none.

MetricModulation.left_rhythm

Gets left rhythm of metric modulation.

>>> metric_modulation = indicatortools.MetricModulation(
...     left_rhythm=Note("c'4"),
...     right_rhythm=Note("c'4."),
...     )
>>> metric_modulation.left_rhythm
Selection([Note("c'4")])

Returns selection.

MetricModulation.ratio

Gets ratio of metric modulation.

>>> metric_modulation = indicatortools.MetricModulation(
...     left_rhythm=Tuplet((2, 3), [Note("c'4")]),
...     right_rhythm=Note("c'4"),
...     )
>>> metric_modulation.ratio
Ratio((2, 3))

Returns ratio.

MetricModulation.right_markup

Gets right markup of metric modulation.

>>> metric_modulation = indicatortools.MetricModulation(
...     left_rhythm=Note("c'4"),
...     right_rhythm=Note("c'4."),
...     )
>>> metric_modulation.right_markup

Returns markup or none.

MetricModulation.right_rhythm

Gets right tempo of metric modulation.

>>> metric_modulation = indicatortools.MetricModulation(
...     left_rhythm=Note("c'4"),
...     right_rhythm=Note("c'4."),
...     )
>>> metric_modulation.right_rhythm
Selection([Note("c'4.")])

Returns selection.

Special methods

(AbjadValueObject).__copy__(*arguments)

Copies Abjad value object.

Returns new Abjad value object.

MetricModulation.__eq__(argument)

Is true argument is another metric modulation with the same ratio as this metric modulation. Otherwise false.

>>> metric_modulation_1 = indicatortools.MetricModulation(
...     left_rhythm=Note("c'4"),
...     right_rhythm=Note("c'4."),
...     )
>>> metric_modulation_2 = indicatortools.MetricModulation(
...     left_rhythm=Tuplet((2, 3), [Note("c'4")]),
...     right_rhythm=Note("c'4"),
...     )
>>> notes = scoretools.make_notes([0], [Duration(5, 16)])
>>> metric_modulation_3 = indicatortools.MetricModulation(
...     left_rhythm=Note("c'4"),
...     right_rhythm=notes,
...     )
>>> metric_modulation_1.ratio
Ratio((2, 3))
>>> metric_modulation_2.ratio
Ratio((2, 3))
>>> metric_modulation_3.ratio
Ratio((4, 5))
>>> metric_modulation_1 == metric_modulation_1
True
>>> metric_modulation_1 == metric_modulation_2
True
>>> metric_modulation_1 == metric_modulation_3
False
>>> metric_modulation_2 == metric_modulation_1
True
>>> metric_modulation_2 == metric_modulation_2
True
>>> metric_modulation_2 == metric_modulation_3
False
>>> metric_modulation_3 == metric_modulation_1
False
>>> metric_modulation_3 == metric_modulation_2
False
>>> metric_modulation_3 == metric_modulation_3
True

Returns true or false.

MetricModulation.__format__(format_specification='')

Formats metric modulation.

>>> metric_modulation = indicatortools.MetricModulation(
...     left_rhythm=Note("c'4"),
...     right_rhythm=Note("c'4."),
...     )
>>> print(format(metric_modulation))
indicatortools.MetricModulation(
    left_rhythm=selectiontools.Selection(
        [
            scoretools.Note("c'4"),
            ]
        ),
    right_rhythm=selectiontools.Selection(
        [
            scoretools.Note("c'4."),
            ]
        ),
    )

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

Returns string.

MetricModulation.__hash__()

Hashes metric modulation.

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

Returns integer.

MetricModulation.__illustrate__()

Illustrates metric modulation.

>>> metric_modulation = indicatortools.MetricModulation(
...     left_rhythm=Tuplet((2, 3), "c'4"),
...     right_rhythm=Note("c'4."),
...     )
>>> show(metric_modulation) 

Returns LilyPond file.

(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.

MetricModulation.__str__()

Gets string representation of metric modulation.

>>> metric_modulation = indicatortools.MetricModulation(
...     left_rhythm=Tuplet((2, 3), [Note("c'4")]),
...     right_rhythm=Note("c'4"),
...     )
>>> print(str(metric_modulation))
\markup {
    \scale
        #'(0.75 . 0.75)
        \score
            {
                \new Score \with {
                    \override SpacingSpanner.spacing-increment = #0.5
                    proportionalNotationDuration = ##f
                } <<
                    \new RhythmicStaff \with {
                        \remove Time_signature_engraver
                        \remove Staff_symbol_engraver
                        \override Stem.direction = #up
                        \override Stem.length = #5
                        \override TupletBracket.bracket-visibility = ##t
                        \override TupletBracket.direction = #up
                        \override TupletBracket.padding = #1.25
                        \override TupletBracket.shorten-pair = #'(-1 . -1.5)
                        \override TupletNumber.text = #tuplet-number::calc-fraction-text
                        tupletFullLength = ##t
                    } {
                        \tweak edge-height #'(0.7 . 0)
                        \times 2/3 {
                            c'4
                        }
                    }
                >>
                \layout {
                    indent = #0
                    ragged-right = ##t
                }
            }
    =
    \hspace
        #-0.5
    \scale
        #'(0.75 . 0.75)
        \score
            {
                \new Score \with {
                    \override SpacingSpanner.spacing-increment = #0.5
                    proportionalNotationDuration = ##f
                } <<
                    \new RhythmicStaff \with {
                        \remove Time_signature_engraver
                        \remove Staff_symbol_engraver
                        \override Stem.direction = #up
                        \override Stem.length = #5
                        \override TupletBracket.bracket-visibility = ##t
                        \override TupletBracket.direction = #up
                        \override TupletBracket.padding = #1.25
                        \override TupletBracket.shorten-pair = #'(-1 . -1.5)
                        \override TupletNumber.text = #tuplet-number::calc-fraction-text
                        tupletFullLength = ##t
                    } {
                        c'4
                    }
                >>
                \layout {
                    indent = #0
                    ragged-right = ##t
                }
            }
    }

Returns string.