Layout objects provide models of various forms of page or other musical layouts. Layout objects may be used like other Music21Object and placed on a Stream.
Inherits from: Music21Object, JSONSerializer
Parameters for configuring a page’s layout. – covers both <print new-page> and <page-layout> elements in musicxml
## TODO – make sure that the first pageLayout and systemLayout for each page are working together.
PageLayout objects may be found on Measure or Part Streams.
>>> from music21 import *
>>> pl = layout.PageLayout(pageNumber = 4, leftMargin=234, rightMargin=124, pageHeight=4000, pageWidth=3000, isNew=True)
>>> pl.pageNumber
4
>>> pl.rightMargin
124
>>> pl.leftMargin
234
>>> pl.isNew
True
PageLayout attributes
Attributes without Documentation: rightMargin, isNew, pageHeight, pageNumber, pageWidth, leftMargin
Attributes inherited from Music21Object: classSortOrder, isSpanner, isStream, isVariant, hideObjectOnPrint, groups, id
PageLayout properties
- mx¶
Used for musicxml conversion: Return a mxPrint object for a PageLayout object. General users should not need to call this method.
>>> from music21 import * >>> pl = layout.PageLayout(pageNumber = 5, leftMargin=234, rightMargin=124, pageHeight=4000, pageWidth=3000, isNew=True) >>> mxPrint = pl.mx>>> plAlt = layout.PageLayout() >>> plAlt.mx = mxPrint # transfer >>> plAlt.pageNumber 5 >>> plAlt.leftMargin 234.0 >>> plAlt.rightMargin 124.0 >>> plAlt.pageHeight 4000.0 >>> plAlt.pageWidth 3000.0 >>> plAlt.isNew TrueProperties inherited from Music21Object: activeSite, beat, beatDuration, beatStr, beatStrength, classes, derivationHierarchy, duration, isGrace, measureNumber, offset, priority, seconds
Properties inherited from JSONSerializer: json
PageLayout methods
Methods inherited from Music21Object: searchActiveSiteByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndActiveSite(), freezeIds(), getAllContextsByClass(), getCommonSiteIds(), getCommonSites(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), getSpannerSites(), hasContext(), hasSite(), hasSpannerSite(), hasVariantSite(), isClassOrSubclass(), mergeAttributes(), next(), previous(), purgeLocations(), purgeOrphans(), purgeUndeclaredIds(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()
Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()
Inherits from: Spanner, Music21Object, JSONSerializer
A StaffGroup defines a collection of one or more Parts, specifying that they should be shown together with a bracket, brace, or other symbol, and may have a common name.
>>> from music21 import *
>>> p1 = stream.Part()
>>> p2 = stream.Part()
>>> p1.append(note.WholeNote('C5'))
>>> p1.append(note.WholeNote('D5'))
>>> p2.append(note.WholeNote('C3'))
>>> p2.append(note.WholeNote('D3'))
>>> p3 = stream.Part()
>>> p3.append(note.WholeNote('F#4'))
>>> p3.append(note.WholeNote('G#4'))
>>> s = stream.Score()
>>> s.insert(0, p1)
>>> s.insert(0, p2)
>>> s.insert(0, p3)
>>> staffGroup1 = layout.StaffGroup([p1, p2], name='Marimba', abbreviation='Mba.', symbol='brace')
>>> staffGroup1.barTogether = 'Mensurstrich'
>>> s.insert(0, staffGroup1)
>>> staffGroup2 = layout.StaffGroup([p3], name='Xylophone', abbreviation='Xyl.', symbol='bracket')
>>> s.insert(0, staffGroup2)
>>> s.show()
StaffGroup attributes
Attributes without Documentation: abbreviation, name
Attributes inherited from Spanner: isSpanner, idLocal, completeStatus
Attributes inherited from Music21Object: classSortOrder, isStream, isVariant, hideObjectOnPrint, groups, id
StaffGroup properties
- barTogether¶
Get or set the barTogether value, with either Boolean values or yes or no strings. Or the string ‘Mensurstrich’ which indicates baring between staves but not in staves.
Currently Mensurstrich i
>>> from music21 import * >>> sg = layout.StaffGroup() >>> sg.barTogether = 'yes' >>> sg.barTogether True >>> sg.barTogether = 'Mensurstrich' >>> sg.barTogether 'Mensurstrich'
- symbol¶
Get or set the symbol value, with either Boolean values or yes or no strings.
>>> from music21 import * >>> sg = layout.StaffGroup() >>> sg.symbol = 'Brace' >>> sg.symbol 'brace'Properties inherited from Music21Object: activeSite, beat, beatDuration, beatStr, beatStrength, classes, derivationHierarchy, duration, isGrace, measureNumber, offset, priority, seconds
Properties inherited from JSONSerializer: json
StaffGroup methods
Methods inherited from Spanner: addComponents(), freezeIds(), getComponentIds(), getComponents(), getComponentsByClass(), getDurationBySite(), getDurationSpanBySite(), getFirst(), getLast(), getOffsetSpanBySite(), getOffsetsBySite(), getSpannerStorageId(), hasComponent(), isFirst(), isLast(), purgeLocations(), purgeOrphans(), replaceComponent(), unfreezeIds(), unwrapWeakref(), wrapWeakref()
Methods inherited from Music21Object: searchActiveSiteByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndActiveSite(), getAllContextsByClass(), getCommonSiteIds(), getCommonSites(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), getSpannerSites(), hasContext(), hasSite(), hasSpannerSite(), hasVariantSite(), isClassOrSubclass(), mergeAttributes(), next(), previous(), purgeUndeclaredIds(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), write()
Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()
Inherits from: Music21Object, JSONSerializer
Parameters for configuring a system’s layout.
SystemLayout objects may be found on Measure or Part Streams.
Importantly, if isNew is True then this object represents the start of a new system.
>>> from music21 import *
>>> sl = layout.SystemLayout(leftMargin=234, rightMargin=124, distance=3, isNew=True)
>>> sl.distance
3
>>> sl.rightMargin
124
>>> sl.leftMargin
234
>>> sl.isNew
True
SystemLayout attributes
Attributes without Documentation: distance, rightMargin, isNew, leftMargin
Attributes inherited from Music21Object: classSortOrder, isSpanner, isStream, isVariant, hideObjectOnPrint, groups, id
SystemLayout properties
- mx¶
Return a mxPrint object
>>> from music21 import * >>> sl = layout.SystemLayout(leftmargin=234, rightmargin=124, distance=3, isNew=True) >>> mxPrint = sl.mx >>> slAlt = layout.SystemLayout() >>> slAlt.mx = mxPrint # transfer >>> slAlt.leftMargin 234.0 >>> slAlt.rightMargin 124.0 >>> slAlt.distance 3.0 >>> slAlt.isNew TrueProperties inherited from Music21Object: activeSite, beat, beatDuration, beatStr, beatStrength, classes, derivationHierarchy, duration, isGrace, measureNumber, offset, priority, seconds
Properties inherited from JSONSerializer: json
SystemLayout methods
Methods inherited from Music21Object: searchActiveSiteByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndActiveSite(), freezeIds(), getAllContextsByClass(), getCommonSiteIds(), getCommonSites(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), getSpannerSites(), hasContext(), hasSite(), hasSpannerSite(), hasVariantSite(), isClassOrSubclass(), mergeAttributes(), next(), previous(), purgeLocations(), purgeOrphans(), purgeUndeclaredIds(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()
Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()