This module defines numerous subclasses of Clef, providing object representations for all commonly used clefs. Clef objects are often found within Measure objects.
Returns a Clef object given a string like “G2” or “F4” etc.
>>> from music21 import *
>>> tc = clef.clefFromString("G2")
>>> tc
<music21.clef.TrebleClef>
>>> nonStandard1 = clef.clefFromString("F1")
>>> nonStandard1
<music21.clef.FClef>
>>> nonStandard1.line
1
>>> nonStandard2 = clef.clefFromString("D4")
>>> nonStandard2
<music21.clef.PitchClef>
>>> nonStandard2.sign
'D'
>>> nonStandard2.line
4
>>> tc8vb = clef.clefFromString("G2", -1)
>>> tc8vb
<music21.clef.Treble8vbClef>
>>> tabClef = clef.clefFromString("TAB")
>>> tabClef
<music21.clef.TabClef>
Inherits from: Music21Object
A Clef is a basic music21 object for representing musical clefs (Treble, Bass, etc.)
Some clefs only represent the graphical element of the clef, such as G clef, which is subclassed by TrebleClef() and FrenchViolinClef().
>>> from music21 import *
>>> tc = clef.TrebleClef()
>>> tc.sign
'G'
>>> tc.line
2
Most clefs also have a “lowest note” function which represents the diatonicNoteNum of the note. (Where C4,C#4,C##4,C-4 etc. = 29, all types of D4 = 30, etc.)
>>> tc.lowestLine
31
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 * >>> m21o = base.Music21Object() >>> m21o.classSortOrder 20 >>> tc = clef.TrebleClef() >>> tc.classSortOrder 0>>> ks = key.KeySignature(3) >>> ks.classSortOrder 1New classes can define their own default classSortOrder
>>> class ExampleClass(base.Music21Object): ... classSortOrderDefault = 5 ... >>> ec1 = ExampleClass() >>> ec1.classSortOrder 5Attributes without Documentation: sign, octaveChange, line
Attributes inherited from Music21Object: isSpanner, isStream, isVariant, hideObjectOnPrint, xPosition, sites, groups, id
Clef properties
Properties inherited from Music21Object: classes, fullyQualifiedClasses, activeSite, beat, beatDuration, beatStr, beatStrength, derivationHierarchy, duration, isGrace, measureNumber, offset, priority, seconds
Clef methods
Methods inherited from Music21Object: findAttributeInHierarchy(), getContextAttr(), setContextAttr(), addContext(), addLocation(), getAllContextsByClass(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), getSpannerSites(), hasContext(), hasSite(), hasSpannerSite(), hasVariantSite(), isClassOrSubclass(), mergeAttributes(), next(), previous(), purgeLocations(), purgeOrphans(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unwrapWeakref(), wrapWeakref(), write()
Inherits from: GClef, PitchClef, Clef, Music21Object
>>> from music21 import *
>>> a = clef.TrebleClef()
>>> a.sign
'G'
Inherits from: FClef, PitchClef, Clef, Music21Object
>>> from music21 import *
>>> a = clef.BassClef()
>>> a.sign
'F'
Inherits from: CClef, PitchClef, Clef, Music21Object
>>> from music21 import *
>>> a = clef.AltoClef()
>>> a.sign
'C'
Inherits from: FClef, PitchClef, Clef, Music21Object
>>> from music21 import *
>>> a = clef.Bass8vaClef()
>>> a.sign
'F'
Inherits from: FClef, PitchClef, Clef, Music21Object
>>> from music21 import *
>>> a = clef.Bass8vbClef()
>>> a.sign
'F'
>>> a.octaveChange
-1
Inherits from: CClef, PitchClef, Clef, Music21Object
>>> from music21 import *
>>> a = clef.CBaritoneClef()
>>> a.sign
'C'
>>> a.line
5
Inherits from: PitchClef, Clef, Music21Object
>>> from music21 import *
>>> a = clef.CClef()
>>> a.sign
'C'
CClef attributes
Attributes without Documentation: lowestLine
Attributes inherited from Clef: classSortOrder, sign, octaveChange, line
Attributes inherited from Music21Object: isSpanner, isStream, isVariant, hideObjectOnPrint, xPosition, sites, groups, id
CClef properties
Properties inherited from Music21Object: classes, fullyQualifiedClasses, activeSite, beat, beatDuration, beatStr, beatStrength, derivationHierarchy, duration, isGrace, measureNumber, offset, priority, seconds
CClef methods
Methods inherited from Music21Object: findAttributeInHierarchy(), getContextAttr(), setContextAttr(), addContext(), addLocation(), getAllContextsByClass(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), getSpannerSites(), hasContext(), hasSite(), hasSpannerSite(), hasVariantSite(), isClassOrSubclass(), mergeAttributes(), next(), previous(), purgeLocations(), purgeOrphans(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unwrapWeakref(), wrapWeakref(), write()
Inherits from: FClef, PitchClef, Clef, Music21Object
>>> 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
Inherits from: PitchClef, Clef, Music21Object
>>> from music21 import *
>>> a = clef.FClef()
>>> a.sign
'F'
FClef attributes
Attributes without Documentation: lowestLine
Attributes inherited from Clef: classSortOrder, sign, octaveChange, line
Attributes inherited from Music21Object: isSpanner, isStream, isVariant, hideObjectOnPrint, xPosition, sites, groups, id
FClef properties
Properties inherited from Music21Object: classes, fullyQualifiedClasses, activeSite, beat, beatDuration, beatStr, beatStrength, derivationHierarchy, duration, isGrace, measureNumber, offset, priority, seconds
FClef methods
Methods inherited from Music21Object: findAttributeInHierarchy(), getContextAttr(), setContextAttr(), addContext(), addLocation(), getAllContextsByClass(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), getSpannerSites(), hasContext(), hasSite(), hasSpannerSite(), hasVariantSite(), isClassOrSubclass(), mergeAttributes(), next(), previous(), purgeLocations(), purgeOrphans(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unwrapWeakref(), wrapWeakref(), write()
Inherits from: GClef, PitchClef, Clef, Music21Object
>>> from music21 import *
>>> a = clef.FrenchViolinClef()
>>> a.sign
'G'
Inherits from: PitchClef, Clef, Music21Object
>>> from music21 import *
>>> a = clef.GClef()
>>> a.sign
'G'
GClef attributes
Attributes without Documentation: lowestLine
Attributes inherited from Clef: classSortOrder, sign, octaveChange, line
Attributes inherited from Music21Object: isSpanner, isStream, isVariant, hideObjectOnPrint, xPosition, sites, groups, id
GClef properties
Properties inherited from Music21Object: classes, fullyQualifiedClasses, activeSite, beat, beatDuration, beatStr, beatStrength, derivationHierarchy, duration, isGrace, measureNumber, offset, priority, seconds
GClef methods
Methods inherited from Music21Object: findAttributeInHierarchy(), getContextAttr(), setContextAttr(), addContext(), addLocation(), getAllContextsByClass(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), getSpannerSites(), hasContext(), hasSite(), hasSpannerSite(), hasVariantSite(), isClassOrSubclass(), mergeAttributes(), next(), previous(), purgeLocations(), purgeOrphans(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unwrapWeakref(), wrapWeakref(), write()
Inherits from: GClef, PitchClef, Clef, Music21Object
>>> from music21 import *
>>> a = clef.GSopranoClef()
>>> a.sign
'G'
Inherits from: CClef, PitchClef, Clef, Music21Object
>>> from music21 import *
>>> a = clef.MezzoSopranoClef()
>>> a.sign
'C'
Inherits from: Clef, Music21Object
represents the absence of a Clef.
Inherits from: Clef, Music21Object
represents a Percussion clef.
Inherits from: Clef, Music21Object
superclass for all other clef subclasses.
Inherits from: CClef, PitchClef, Clef, Music21Object
>>> from music21 import *
>>> a = clef.SopranoClef()
>>> a.sign
'C'
Inherits from: FClef, PitchClef, Clef, Music21Object
An F clef on the top line.
>>> from music21 import *
>>> a = clef.SubBassClef()
>>> a.sign
'F'
Inherits from: Clef, Music21Object
represents a Tablature clef (not used).
Inherits from: CClef, PitchClef, Clef, Music21Object
>>> from music21 import *
>>> a = clef.TenorClef()
>>> a.sign
'C'
>>> a.line
4
Inherits from: TrebleClef, GClef, PitchClef, Clef, Music21Object
>>> from music21 import *
>>> a = clef.Treble8vaClef()
>>> a.sign
'G'
>>> a.octaveChange
1
Inherits from: TrebleClef, GClef, PitchClef, Clef, Music21Object
>>> from music21 import *
>>> a = clef.Treble8vbClef()
>>> a.sign
'G'
>>> a.octaveChange
-1