Spanner¶
- class maelzel.core.symbols.Spanner(kind='start', uuid='', linetype='solid', placement='', color='', anchor=None)[source]¶
Bases:
SymbolA Spanner is a line/curve between two anchors (notes/chords/rests)
Spanners always come in pairs start/end.
Example
>>> from maelzel.core import * >>> from maelzel.core import symbols >>> chain = Chain(["C4:0.5", "D4:1", "E4:0.5"]) >>> slur = symbols.Slur() >>> chain[0].addSymbol(slur) >>> chain[2].addSymbol(slur.makeEndSpanner())
Or you can use the
.bindmethod which is a shortcut:>>> symbols.Slur().bind(chain[0], chain[2])
Attributes Summary
Only one of a given class
Methods Summary
applyToNotation(n, parent)Apply this symbol to the given notation, inplace
applyToPair(start, end)applyToTiedGroup(notations, parent)Apply this symbol to a group of tied notations, inplace.
bind(startobj, endobj)Bind a Spanner to two notes/chords
makePartnerSpanner([anchor])Creates the partner spanner for an already existing spanner
setAnchor(obj)Set the anchor for this spanner.
setPartner(partner)Set the given spanner as the partner spanner of self (and self as partner of other)
Attributes Documentation
- anchor¶
- appliesToRests = True¶
- exclusive = False¶
Only one of a given class
- partner¶
Methods Documentation
- applyToNotation(n, parent)[source]¶
Apply this symbol to the given notation, inplace
- Return type:
None
- applyToTiedGroup(notations, parent)[source]¶
Apply this symbol to a group of tied notations, inplace.
- Return type:
None
- bind(startobj, endobj)[source]¶
Bind a Spanner to two notes/chords
- Parameters:
- Return type:
None
Example
>>> from maelzel.core import * >>> chain = Chain(["4E:1", "4F:1", "4G:1"]) # slur the first two notes of the chain, customizing the line-type >>> Slur(linetype='dashed').bind(chain[0], chain[1]) # The same can be achieved as: >>> chain[0].addSpanner(Slur(linetype='dashed'), chain[1])
- makePartnerSpanner(anchor=None)[source]¶
Creates the partner spanner for an already existing spanner
start and end spanner share the same uuid and have a ref to each other, allowing each of the spanners to access their twin. As each spanner also holds a ref to their anchor, the anchored events can be made aware of each other.
- Parameters:
anchor (
Optional[MEvent]) – the event to which the end spanner is anchored to.- Return type:
Self- Returns:
the created spanner. This is a copy of the start spanner in every way with the only difference that
kind='end'
- setAnchor(obj)[source]¶
Set the anchor for this spanner.
This is called by :meth:
MusicObj.setSymbolor by :meth:Spanner.bindto set the anchor of this spanner. A User should not normally call this method- Parameters:
obj (
MEvent) – the object this spanner is anchored to, either as start or end- Return type:
None