gracetools.Grace

Inheritance diagram of abjad.tools.gracetools.Grace.Grace.Grace

class abjad.tools.gracetools.Grace.Grace.Grace(music=None, kind='grace', **kwargs)[source]

Abjad model of grace music:

abjad> voice = Voice("c'8 d'8 e'8 f'8")
abjad> spannertools.BeamSpanner(voice[:])
BeamSpanner(c'8, d'8, e'8, f'8)
abjad> f(voice)
\new Voice {
    c'8 [
    d'8
    e'8
    f'8 ]
}
abjad> grace_notes = [Note("c'16"), Note("d'16")]
abjad> gracetools.Grace(grace_notes, kind = 'grace')(voice[1])
Note("d'8")
abjad> f(voice)
\new Voice {
    c'8 [
    \grace {
        c'16
        d'16
    }
    d'8
    e'8
    f'8 ]
}
abjad> after_grace_notes = [Note("e'16"), Note("f'16")]
abjad> gracetools.Grace(after_grace_notes, kind = 'after')(voice[1])
Note("d'8")
abjad> f(voice)
\new Voice {
    c'8 [
    \grace {
        c'16
        d'16
    }
    \afterGrace
    d'8
    {
        e'16
        f'16
    }
    e'8
    f'8 ]
}

Grace objects are containers you can fill with notes, rests and chords.

Grace containers override the special __call__ method.

Use Grace() to attach grace containers to nongrace notes, rests and chords.

Read-only Properties

Grace.contents_duration

Note

Inherited from containertools.Container

Grace.duration_in_seconds

Note

Inherited from containertools.Container

Grace.format

Read-only LilyPond input format of component.

Note

Inherited from componenttools.Component

Grace.leaves

Read-only tuple of leaves in container:

abjad> container = Container("c'8 d'8 e'8")
abjad> container.leaves
(Note("c'8"), Note("d'8"), Note("e'8"))

Return tuple of zero or more leaves.

Note

Inherited from containertools.Container

Grace.marks

Read-only tuple of marks attached to component.

Note

Inherited from componenttools.Component

Grace.music

Read-only tuple of components in container:

abjad> container = Container("c'8 d'8 e'8")
abjad> container.music
(Note("c'8"), Note("d'8"), Note("e'8"))

Return tuple or zero or more components.

Note

Inherited from containertools.Container

Grace.override

Read-only reference to LilyPond grob override component plug-in.

Note

Inherited from componenttools.Component

Grace.parent

Note

Inherited from componenttools.Component

Grace.preprolated_duration

Note

Inherited from containertools.Container

Grace.prolated_duration

Note

Inherited from componenttools.Component

Grace.prolation

Note

Inherited from componenttools.Component

Grace.set

Read-only reference LilyPond context setting component plug-in.

Note

Inherited from componenttools.Component

Grace.spanners

Read-only reference to unordered set of spanners attached to component.

Note

Inherited from componenttools.Component

Read/write Properties

Grace.is_parallel

Get parallel container:

abjad> container = Container([Voice("c'8 d'8 e'8"), Voice('g4.')])
abjad> f(container)
{
    \new Voice {
        c'8
        d'8
        e'8
    }
    \new Voice {
        g4.
    }
}
abjad> container.is_parallel
False

Return boolean.

Set parallel container:

abjad> container.is_parallel = True
abjad> f(container)
<<
    \new Voice {
        c'8
        d'8
        e'8
    }
    \new Voice {
        g4.
    }
>>

Return none.

Note

Inherited from containertools.Container

Grace.kind[source]

Get kind of grace container:

abjad> staff = Staff("c'8 d'8 e'8 f'8")
abjad> gracetools.Grace([Note("cs'16")], kind = 'grace')(staff[1])
Note("d'8")
abjad> grace_container = staff[1].grace
abjad> grace_container.kind
'grace'

Return string.

Set kind of grace container:

abjad> staff = Staff("c'8 d'8 e'8 f'8")
abjad> gracetools.Grace([Note("cs'16")], kind = 'grace')(staff[1])
Note("d'8")
abjad> grace_container = staff[1].grace
abjad> grace_container.kind = 'acciaccatura'
abjad> grace_container.kind
'acciaccatura'

Set string.

Valid options include 'after', 'grace', 'acciaccatura', 'appoggiatura'.

Methods

Grace.append(component)

Append component to container:

abjad> container = Container("c'8 d'8 e'8")
abjad> beam = spannertools.BeamSpanner(container.music)
abjad> f(container)
{
    c'8 [
    d'8
    e'8 ]
}
abjad> container.append(Note("f'8"))
abjad> f(container)
{
    c'8 [
    d'8
    e'8 ]
    f'8
}

Return none.

Note

Inherited from containertools.Container

Grace.detach()[source]

Detach grace container from leaf:

abjad> staff = Staff("c'8 d'8 e'8 f'8")
abjad> grace_container = gracetools.Grace([Note("cs'16")], kind = 'grace')
abjad> grace_container(staff[1])
Note("d'8")
abjad> f(staff)
\new Staff {
    c'8
    \grace {
        cs'16
    }
    d'8
    e'8
    f'8
}
abjad> grace_container.detach()
Grace()
abjad> f(staff)
\new Staff {
    c'8
    d'8
    e'8
    f'8
}

Return grace container.

Grace.extend(expr)

Extend expr against container:

abjad> container = Container("c'8 d'8 e'8")
abjad> beam = spannertools.BeamSpanner(container.music)
abjad> f(container)
{
    c'8 [
    d'8
    e'8 ]
}
abjad> container.extend([Note("cs'8"), Note("ds'8"), Note("es'8")])
abjad> f(container)
{
    c'8 [
    d'8
    e'8 ]
    cs'8
    ds'8
    es'8
}

Return none.

New in version 2.3: expr may now be a LilyPond input string.

Note

Inherited from containertools.Container

Grace.index(component)

Index component in container:

abjad> container = Container("c'8 d'8 e'8")
abjad> note = container[-1]
abjad> note
Note("e'8")
abjad> container.index(note)
2

Return nonnegative integer.

Note

Inherited from containertools.Container

Grace.insert(i, component)

Insert component in container at index i:

abjad> container = Container("c'8 d'8 e'8")
abjad> beam = spannertools.BeamSpanner(container.music)
abjad> f(container)
{
    c'8 [
    d'8
    e'8 ]
}
abjad> container.insert(1, Note("cs'8"))
abjad> f(container)
{
    c'8 [
    cs'8
    d'8
    e'8 ]
}

Return none.

Note

Inherited from containertools.Container

Grace.pop(i=-1)

Pop component at index i from container:

abjad> container = Container("c'8 d'8 e'8")
abjad> beam = spannertools.BeamSpanner(container.music)
abjad> f(container)
{
    c'8 [
    d'8
    e'8 ]
}
abjad> container.pop(-1)
Note("e'8")
abjad> f(container)
{
    c'8 [
    d'8 ]
}

Return component.

Note

Inherited from containertools.Container

Grace.remove(component)

Remove component from container:

abjad> container = Container("c'8 d'8 e'8")
abjad> beam = spannertools.BeamSpanner(container.music)
abjad> f(container)
{
    c'8 [
    d'8
    e'8 ]
}
abjad> note = container[-1]
abjad> note
Note("e'8")
abjad> container.remove(note)
abjad> f(container)
{
    c'8 [
    d'8 ]
}

Return none.

Note

Inherited from containertools.Container

Special Methods

Grace.__add__(expr)

Concatenate containers self and expr. The operation c = a + b returns a new Container c with the content of both a and b. The operation is non-commutative: the content of the first operand will be placed before the content of the second operand.

Note

Inherited from containertools.Container

Grace.__call__(arg)[source]
Grace.__contains__(expr)

True if expr is in container, otherwise False.

Note

Inherited from containertools.Container

Grace.__delattr__()

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

Note

Inherited from __builtin__.object

Grace.__delitem__(i)

Find component(s) at index or slice ‘i’ in container. Detach component(s) from parentage. Withdraw component(s) from crossing spanners. Preserve spanners that component(s) cover(s).

Note

Inherited from containertools.Container

Grace.__eq__(arg)

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

Return boolean.

Note

Inherited from abctools.AbjadObject

Grace.__ge__(arg)

Abjad objects by default do not implement this method.

Raise exception.

Note

Inherited from abctools.AbjadObject

Grace.__getitem__(i)

Return component at index i in container. Shallow traversal of container for numeric indices only.

Note

Inherited from containertools.Container

Grace.__gt__(arg)

Abjad objects by default do not implement this method.

Raise exception

Note

Inherited from abctools.AbjadObject

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

Note

Inherited from __builtin__.object

Grace.__iadd__(expr)

__iadd__ avoids unnecessary copying of structures.

Note

Inherited from containertools.Container

Grace.__imul__(total)

Multiply contents of container ‘total’ times. Return multiplied container.

Note

Inherited from containertools.Container

Grace.__le__(arg)

Abjad objects by default do not implement this method.

Raise exception.

Note

Inherited from abctools.AbjadObject

Grace.__len__()

Return nonnegative integer number of components in container.

Note

Inherited from containertools.Container

Grace.__lt__(arg)

Abjad objects by default do not implement this method.

Raise exception.

Note

Inherited from abctools.AbjadObject

Grace.__mul__(n)

Note

Inherited from componenttools.Component

Grace.__ne__(arg)

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

Return boolean.

Note

Inherited from abctools.AbjadObject

Grace.__radd__(expr)

Extend container by contents of expr to the right.

Note

Inherited from containertools.Container

Grace.__repr__()[source]
Grace.__rmul__(n)

Note

Inherited from componenttools.Component

Grace.__setattr__()

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

Note

Inherited from __builtin__.object

Grace.__setitem__(i, expr)

Set ‘expr’ in self at nonnegative integer index i. Or, set ‘expr’ in self at slice i. Find spanners that dominate self[i] and children of self[i]. Replace contents at self[i] with ‘expr’. Reattach spanners to new contents. This operation leaves all score trees always in tact.

Note

Inherited from containertools.Container

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

Note

Inherited from __builtin__.object

Table Of Contents

This Page