This module defines the TimeSignature object, as well as component objects for defining nested metrical structures, MeterTerminal and MeterSequence objects.
Given a list of fractions represented as a list, find the sum
>>> from music21 import *
>>> meter.fractionSum([(3,8), (5,8), (1,8)])
(9, 8)
>>> meter.fractionSum([(1,6), (2,3)])
(5, 6)
>>> meter.fractionSum([(3,4), (1,2)])
(5, 4)
>>> meter.fractionSum([(1,13), (2,17)])
(43, 221)
Given a list of fraction values, compact numerators by sum if denominators are the same
>>> from music21 import *
>>> meter.fractionToSlashMixed([(3, 8), (2, 8), (5, 8), (3, 4), (2, 16), (1, 16), (4, 16)])
[('3+2+5', 8), ('3', 4), ('2+1+4', 16)]
Given a floating point proportional value between 0 and 1, return the best-fit slash-base fraction
>>> from music21 import *
>>> meter.proportionToFraction(.5)
(1, 2)
>>> meter.proportionToFraction(.25)
(1, 4)
>>> meter.proportionToFraction(.75)
(3, 4)
>>> meter.proportionToFraction(.125)
(1, 8)
>>> meter.proportionToFraction(.375)
(3, 8)
>>> meter.proportionToFraction(.625)
(5, 8)
>>> meter.proportionToFraction(.333)
(1, 3)
>>> meter.proportionToFraction(0.83333)
(5, 6)
>>> from music21 import *
>>> meter.slashCompoundToFraction('3/8+2/8')
[(3, 8), (2, 8)]
>>> meter.slashCompoundToFraction('5/8')
[(5, 8)]
>>> meter.slashCompoundToFraction('5/8+2/4+6/8')
[(5, 8), (2, 4), (6, 8)]
Given a mixture if possible meter fraction representations, return a list of pairs. If originally given as a summed numerator; break into separate fractions.
>>> from music21 import *
>>> meter.slashMixedToFraction('3/8+2/8')
([(3, 8), (2, 8)], False)
>>> meter.slashMixedToFraction('3+2/8')
([(3, 8), (2, 8)], True)
>>> meter.slashMixedToFraction('3+2+5/8')
([(3, 8), (2, 8), (5, 8)], True)
>>> meter.slashMixedToFraction('3+2+5/8+3/4')
([(3, 8), (2, 8), (5, 8), (3, 4)], True)
>>> meter.slashMixedToFraction('3+2+5/8+3/4+2+1+4/16')
([(3, 8), (2, 8), (5, 8), (3, 4), (2, 16), (1, 16), (4, 16)], True)
>>> meter.slashMixedToFraction('3+2+5/8+3/4+2+1+4')
...
MeterException: cannot match denominator to numerator in: 3+2+5/8+3/4+2+1+4
>>> from music21 import *
>>> meter.slashToFraction('3/8')
(3, 8)
>>> meter.slashToFraction('7/32')
(7, 32)
Inherits from: Music21Object
TimeSignature 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
- display¶
- A meter sequence is a list of MeterTerminals, or other MeterSequences
- beat¶
- A meter sequence is a list of MeterTerminals, or other MeterSequences
- accent¶
- A meter sequence is a list of MeterTerminals, or other MeterSequences
- beam¶
- A meter sequence is a list of MeterTerminals, or other MeterSequences
Attributes without Documentation: symbolizeDenominator, symbol, summedNumerator, inherited
Attributes inherited from Music21Object: id, groups
TimeSignature properties
- barDuration¶
Return a Duration object equal to the total length of this TimeSignature.
>>> from music21 import * >>> ts = TimeSignature('5/16') >>> ts.barDuration <music21.duration.Duration 1.25>
- beatCount¶
Return the count of beat units, or the number of beats in this TimeSignature
>>> from music21 import * >>> ts = TimeSignature('3/4') >>> ts.beatCount 3
- beatCountName¶
Return the beat count name, or the name given for the number of beat units. For example, 2/4 is duple; 9/4 is triple.
>>> from music21 import * >>> ts = TimeSignature('3/4') >>> ts.beatCountName 'Triple' >>> ts = TimeSignature('6/8') >>> ts.beatCountName 'Duple'
- beatDivisionCount¶
Return the count of background beat units found within one beat, or the number of subdivisions in the beat unit in this TimeSignature.
>>> from music21 import * >>> ts = TimeSignature('3/4') >>> ts.beatDivisionCount 2 >>> ts = TimeSignature('6/8') >>> ts.beatDivisionCount 3 >>> ts = TimeSignature('15/8') >>> ts.beatDivisionCount 3 >>> ts = TimeSignature('3/8') >>> ts.beatDivisionCount 2 >>> ts = TimeSignature('13/8', 13) >>> ts.beatDivisionCount Traceback (most recent call last): TimeSignatureException: cannot determine beat backgrond when each beat is not partitioned
- beatDivisionCountName¶
Return the beat count name, or the name given for the number of beat units. For example, 2/4 is duple; 9/4 is triple.
>>> from music21 import * >>> ts = TimeSignature('3/4') >>> ts.beatDivisionCountName 'Simple' >>> ts = TimeSignature('6/8') >>> ts.beatDivisionCountName 'Compound'
- beatDivisionDurations¶
Return the beat division, or the durations that make up one beat, as a list of Duration objects, if and only if the TimeSignature has a uniform beat division for all beats.
>>> from music21 import * >>> ts = TimeSignature('3/4') >>> ts.beatDivisionDurations [<music21.duration.Duration 0.5>, <music21.duration.Duration 0.5>] >>> ts = TimeSignature('6/8') >>> ts.beatDivisionDurations [<music21.duration.Duration 0.5>, <music21.duration.Duration 0.5>, <music21.duration.Duration 0.5>]
- beatDuration¶
Return a Duration object equal to the beat unit of this Time Signature, if and only if this TimeSignatyure has a uniform beat unit.
>>> from music21 import * >>> ts = meter.TimeSignature('3/4') >>> ts.beatDuration <music21.duration.Duration 1.0> >>> ts = meter.TimeSignature('6/8') >>> ts.beatDuration <music21.duration.Duration 1.5> >>> ts = meter.TimeSignature('7/8') >>> ts.beatDuration <music21.duration.Duration 0.5>
- beatLengthToQuarterLengthRatio¶
>>> from music21 import * >>> a = TimeSignature('3/2') >>> a.beatLengthToQuarterLengthRatio 2.0
- beatSubDivisionDurations¶
Return a subdivision of the beat division, or a list of Duration objects representing each beat division divided by two.
>>> from music21 import * >>> ts = TimeSignature('3/4') >>> ts.beatSubDivisionDurations [<music21.duration.Duration 0.25>, <music21.duration.Duration 0.25>, <music21.duration.Duration 0.25>, <music21.duration.Duration 0.25>] >>> ts = TimeSignature('6/8') >>> ts.beatSubDivisionDurations [<music21.duration.Duration 0.25>, <music21.duration.Duration 0.25>, <music21.duration.Duration 0.25>, <music21.duration.Duration 0.25>, <music21.duration.Duration 0.25>, <music21.duration.Duration 0.25>]
- classification¶
Return the classification of this TimeSignature, such as Simple Triple or Compound Quadruple.
>>> from music21 import * >>> ts = TimeSignature('3/4') >>> ts.classification 'Simple Triple' >>> ts = TimeSignature('6/8') >>> ts.classification 'Compound Duple' >>> ts = TimeSignature('4/32') >>> ts.classification 'Simple Quadruple'
- denominator¶
Return the denominator of the TimeSignature as a number
>>> from music21 import * >>> ts = TimeSignature('3/4') >>> ts.denominator 4
- lily¶
returns the lilypond representation of the timeSignature
>>> from music21 import * >>> a = TimeSignature('3/16') >>> a.lily \time 3/16
- musicxml¶
- Return a complete MusicXML string
- mx¶
Returns a list of one mxTime object. Compound meters are represented as multiple pairs of beat and beat-type elements
>>> from music21 import * >>> a = TimeSignature('3/4') >>> b = a.mx >>> a = TimeSignature('3/4+2/4') >>> b = a.mx
- numerator¶
Return the numerator of the TimeSignature as a number.
>>> from music21 import * >>> ts = TimeSignature('3/4') >>> ts.numerator 3
- quarterLengthToBeatLengthRatio¶
- No documentation.
- totalLength¶
Total length of the TimeSignature, in Quarter Lengths.
>>> from music21 import * >>> ts = TimeSignature('6/8') >>> ts.totalLength 3.0Properties inherited from Music21Object: classes, duration, offset, parent, priority
TimeSignature methods
- getAccent(qLenPos)¶
Return True or False if the qLenPos is at the start of an accent division.
>>> from music21 import * >>> a = TimeSignature('3/4', 3) >>> a.accent.partition([2,1]) >>> a.accent <MeterSequence {2/4+1/4}> >>> a.getAccent(0) True >>> a.getAccent(1) False >>> a.getAccent(2) True
- getAccentWeight(qLenPos, level=0)¶
- Given a qLenPos, return an accent level.
- getBeams(srcList)¶
Given a qLen position and a list of Duration objects, return a list of Beams object. Can alternatively provide a flat stream, from which Durations are extracted. Duration objects are assumed to be adjoining; offsets are not used. This can be modified to take lists of rests and notes Must process a list at time, because we cannot tell when a beam ends unless we see the context of adjoining durations.
>>> from music21 import * >>> a = TimeSignature('2/4', 2) >>> a.beam[0] = a.beam[0].subdivide(2) >>> a.beam[1] = a.beam[1].subdivide(2) >>> a.beam <MeterSequence {{1/8+1/8}+{1/8+1/8}}> >>> b = [duration.Duration('16th')] * 8 >>> c = a.getBeams(b) >>> len(c) == len(b) True >>> print(c) [<music21.beam.Beams <music21.beam.Beam 1/start>/<music21.beam.Beam 2/start>>, <music21.beam.Beams <music21.beam.Beam 1/continue>/<music21.beam.Beam 2/stop>>, <music21.beam.Beams <music21.beam.Beam 1/continue>/<music21.beam.Beam 2/start>>, <music21.beam.Beams <music21.beam.Beam 1/stop>/<music21.beam.Beam 2/stop>>, <music21.beam.Beams <music21.beam.Beam 1/start>/<music21.beam.Beam 2/start>>, <music21.beam.Beams <music21.beam.Beam 1/continue>/<music21.beam.Beam 2/stop>>, <music21.beam.Beams <music21.beam.Beam 1/continue>/<music21.beam.Beam 2/start>>, <music21.beam.Beams <music21.beam.Beam 1/stop>/<music21.beam.Beam 2/stop>>] >>> a = TimeSignature('6/8') >>> b = [duration.Duration('eighth')] * 6 >>> c = a.getBeams(b) >>> print(c) [<music21.beam.Beams <music21.beam.Beam 1/start>>, <music21.beam.Beams <music21.beam.Beam 1/continue>>, <music21.beam.Beams <music21.beam.Beam 1/stop>>, <music21.beam.Beams <music21.beam.Beam 1/start>>, <music21.beam.Beams <music21.beam.Beam 1/continue>>, <music21.beam.Beams <music21.beam.Beam 1/stop>>]
- getBeat(qLenPos)¶
Given a quarterLength position, get the beat, where beats count from 1
>>> from music21 import * >>> a = TimeSignature('3/4', 3) >>> a.getBeat(0) 1 >>> a.getBeat(2.5) 3 >>> a.beat.partition(['3/8', '3/8']) >>> a.getBeat(2.5) 2
- getBeatDepth(qLenPos, align=quantize)¶
Return the number of levels of beat partitioning given a QL into the TimeSignature. Note that by default beat partitioning always has a single, top-level partition. The align parameter is passed to the positionToDepth() method, and can be used to find depths based on start position overlaps.
>>> from music21 import * >>> a = TimeSignature('3/4', 3) >>> a.getBeatDepth(0) 1 >>> a.getBeatDepth(1) 1 >>> a.getBeatDepth(2) 1 >>> b = TimeSignature('3/4', 1) >>> b.beat[0] = b.beat[0].subdivide(3) >>> b.beat[0][0] = b.beat[0][0].subdivide(2) >>> b.beat[0][1] = b.beat[0][1].subdivide(2) >>> b.beat[0][2] = b.beat[0][2].subdivide(2) >>> b.getBeatDepth(0) 3 >>> b.getBeatDepth(.5) 1 >>> b.getBeatDepth(1) 2
- getBeatDuration(qLenPos)¶
Give a quarter length position into this meter, return a Duration object active for the top-level beat. Unlike the music21.meter.TimeSignature.beatDuration parameter, this will work for asymmetrical meters.
>>> from music21 import * >>> ts1 = meter.TimeSignature('3/4') >>> ts1.getBeatDuration(.5) <music21.duration.Duration 1.0> >>> ts1.getBeatDuration(2.5) <music21.duration.Duration 1.0> >>> ts2 = meter.TimeSignature('6/8') >>> ts2.getBeatDuration(2.5) <music21.duration.Duration 1.5> >>> ts3 = meter.TimeSignature(['3/8','2/8']) # will partition as 2 beat >>> ts3.getBeatDuration(.5) <music21.duration.Duration 1.5> >>> ts3.getBeatDuration(1.5) <music21.duration.Duration 1.0>
- getBeatProgress(qLenPos)¶
Given a quarterLength position, get the beat, where beats count from 1, and return the the amount of qLen into this beat the supplied qLenPos is.
>>> from music21 import * >>> a = meter.TimeSignature('3/4', 3) >>> a.getBeatProgress(0) (1, 0) >>> a.getBeatProgress(0.75) (1, 0.75) >>> a.getBeatProgress(2.5) (3, 0.5) >>> a.beat.partition(['3/8', '3/8']) >>> a.getBeatProgress(2.5) (2, 1.0)
- getBeatProportion(qLenPos)¶
Given a quarter length position into the meter, return a numerical progress through the beat (where beats count from one) with a floating-point value between 0 and 1 appended to this value that gives the proportional progress into the beat.
>>> from music21 import * >>> ts1 = meter.TimeSignature('3/4') >>> ts1.getBeatProportion(0) 1.0 >>> ts1.getBeatProportion(0.5) 1.5 >>> ts1.getBeatProportion(1) 2.0 >>> ts3 = meter.TimeSignature(['3/8','2/8']) # will partition as 2 beat >>> ts3.getBeatProportion(.75) 1.5 >>> ts3.getBeatProportion(2) 2.5
- getBeatProportionStr(qLenPos)¶
Return a string presentation of the beat.
>>> from music21 import * >>> ts1 = meter.TimeSignature('3/4') >>> ts1.getBeatProportionStr(0) '1' >>> ts1.getBeatProportionStr(0.5) '1 1/2' >>> ts1.getBeatProportionStr(1) '2' >>> ts3 = meter.TimeSignature(['3/8','2/8']) # will partition as 2 beat >>> ts3.getBeatProportionStr(.75) '1 1/2' >>> ts3.getBeatProportionStr(2) '2 1/2' >>> ts4 = meter.TimeSignature(['6/8']) # will partition as 2 beat
- load(value, partitionRequest=None)¶
- Loading a meter destroys all internal representations
- loadRatio(numerator, denominator, partitionRequest=None)¶
- Convenience method
- quarterPositionToBeat(currentQtrPosition=0)¶
- For backward compatibility. Ultimately, remove.
- ratioEqual(other)¶
- A basic form of comparison; does not determine if any internatl structures are equal; only outermost ratio.
- setAccentWeight(weightList, level=0)¶
Set accent weight, or floating point scalars, for the accent MeterSequence. Provide a list of values; if this list is shorter than the length of the MeterSequence, it will be looped; if this list is longer, only the first relevant value will be used. If the accent MeterSequence is subdivided, the level of depth to set is given by the optional level argument.
>>> from music21 import * >>> a = TimeSignature('4/4', 4) >>> len(a.accent) 4 >>> a.setAccentWeight([.8, .2]) >>> a.getAccentWeight(0) 0.800... >>> a.getAccentWeight(.5) 0.800... >>> a.getAccentWeight(1) 0.200... >>> a.getAccentWeight(2.5) 0.800... >>> a.getAccentWeight(3.5) 0.200...
- setDisplay(value, partitionRequest=None)¶
Set an indendent display value
>>> from music21 import * >>> a = TimeSignature() >>> a.load('3/4') >>> a.setDisplay('2/8+2/8+2/8') >>> a.display <MeterSequence {2/8+2/8+2/8}> >>> a.beam <MeterSequence {{1/8+1/8}+{1/8+1/8}+{1/8+1/8}}> >>> a.beat # a single top-level partition is default for beat <MeterSequence {{1/8+1/8}+{1/8+1/8}+{1/8+1/8}}> >>> a.setDisplay('3/4') >>> a.display <MeterSequence {3/4}>Methods inherited from Music21Object: searchParentByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndParent(), freezeIds(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), hasContext(), isClass(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()
Inherits from: TimeSignature, Music21Object
Inherits from: TimeSignature, Music21Object
Inherits from: MeterTerminal
A meter sequence is a list of MeterTerminals, or other MeterSequences
MeterSequence attributes
Attributes without Documentation: parenthesis, summedNumerator
MeterSequence properties
- denominator¶
- No documentation.
- depth¶
- Return how many unique levels deep this part is This should be optimized to store values unless the structure has changed.
- flat¶
Retrun a new MeterSequence composed of the flattend representation.
>>> from music21 import * >>> a = meter.MeterSequence('3/4', 3) >>> b = a.flat >>> len(b) 3 >>> a[1] = a[1].subdivide(4) >>> b = a.flat >>> len(b) 6 >>> a[1][2] = a[1][2].subdivide(4) >>> a <MeterSequence {1/4+{1/16+1/16+{1/64+1/64+1/64+1/64}+1/16}+1/4}> >>> b = a.flat >>> len(b) 9
- flatWeight¶
- Retrun a list of flat weight valuess
- numerator¶
- No documentation.
- partitionStr¶
Return the number of top-level partitions in this MeterSequence as a string.
>>> from music21 import * >>> ms = meter.MeterSequence('2/4+2/4') >>> ms <MeterSequence {2/4+2/4}> >>> ms.partitionStr 'Duple' >>> ms = meter.MeterSequence('6/4', 6) >>> ms <MeterSequence {1/4+1/4+1/4+1/4+1/4+1/4}> >>> ms.partitionStr 'Sextuple'
- weight¶
>>> from music21 import * >>> a = meter.MeterSequence('3/4') >>> a.partition(3) >>> a.weight = 1 >>> a[0].weight 0.333... >>> b = meter.MeterTerminal('1/4', .25) >>> c = meter.MeterTerminal('1/4', .25) >>> d = meter.MeterSequence([b, c]) >>> d.weight 0.5Properties inherited from MeterTerminal: duration
MeterSequence methods
- getLevel(level=0, flat=True)¶
Return a complete MeterSequence with the same numerator/denominator reationship but that represents any partitions found at the rquested level. A sort of flatness with variable depth.
>>> from music21 import * >>> b = meter.MeterSequence('4/4', 4) >>> b[1] = b[1].subdivide(2) >>> b[3] = b[3].subdivide(2) >>> b[3][0] = b[3][0].subdivide(2) >>> b <MeterSequence {1/4+{1/8+1/8}+1/4+{{1/16+1/16}+1/8}}> >>> b.getLevel(0) <MeterSequence {1/4+1/4+1/4+1/4}> >>> b.getLevel(1) <MeterSequence {1/4+1/8+1/8+1/4+1/8+1/8}> >>> b.getLevel(2) <MeterSequence {1/4+1/8+1/8+1/4+1/16+1/16+1/8}>
- getLevelSpan(level=0)¶
For a given level, return the time span of each terminal or sequnece
>>> from music21 import * >>> b = meter.MeterSequence('4/4', 4) >>> b[1] = b[1].subdivide(2) >>> b[3] = b[3].subdivide(2) >>> b[3][0] = b[3][0].subdivide(2) >>> b <MeterSequence {1/4+{1/8+1/8}+1/4+{{1/16+1/16}+1/8}}> >>> b.getLevelSpan(0) [(0.0, 1.0), (1.0, 2.0), (2.0, 3.0), (3.0, 4.0)] >>> b.getLevelSpan(1) [(0.0, 1.0), (1.0, 1.5), (1.5, 2.0), (2.0, 3.0), (3.0, 3.5), (3.5, 4.0)] >>> b.getLevelSpan(2) [(0.0, 1.0), (1.0, 1.5), (1.5, 2.0), (2.0, 3.0), (3.0, 3.25), (3.25, 3.5), (3.5, 4.0)]
- getLevelWeight(level=0)¶
The weightList is an array of weights found in the components. The MeterSequence has a ._weight attribute, but it is not used here
>>> from music21 import * >>> a = meter.MeterSequence('4/4', 4) >>> a.getLevelWeight() [0.25, 0.25, 0.25, 0.25] >>> b = meter.MeterSequence('4/4', 4) >>> b.getLevelWeight(0) [0.25, 0.25, 0.25, 0.25] >>> b[1] = b[1].subdivide(2) >>> b[3] = b[3].subdivide(2) >>> b.getLevelWeight(0) [0.25, 0.25, 0.25, 0.25] >>> b[3][0] = b[3][0].subdivide(2) >>> b <MeterSequence {1/4+{1/8+1/8}+1/4+{{1/16+1/16}+1/8}}> >>> b.getLevelWeight(0) [0.25, 0.25, 0.25, 0.25] >>> b.getLevelWeight(1) [0.25, 0.125, 0.125, 0.25, 0.125, 0.125] >>> b.getLevelWeight(2) [0.25, 0.125, 0.125, 0.25, 0.0625, 0.0625, 0.125]
- load(value, partitionRequest=None, autoWeight=False, targetWeight=None)¶
This method is called when a MeterSequence is created, or if a MeterSequece is re-set. User can enter a list of values or an abbreviated slash notation. autoWeight, if True, will attempt to set weights. tragetWeight, if given, will be used instead of self.weight
>>> from music21 import * >>> a = meter.MeterSequence() >>> a.load('4/4', 4) >>> str(a) '{1/4+1/4+1/4+1/4}' >>> a.load('4/4', 2) # request 2 beats >>> str(a) '{1/2+1/2}' >>> a.load('5/8', 2) # request 2 beats >>> str(a) '{2/8+3/8}' >>> a.load('5/8+4/4') >>> str(a) '{5/8+4/4}'
- partition(value)¶
Partitioning creates and sets a number of MeterTerminals that make up this MeterSequence. A simple way to partition based on argument time. Single integers are treated as beat counts; lists are treated as numerator lists; MeterSequence objects are call partitionByOther().
>>> from music21 import * >>> a = meter.MeterSequence('5/4+3/8') >>> len(a) 2 >>> b = meter.MeterSequence('13/8') >>> len(b) 1 >>> b.partition(13) >>> len(b) 13 >>> a.partition(b) >>> len(a) 13
- partitionByCount(countRequest, loadDefault=True)¶
This will destroy any structure in the _partition
>>> from music21 import * >>> a = meter.MeterSequence('4/4') >>> a.partitionByCount(2) >>> str(a) '{1/2+1/2}' >>> a.partitionByCount(4) >>> str(a) '{1/4+1/4+1/4+1/4}'
- partitionByList(numeratorList)¶
Given a numerator list, partition MeterSequence inot a new list of MeterTerminals
>>> from music21 import * >>> a = meter.MeterSequence('4/4') >>> a.partitionByList([1,1,1,1]) >>> str(a) '{1/4+1/4+1/4+1/4}' >>> a.partitionByList(['3/4', '1/8', '1/8']) >>> a <MeterSequence {3/4+1/8+1/8}> >>> a.partitionByList(['3/4', '1/8', '5/8']) Traceback (most recent call last): MeterException: Cannot set partition by ['3/4', '1/8', '5/8']
- partitionByOther(other)¶
Set partition to that found in another object
>>> from music21 import * >>> a = meter.MeterSequence('4/4', 4) >>> b = meter.MeterSequence('4/4', 2) >>> a.partitionByOther(b) >>> len(a) 2
- positionToAddress(qLenPos, includeCoincidentBoundaries=False)¶
Give a list of values that show all indices necessary to access the exact terminal at a given qLenPos. The len of the returned list also provides the depth at the specified qLen.
>>> from music21 import * >>> a = meter.MeterSequence('3/4', 3) >>> a[1] = a[1].subdivide(4) >>> a <MeterSequence {1/4+{1/16+1/16+1/16+1/16}+1/4}> >>> len(a) 3 >>> a.positionToAddress(.5) [0] >>> a[0] <MeterTerminal 1/4> >>> a.positionToAddress(1.0) [1, 0] >>> a.positionToAddress(1.5) [1, 2] >>> a[1][2] <MeterTerminal 1/16> >>> a.positionToAddress(1.99) [1, 3] >>> a.positionToAddress(2.5) [2]
- positionToDepth(qLenPos, align=quantize)¶
Given a qLenPos, return the maximum available depth at this position
>>> from music21 import * >>> b = meter.MeterSequence('4/4', 4) >>> b[1] = b[1].subdivide(2) >>> b[3] = b[3].subdivide(2) >>> b[3][0] = b[3][0].subdivide(2) >>> b <MeterSequence {1/4+{1/8+1/8}+1/4+{{1/16+1/16}+1/8}}> >>> b.positionToDepth(0) 3 >>> b.positionToDepth(0.25) # quantizing active by default 3 >>> b.positionToDepth(1) 3 >>> b.positionToDepth(1.5) 2
- positionToIndex(qLenPos, includeCoincidentBoundaries=False)¶
Given a qLen pos (0 through self.duration.quarterLength), return the index of the active MeterTerminal or MeterSequence
>>> from music21 import * >>> a = meter.MeterSequence('4/4') >>> a.positionToIndex(5) ... MeterException: cannot access from qLenPos 5 where total duration is 4.0 >>> a = MeterSequence('4/4') >>> a.positionToIndex(.5) 0 >>> a.positionToIndex(3.5) 0 >>> a.partition(4) >>> a.positionToIndex(0.5) 0 >>> a.positionToIndex(3.5) 3 >>> a.partition([1,2,1]) >>> len(a) 3 >>> a.positionToIndex(2.9) 1
- positionToSpan(qLenPos)¶
Given a lenPos, return the span of the active region. Only applies to the top most level of partitions
>>> from music21 import * >>> a = meter.MeterSequence('3/4', 3) >>> a.positionToSpan(.5) (0, 1.0) >>> a.positionToSpan(1.5) (1.0, 2.0)
- positionToWeight(qLenPos)¶
Given a lenPos, return the weight of the active region. Only applies to the top-most level of partitions
>>> from music21 import * >>> a = meter.MeterSequence('3/4', 3) >>> a.positionToSpan(.5) (0, 1.0) >>> a.positionToSpan(1.5) (1.0, 2.0)
- setLevelWeight(weightList, level=0)¶
The weightList is an array of weights to be applied to a single level of the MeterSequence..
>>> from music21 import * >>> a = meter.MeterSequence('4/4', 4) >>> a.setLevelWeight([1, 2, 3, 4]) >>> a.getLevelWeight() [1, 2, 3, 4] >>> b = meter.MeterSequence('4/4', 4) >>> b.setLevelWeight([2, 3]) >>> b.getLevelWeight(0) [2, 3, 2, 3] >>> b[1] = b[1].subdivide(2) >>> b[3] = b[3].subdivide(2) >>> b.getLevelWeight(0) [2, 3.0, 2, 3.0] >>> b[3][0] = b[3][0].subdivide(2) >>> b <MeterSequence {1/4+{1/8+1/8}+1/4+{{1/16+1/16}+1/8}}> >>> b.getLevelWeight(0) [2, 3.0, 2, 3.0] >>> b.getLevelWeight(1) [2, 1.5, 1.5, 2, 1.5, 1.5] >>> b.getLevelWeight(2) [2, 1.5, 1.5, 2, 0.75, 0.75, 1.5]Methods inherited from MeterTerminal: ratioEqual(), subdivide(), subdivideByCount(), subdivideByList()
A MeterTerminal is a nestable primitive of rhythmic division
>>> from music21 import *
>>> a = meter.MeterTerminal('2/4')
>>> a.duration.quarterLength
2.0
>>> a = meter.MeterTerminal('3/8')
>>> a.duration.quarterLength
1.5
>>> a = meter.MeterTerminal('5/2')
>>> a.duration.quarterLength
10.0
MeterTerminal properties
- denominator¶
- No documentation.
- depth¶
- Return how many levels deep this part is. Depth of a terminal is always 1
- duration¶
barDuration gets or sets a duration value that is equal in length to the totalLength
>>> from music21 import * >>> a = meter.MeterTerminal() >>> a.numerator = 3 >>> a.denominator = 8 >>> d = a.duration >>> d.type 'quarter' >>> d.dots 1 >>> d.quarterLength 1.5
- numerator¶
- No documentation.
- weight¶
- No documentation.
MeterTerminal methods
- ratioEqual(other)¶
Compare the numerator and denominator of another object. Note that these have to be exact matches; 3/4 is not the same as 6/8
>>> from music21 import meter >>> a = meter.MeterTerminal('3/4') >>> b = meter.MeterTerminal('6/4') >>> c = meter.MeterTerminal('2/4') >>> d = meter.MeterTerminal('3/4') >>> a.ratioEqual(b) False >>> a.ratioEqual(c) False >>> a.ratioEqual(d) True
- subdivide(value)¶
- Subdivision takes a MeterTerminal and, making it into a a collection of MeterTerminals, Returns a MeterSequence. This is different than a partitioning a MeterSequence in that this does not happen in place and instead returns a new object. If an integer is provided, assume it is a partition count
- subdivideByCount(countRequest=None)¶
retrun a MeterSequence
>>> from music21 import * >>> a = meter.MeterTerminal('3/4') >>> b = a.subdivideByCount(3) >>> isinstance(b, meter.MeterSequence) True >>> len(b) 3
- subdivideByList(numeratorList)¶
Return a MeterSequence countRequest is within the context of the beatIndex
>>> from music21 import * >>> a = meter.MeterTerminal('3/4') >>> b = a.subdivideByList([1,1,1]) >>> len(b) 3
Inherits from: TimeSignature, Music21Object
NonPowerOfTwoTimeSignature attributes
Attributes inherited from TimeSignature: classSortOrder, symbolizeDenominator, display, beat, symbol, accent, summedNumerator, beam, inherited
Attributes inherited from Music21Object: id, groups
NonPowerOfTwoTimeSignature properties
Properties inherited from TimeSignature: barDuration, beatCount, beatCountName, beatDivisionCount, beatDivisionCountName, beatDivisionDurations, beatDuration, beatLengthToQuarterLengthRatio, beatSubDivisionDurations, classification, denominator, lily, musicxml, mx, numerator, quarterLengthToBeatLengthRatio, totalLength
Properties inherited from Music21Object: classes, duration, offset, parent, priority
NonPowerOfTwoTimeSignature methods
- runTest()¶
- No documentation.
- testBasic()¶
- No documentation.
- testCompound()¶
- No documentation.
- testMeterBeam()¶
- No documentation.
- testSingle()¶
- Need to test direct meter creation w/o stream
Methods inherited from TimeSignature: getAccent(), getAccentWeight(), getBeams(), getBeat(), getBeatDepth(), getBeatDuration(), getBeatProgress(), getBeatProportion(), getBeatProportionStr(), load(), loadRatio(), quarterPositionToBeat(), ratioEqual(), setAccentWeight(), setDisplay()
Methods inherited from Music21Object: searchParentByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndParent(), freezeIds(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), hasContext(), isClass(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()