spannertools.MetricGridSpanner

Inheritance diagram of abjad.tools.spannertools.MetricGridSpanner.MetricGridSpanner.MetricGridSpanner

class abjad.tools.spannertools.MetricGridSpanner.MetricGridSpanner.MetricGridSpanner(components=None, meters=None)[source]

Abjad metric grid spanner:

abjad> staff = Staff("c'8 d'8 e'8 f'8 g'8 a'8 b'8 c'8")
abjad> spannertools.MetricGridSpanner(staff.leaves, meters = [(1, 8), (1, 4)])
MetricGridSpanner(c'8, d'8, e'8, f'8, g'8, a'8, b'8, c'8)
abjad> f(staff)
\new Staff {
    \time 1/8
    c'8
    \time 1/4
    d'8
    e'8
    \time 1/8
    f'8
    \time 1/4
    g'8
    a'8
    \time 1/8
    b'8
    \time 1/4
    c'8
}

Format leaves in spanner cyclically with meters.

Return metric grid spanner.

Read-only Properties

MetricGridSpanner.components

Return read-only tuple of components in spanner.

abjad> voice = Voice("c'8 d'8 e'8 f'8")
abjad> spanner = spannertools.Spanner(voice[:2])
abjad> spanner.components
(Note("c'8"), Note("d'8"))

Changed in version 1.1: Now returns an (immutable) tuple instead of a (mutable) list.

Note

Inherited from spannertools.Spanner

MetricGridSpanner.duration_in_seconds

Sum of duration of all leaves in spanner, in seconds.

Note

Inherited from spannertools.Spanner

MetricGridSpanner.leaves

Return read-only tuple of leaves in spanner.

abjad> voice = Voice("c'8 d'8 e'8 f'8")
abjad> spanner = spannertools.Spanner(voice[:2])
abjad> spanner.leaves
(Note("c'8"), Note("d'8"))

Changed in version 1.1: Now returns an (immutable) tuple instead of a (mutable) list.

Note

When dealing with large, complex scores accessing this attribute can take some time. Best to make a local copy with leaves = spanner.leaves first. Or use spanner- specific iteration tools.

Note

Inherited from spannertools.Spanner

MetricGridSpanner.offset

New in version 1.1.

Return read-only reference to spanner offset interface.

Spanner offset interface implements start and stop attributes.

abjad> voice = Voice("c'8 d'8 e'8 f'8")
abjad> spanner = spannertools.Spanner(voice[2:])
abjad> spanner
Spanner(e'8, f'8)
abjad> spanner._offset.start
Offset(1, 4)
abjad> spanner._offset.stop
Offset(1, 2)

Return duration.

Note

Inherited from spannertools.Spanner

MetricGridSpanner.override

LilyPond grob override component plug-in.

Note

Inherited from spannertools.Spanner

MetricGridSpanner.preprolated_duration

Sum of preprolated duration of all components in spanner.

Note

Inherited from spannertools.Spanner

MetricGridSpanner.prolated_duration

Sum of prolated duration of all components in spanner.

Note

Inherited from spannertools.Spanner

MetricGridSpanner.set

LilyPond context setting component plug-in.

Note

Inherited from spannertools.Spanner

MetricGridSpanner.written_duration

Sum of written duration of all components in spanner.

Note

Inherited from spannertools.Spanner

Read/write Properties

MetricGridSpanner.meters[source]

Get metric grid meters:

abjad> staff = Staff("c'8 d'8 e'8 f'8 g'8 a'8 b'8 c'8")
abjad> metric_grid_spanner = spannertools.MetricGridSpanner(staff.leaves, meters = [(1, 8), (1, 4)])
abjad> list(metric_grid_spanner.meters)
[(TimeSignatureMark((1, 8)), 0, False), (TimeSignatureMark((1, 4)), Duration(1, 8), False), (TimeSignatureMark((1, 8)), Duration(3, 8), False), (TimeSignatureMark((1, 4)), Duration(1, 2), False), (TimeSignatureMark((1, 8)), Duration(3, 4), False), (TimeSignatureMark((1, 4)), Duration(7, 8), False)]

Set metric grid meters:

abjad> staff = Staff("c'8 d'8 e'8 f'8 g'8 a'8 b'8 c'8")
abjad> metric_grid_spanner = spannertools.MetricGridSpanner(staff.leaves, meters = [(1, 8), (1, 4)])
abjad> metric_grid_spanner.meters = [Duration(1, 4)]
abjad> list(metric_grid_spanner.meters)
[(TimeSignatureMark((1, 4)), 0, False), (TimeSignatureMark((1, 4)), Duration(1, 4), True), (TimeSignatureMark((1, 4)), Duration(1, 2), True), (TimeSignatureMark((1, 4)), Duration(3, 4), True)]

Set iterable.

Methods

MetricGridSpanner.append(component)

Add component to right of spanner.

abjad> voice = Voice("c'8 d'8 e'8 f'8")
abjad> spanner = spannertools.Spanner(voice[:2])
abjad> spanner
Spanner(c'8, d'8)
abjad> spanner.append(voice[2])
abjad> spanner
Spanner(c'8, d'8, e'8)

Return none.

Note

Inherited from spannertools.Spanner

MetricGridSpanner.append_left(component)

Add component to left of spanner.

abjad> voice = Voice("c'8 d'8 e'8 f'8")
abjad> spanner = spannertools.Spanner(voice[2:])
abjad> spanner
Spanner(e'8, f'8)
abjad> spanner.append_left(voice[1])
abjad> spanner
Spanner(d'8, e'8, f'8)

Return none.

Note

Inherited from spannertools.Spanner

MetricGridSpanner.clear()

Remove all components from spanner:

abjad> voice = Voice("c'8 d'8 e'8 f'8")
abjad> spanner = spannertools.Spanner(voice[:])
abjad> spanner
Spanner(c'8, d'8, e'8, f'8)
abjad> spanner.clear()
abjad> spanner
Spanner()

Return none.

Note

Inherited from spannertools.Spanner

MetricGridSpanner.extend(components)

Add iterable components to right of spanner:

abjad> voice = Voice("c'8 d'8 e'8 f'8")
abjad> spanner = spannertools.Spanner(voice[:2])
abjad> spanner
Spanner(c'8, d'8)
abjad> spanner.extend(voice[2:])
abjad> spanner
Spanner(c'8, d'8, e'8, f'8)

Return none.

Note

Inherited from spannertools.Spanner

MetricGridSpanner.extend_left(components)

Add iterable components to left of spanner:

abjad> voice = Voice("c'8 d'8 e'8 f'8")
abjad> spanner = spannertools.Spanner(voice[2:])
abjad> spanner
Spanner(e'8, f'8)
abjad> spanner.extend_left(voice[:2])
abjad> spanner
Spanner(c'8, d'8, e'8, f'8)

Return none.

Note

Inherited from spannertools.Spanner

MetricGridSpanner.fracture(i, direction='both')

Fracture spanner at direction of component at index i.

Valid values for direction are 'left', 'right' and 'both'.

Return original, left and right spanners.

abjad> voice = Voice("c'8 d'8 e'8 f'8")
abjad> beam = spannertools.BeamSpanner(voice[:])
abjad> beam
BeamSpanner(c'8, d'8, e'8, f'8)
abjad> beam.fracture(1, direction = 'left')
(BeamSpanner(c'8, d'8, e'8, f'8), BeamSpanner(c'8), BeamSpanner(d'8, e'8, f'8))
abjad> print voice.format
\new Voice {
    c'8 [ ]
    d'8 [
    e'8
    f'8 ]
}

Return tuple.

Note

Inherited from spannertools.Spanner

MetricGridSpanner.fuse(spanner)

Fuse contiguous spanners.

Return new spanner.

abjad> voice = Voice("c'8 d'8 e'8 f'8")
abjad> left_beam = spannertools.BeamSpanner(voice[:2])
abjad> right_beam = spannertools.BeamSpanner(voice[2:])
abjad> print voice.format
\new Voice {
    c'8 [
    d'8 ]
    e'8 [
    f'8 ]
}
abjad> left_beam.fuse(right_beam)
[(BeamSpanner(c'8, d'8), BeamSpanner(e'8, f'8), BeamSpanner(c'8, d'8, e'8, f'8))]
abjad> print voice.format
\new Voice {
    c'8 [
    d'8
    e'8
    f'8 ]
}

Todo

Return (immutable) tuple instead of (mutable) list.

Note

Inherited from spannertools.Spanner

MetricGridSpanner.index(component)

Return nonnegative integer index of component in spanner.

abjad> voice = Voice("c'8 d'8 e'8 f'8")
abjad> spanner = spannertools.Spanner(voice[2:])
abjad> spanner
Spanner(e'8, f'8)
abjad> spanner.index(voice[-2])
0

Return nonnegative integer.

Note

Inherited from spannertools.Spanner

MetricGridSpanner.pop()

Remove and return rightmost component in spanner.

abjad> voice = Voice("c'8 d'8 e'8 f'8")
abjad> spanner = spannertools.Spanner(voice[:])
abjad> spanner
Spanner(c'8, d'8, e'8, f'8)
abjad> spanner.pop()
Note("f'8")
abjad> spanner
Spanner(c'8, d'8, e'8)

Return component.

Note

Inherited from spannertools.Spanner

MetricGridSpanner.pop_left()

Remove and return leftmost component in spanner.

abjad> voice = Voice("c'8 d'8 e'8 f'8")
abjad> spanner = spannertools.Spanner(voice[:])
abjad> spanner
Spanner(c'8, d'8, e'8, f'8)
abjad> spanner.pop_left()
Note("c'8")
abjad> spanner
Spanner(d'8, e'8, f'8)

Return component.

Note

Inherited from spannertools.Spanner

MetricGridSpanner.split_on_bar()[source]

Temporarily unavailable.

MetricGridSpanner.splitting_condition(leaf)[source]

User-definable boolean function to determine whether leaf should be split:

abjad> voice = Voice("c'4 r4 c'4")
abjad> f(voice)
\new Voice {
    c'4
    r4
    c'4
}
abjad> def cond(leaf):
...   if not isinstance(leaf, Rest): return True
...   else: return False
abjad> metric_grid_spanner = spannertools.MetricGridSpanner(voice.leaves, [Duration(1, 8)])
abjad> metric_grid_spanner.splitting_condition = cond
abjad> metric_grid_spanner.split_on_bar()
abjad> f(voice)
\new Voice {
    \time 1/8
    c'8 ~
    c'8
    r4
    c'8 ~
    c'8
}

Function defaults to return true.

Special Methods

MetricGridSpanner.__contains__(expr)

Note

Inherited from spannertools.Spanner

MetricGridSpanner.__delattr__()

x.__delattr__(‘name’) <==> del x.name

Note

Inherited from __builtin__.object

MetricGridSpanner.__eq__(arg)

True when id(self) equals id(arg).

Return boolean.

Note

Inherited from abctools.AbjadObject

MetricGridSpanner.__ge__(arg)

Abjad objects by default do not implement this method.

Raise exception.

Note

Inherited from abctools.AbjadObject

MetricGridSpanner.__getitem__(expr)

Note

Inherited from spannertools.Spanner

MetricGridSpanner.__gt__(arg)

Abjad objects by default do not implement this method.

Raise exception

Note

Inherited from abctools.AbjadObject

MetricGridSpanner.__hash__() <==> hash(x)

Note

Inherited from __builtin__.object

MetricGridSpanner.__le__(arg)

Abjad objects by default do not implement this method.

Raise exception.

Note

Inherited from abctools.AbjadObject

MetricGridSpanner.__len__()

Note

Inherited from spannertools.Spanner

MetricGridSpanner.__lt__(other)

Trivial comparison to allow doctests to work.

Note

Inherited from spannertools.Spanner

MetricGridSpanner.__ne__(arg)

True when id(self) does not equal id(arg).

Return boolean.

Note

Inherited from abctools.AbjadObject

MetricGridSpanner.__repr__()

Note

Inherited from spannertools.Spanner

MetricGridSpanner.__setattr__()

x.__setattr__(‘name’, value) <==> x.name = value

Note

Inherited from __builtin__.object

MetricGridSpanner.__str__() <==> str(x)

Note

Inherited from __builtin__.object

Table Of Contents

This Page