Table Of Contents

Previous topic

music21.beam

Next topic

music21.common

This Page

music21.clef

This module defines numerous subclasses of Clef, providing object representations for all commonly used clefs. Clef objects are often found within Measure objects.

music21.clef.standardClefFromXN(xnStr)
Returns a Clef object given a string like “G2” or “F4” etc.

Clef

Inherits from: Music21Object

class music21.clef.Clef

Clef attributes

classSortOrder

Property which returns an number (int or otherwise) depending on the class of the Music21Object that represents a priority for an object based on its class alone – used as a tie for stream sorting in case two objects have the same offset and priority. Lower numbers are sorted to the left of higher numbers. For instance, Clef, KeySignature, TimeSignature all come (in that order) before Note. All undefined classes have classSortOrder of 20 – same as note.Note

>>> from music21 import *
>>> tc = clef.TrebleClef()
>>> tc.classSortOrder
0
>>> ks = key.KeySignature(3)
>>> ks.classSortOrder
1
New classes can define their own default classSortOrder
>>> class ExampleClass(base.Music21Object):
...     classSortOrderDefault = 5
...
>>> ec1 = ExampleClass()
>>> ec1.classSortOrder
5

Attributes without Documentation: octaveChange, sign, line

Attributes inherited from Music21Object: id, groups

Clef properties

mx

Given a music21 Clef object, return a MusicXML Clef object. This might be moved only into PitchClef.

>>> from music21 import *
>>> b = clef.GClef()
>>> a = b.mx
>>> a.get('sign')
'G'
>>> b = clef.Treble8vbClef()
>>> b.octaveChange
-1
>>> a = b.mx
>>> a.get('sign')
'G'
>>> a.get('clefOctaveChange')
-1

Properties inherited from Music21Object: beat, beatDuration, beatStr, beatStrength, classes, duration, measureNumberLocal, offset, parent, priority

Clef methods

Methods inherited from Music21Object: searchParentByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndParent(), freezeIds(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), hasContext(), isClass(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()

TrebleClef

Inherits from: GClef, PitchClef, Clef, Music21Object

class music21.clef.TrebleClef
>>> from music21 import *
>>> a = clef.TrebleClef()
>>> a.sign
'G'

BassClef

Inherits from: FClef, PitchClef, Clef, Music21Object

class music21.clef.BassClef
>>> from music21 import *
>>> a = clef.BassClef()
>>> a.sign
'F'

AltoClef

Inherits from: CClef, PitchClef, Clef, Music21Object

class music21.clef.AltoClef
>>> from music21 import *
>>> a = clef.AltoClef()
>>> a.sign
'C'

Bass8vaClef

Inherits from: FClef, PitchClef, Clef, Music21Object

class music21.clef.Bass8vaClef
>>> from music21 import *
>>> a = clef.Bass8vaClef()
>>> a.sign
'F'

Bass8vbClef

Inherits from: FClef, PitchClef, Clef, Music21Object

class music21.clef.Bass8vbClef
>>> from music21 import *
>>> a = clef.Bass8vbClef()
>>> a.sign
'F'
>>> a.octaveChange
-1

CBaritoneClef

Inherits from: CClef, PitchClef, Clef, Music21Object

class music21.clef.CBaritoneClef
>>> from music21 import *
>>> a = clef.CBaritoneClef()
>>> a.sign
'C'
>>> a.line
5

CClef

Inherits from: PitchClef, Clef, Music21Object

class music21.clef.CClef
>>> from music21 import *
>>> a = clef.CClef()
>>> a.sign
'C'

CClef attributes

Attributes without Documentation: lowestLine

Attributes inherited from PitchClef: lilyName

Attributes inherited from Clef: classSortOrder, octaveChange, sign, line

Attributes inherited from Music21Object: id, groups

CClef properties

Properties inherited from PitchClef: lily

Properties inherited from Clef: mx

Properties inherited from Music21Object: beat, beatDuration, beatStr, beatStrength, classes, duration, measureNumberLocal, offset, parent, priority

CClef methods

Methods inherited from Music21Object: searchParentByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndParent(), freezeIds(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), hasContext(), isClass(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()

FBaritoneClef

Inherits from: FClef, PitchClef, Clef, Music21Object

class music21.clef.FBaritoneClef
>>> from music21 import *
>>> a = clef.FBaritoneClef()
>>> a.sign
'F'
>>> a.line
3
>>> b = clef.CBaritoneClef()
>>> a.lowestLine == b.lowestLine
True
>>> a.sign == b.sign
False

FClef

Inherits from: PitchClef, Clef, Music21Object

class music21.clef.FClef
>>> from music21 import *
>>> a = clef.FClef()
>>> a.sign
'F'

FClef attributes

Attributes without Documentation: lowestLine

Attributes inherited from PitchClef: lilyName

Attributes inherited from Clef: classSortOrder, octaveChange, sign, line

Attributes inherited from Music21Object: id, groups

FClef properties

Properties inherited from PitchClef: lily

Properties inherited from Clef: mx

Properties inherited from Music21Object: beat, beatDuration, beatStr, beatStrength, classes, duration, measureNumberLocal, offset, parent, priority

FClef methods

Methods inherited from Music21Object: searchParentByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndParent(), freezeIds(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), hasContext(), isClass(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()

FrenchViolinClef

Inherits from: GClef, PitchClef, Clef, Music21Object

class music21.clef.FrenchViolinClef
>>> from music21 import *
>>> a = clef.FrenchViolinClef()
>>> a.sign
'G'

GClef

Inherits from: PitchClef, Clef, Music21Object

class music21.clef.GClef
>>> from music21 import *
>>> a = clef.GClef()
>>> a.sign
'G'

GClef attributes

Attributes without Documentation: lowestLine

Attributes inherited from PitchClef: lilyName

Attributes inherited from Clef: classSortOrder, octaveChange, sign, line

Attributes inherited from Music21Object: id, groups

GClef properties

Properties inherited from PitchClef: lily

Properties inherited from Clef: mx

Properties inherited from Music21Object: beat, beatDuration, beatStr, beatStrength, classes, duration, measureNumberLocal, offset, parent, priority

GClef methods

Methods inherited from Music21Object: searchParentByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndParent(), freezeIds(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), hasContext(), isClass(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()

GSopranoClef

Inherits from: GClef, PitchClef, Clef, Music21Object

class music21.clef.GSopranoClef
>>> from music21 import *
>>> a = clef.GSopranoClef()
>>> a.sign
'G'

MezzoSopranoClef

Inherits from: CClef, PitchClef, Clef, Music21Object

class music21.clef.MezzoSopranoClef
>>> from music21 import *
>>> a = clef.MezzoSopranoClef()
>>> a.sign
'C'

NoClef

Inherits from: Clef, Music21Object

class music21.clef.NoClef

PercussionClef

Inherits from: Clef, Music21Object

class music21.clef.PercussionClef

PitchClef

Inherits from: Clef, Music21Object

class music21.clef.PitchClef

PitchClef attributes

Attributes without Documentation: lilyName

Attributes inherited from Clef: classSortOrder, octaveChange, sign, line

Attributes inherited from Music21Object: id, groups

PitchClef properties

lily
No documentation.

Properties inherited from Clef: mx

Properties inherited from Music21Object: beat, beatDuration, beatStr, beatStrength, classes, duration, measureNumberLocal, offset, parent, priority

PitchClef methods

Methods inherited from Music21Object: searchParentByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndParent(), freezeIds(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), hasContext(), isClass(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()

SopranoClef

Inherits from: CClef, PitchClef, Clef, Music21Object

class music21.clef.SopranoClef
>>> from music21 import *
>>> a = clef.SopranoClef()
>>> a.sign
'C'

SubBassClef

Inherits from: FClef, PitchClef, Clef, Music21Object

class music21.clef.SubBassClef
>>> from music21 import *
>>> a = clef.SubBassClef()
>>> a.sign
'F'

TabClef

Inherits from: Clef, Music21Object

class music21.clef.TabClef

TenorClef

Inherits from: CClef, PitchClef, Clef, Music21Object

class music21.clef.TenorClef
>>> from music21 import *
>>> a = clef.TenorClef()
>>> a.sign
'C'
>>> a.line
4

Treble8vaClef

Inherits from: TrebleClef, GClef, PitchClef, Clef, Music21Object

class music21.clef.Treble8vaClef
>>> from music21 import *
>>> a = clef.Treble8vaClef()
>>> a.sign
'G'
>>> a.octaveChange
1

Treble8vbClef

Inherits from: TrebleClef, GClef, PitchClef, Clef, Music21Object

class music21.clef.Treble8vbClef
>>> from music21 import *
>>> a = clef.Treble8vbClef()
>>> a.sign
'G'
>>> a.octaveChange
-1