Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion music21/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
Changing this number invalidates old pickles -- do it if the old pickles create a problem.
'''

__version_info__ = (8, 0, 0, 'a11') # can be 3-tuple or 4+-tuple: (7, 0, 5, 'a2')
__version_info__ = (8, 0, 0, 'a12') # can be 3-tuple or 4+-tuple: (7, 0, 5, 'a2')

v = '.'.join(str(x) for x in __version_info__[0:3])
if len(__version_info__) > 3 and __version_info__[3]: # type: ignore
Expand Down
2 changes: 1 addition & 1 deletion music21/analysis/discrete.py
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@ def countMelodicIntervals(self, sStream, found=None, ignoreDirection=True, ignor

if nNext is not None:
# environLocal.printDebug(['creating interval from notes:', n, nNext, i])
i = interval.notesToInterval(n, nNext)
i = interval.Interval(n, nNext)
if ignoreUnison: # will apply to enharmonic eq unisons
if i.chromatic.semitones == 0:
continue
Expand Down
28 changes: 13 additions & 15 deletions music21/analysis/transposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Copyright: Copyright © 2017 Michael Scott Asato Cuthbert and the music21 Project
# License: BSD, see license.txt
# ------------------------------------------------------------------------------

import typing as t
import unittest

from music21 import common
Expand Down Expand Up @@ -51,27 +51,25 @@ class TranspositionChecker:
<music21.chord.Chord C# E G A#>,
<music21.chord.Chord D F G# B>]
'''
def __init__(self, pitches=None):
if pitches is None:
raise TranspositionException('Must have some input')
if not common.isIterable(pitches):
raise TranspositionException('Must be a list or tuple')
def __init__(self, pitches: t.Iterable[pitch.Pitch] = ()):
if not pitches:
raise TranspositionException(
'Must have at least one element in list'
)
if not common.isIterable(pitches):
raise TranspositionException('Must be a list or tuple')
# p0 = pitches[0]
# if not isinstance(p0, pitch.Pitch):
# raise TranspositionException('List must have pitch objects')
self.pitches = pitches
self.allTranspositions = None
self.allNormalOrders = None
self.distinctNormalOrders = None
self.pitches: t.Iterable[pitch.Pitch] = pitches
self.allTranspositions: t.List = []
self.allNormalOrders: t.List = []
self.distinctNormalOrders: t.List = []

def getTranspositions(self):
# noinspection PyShadowingNames
'''
Gets all 12 transpositions (distinct or otherwise)
Gets all 12 transpositions (distinct or otherwise).

>>> p = [pitch.Pitch('D#')]
>>> tc = analysis.transposition.TranspositionChecker(p)
Expand Down Expand Up @@ -109,7 +107,7 @@ def listNormalOrders(self):
[0, 4, 8], [1, 5, 9], [2, 6, 10], [3, 7, 11],
[0, 4, 8], [1, 5, 9], [2, 6, 10], [3, 7, 11]]
'''
if self.allTranspositions is None:
if not self.allTranspositions:
self.getTranspositions()
allTranspositions = self.allTranspositions
allNormalOrders = []
Expand All @@ -130,7 +128,7 @@ def listDistinctNormalOrders(self):
>>> tc.listDistinctNormalOrders()
[[0, 4, 8], [1, 5, 9], [2, 6, 10], [3, 7, 11]]
'''
if self.allNormalOrders is None:
if not self.allNormalOrders:
self.listNormalOrders()
allNormalOrders = self.allNormalOrders
seen = set()
Expand All @@ -148,7 +146,7 @@ def numDistinctTranspositions(self):
>>> tc.numDistinctTranspositions()
4
'''
if self.distinctNormalOrders is None:
if not self.distinctNormalOrders:
self.listDistinctNormalOrders()
return len(self.distinctNormalOrders)

Expand All @@ -164,7 +162,7 @@ def getChordsOfDistinctTranspositions(self):
<music21.chord.Chord D F# A#>,
<music21.chord.Chord E- G B>]
'''
if self.distinctNormalOrders is None:
if not self.distinctNormalOrders:
self.listDistinctNormalOrders()
distinctNormalOrders = self.distinctNormalOrders
allNormalOrderChords = []
Expand Down
2 changes: 1 addition & 1 deletion music21/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<class 'music21.base.Music21Object'>

>>> music21.VERSION_STR
'8.0.0a11'
'8.0.0a12'

Alternatively, after doing a complete import, these classes are available
under the module "base":
Expand Down
8 changes: 4 additions & 4 deletions music21/braille/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def chordToBraille(music21Chord, descending=True, showOctave=True):
f'Accidental {currentPitch.accidental} of '
+ f'chord {music21Chord} cannot be transcribed to braille.'
)
intervalDistance = interval.notesToInterval(basePitch, currentPitch).generic.undirected
intervalDistance = interval.notesToGeneric(basePitch, currentPitch).undirected
if intervalDistance > 8:
intervalDistance = (intervalDistance - 1) % 7 + 1
if currentPitchIndex == 1:
Expand All @@ -196,8 +196,8 @@ def chordToBraille(music21Chord, descending=True, showOctave=True):
f'Octave {currentPitch.octave} {brailleOctave}')
else:
previousPitch = allPitches[currentPitchIndex - 1]
relativeIntervalDist = interval.notesToInterval(previousPitch,
currentPitch).generic.undirected
relativeIntervalDist = interval.notesToGeneric(previousPitch,
currentPitch).undirected
if relativeIntervalDist >= 8:
brailleOctave = pitchToOctave(currentPitch)
chordTrans.append(brailleOctave)
Expand Down Expand Up @@ -1160,7 +1160,7 @@ def showOctaveWithNote(previousNote, currentNote):
'''
if previousNote is None:
return True
i = interval.notesToInterval(previousNote, currentNote)
i = interval.Interval(previousNote, currentNote)
isSixthOrGreater = i.generic.undirected >= 6
isFourthOrFifth = i.generic.undirected in (4, 5)
sameOctaveAsPrevious = previousNote.octave == currentNote.octave
Expand Down
4 changes: 2 additions & 2 deletions music21/braille/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1059,8 +1059,8 @@ def test_example07_7(self):
bm.makeNotation(inPlace=True, cautionaryNotImmediateRepeat=False)
m = bm.getElementsByClass(stream.Measure)
m[0].pop(0)
m[1].transpose(value='P8', inPlace=True)
m[2].transpose(value='P8', inPlace=True)
m[1].transpose('P8', inPlace=True)
m[2].transpose('P8', inPlace=True)
self.s = bm
self.b = '''
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠼⠙⠦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
Expand Down
18 changes: 9 additions & 9 deletions music21/chord/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2190,7 +2190,7 @@ def hasRepeatedChordStep(self, chordStep, *, testRoot=None):

first = self.intervalFromChordStep(chordStep)
for thisPitch in self.pitches:
thisInterval = interval.notesToInterval(testRoot, thisPitch)
thisInterval = interval.Interval(testRoot, thisPitch)
if thisInterval.diatonic.generic.mod7 == chordStep:
if thisInterval.chromatic.mod12 - first.chromatic.mod12 != 0:
return True
Expand Down Expand Up @@ -2221,7 +2221,7 @@ def intervalFromChordStep(self, chordStep, *, testRoot=None):
if testRoot is None:
raise ChordException('Cannot run intervalFromChordStep without a root')
for thisPitch in self.pitches:
thisInterval = interval.notesToInterval(testRoot, thisPitch)
thisInterval = interval.Interval(testRoot, thisPitch)
if thisInterval.diatonic.generic.mod7 == chordStep:
return thisInterval
return None
Expand Down Expand Up @@ -2447,8 +2447,8 @@ def _findInversion(self, rootPitch: pitch.Pitch) -> int:
tempRootPitch = copy.deepcopy(rootPitch)
tempRootPitch.octave = 2

bassToRoot = interval.notesToInterval(tempBassPitch,
tempRootPitch).generic.simpleDirected
bassToRoot = interval.notesToGeneric(tempBassPitch,
tempRootPitch).simpleDirected
# print('bassToRoot', bassToRoot)
if bassToRoot == 1:
inv = 0
Expand Down Expand Up @@ -2702,7 +2702,7 @@ def isConsonant(self):
>>> c14
<music21.chord.Chord A4 B4>

>>> i14 = interval.notesToInterval(c14.pitches[0], c14.pitches[1])
>>> i14 = interval.Interval(c14.pitches[0], c14.pitches[1])
>>> i14
<music21.interval.Interval M2>

Expand All @@ -2720,7 +2720,7 @@ def isConsonant(self):
c3 = self.closedPosition()
# to get from lowest to highest for P4 protection
c4 = c3.removeRedundantPitches(inPlace=False)
i = interval.notesToInterval(c4.pitches[0], c4.pitches[1])
i = interval.Interval(c4.pitches[0], c4.pitches[1])
return i.isConsonant()
elif len(c2.pitches) == 3:
if ((self.isMajorTriad() is True or self.isMinorTriad() is True)
Expand Down Expand Up @@ -2776,7 +2776,7 @@ def isSeventhOfType(self, intervalArray):
root = self.root()

for thisPitch in self.pitches:
thisInterval = interval.notesToInterval(root, thisPitch)
thisInterval = interval.Interval(root, thisPitch)
if thisInterval.chromatic.mod12 not in intervalArray:
return False
return True
Expand Down Expand Up @@ -3054,7 +3054,7 @@ def isIncompleteMajorTriad(self) -> bool:
return False

for thisPitch in self.pitches:
thisInterval = interval.notesToInterval(self.root(), thisPitch)
thisInterval = interval.Interval(self.root(), thisPitch)
if thisInterval.chromatic.mod12 not in (0, 4):
return False

Expand Down Expand Up @@ -3100,7 +3100,7 @@ def isIncompleteMinorTriad(self) -> bool:
return False

for thisPitch in self.pitches:
thisInterval = interval.notesToInterval(self.root(), thisPitch)
thisInterval = interval.Interval(self.root(), thisPitch)
if thisInterval.chromatic.mod12 not in (0, 3):
return False

Expand Down
4 changes: 2 additions & 2 deletions music21/figuredBass/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ def generateBoogieVamp(blRealization=None, numRepeats=5):
newBassLine.append(sampleScore[1][1]) # Key signature

for n in sampleScore[1].notes:
i = interval.notesToInterval(boogieBassLine[0], n)
i = interval.Interval(boogieBassLine[0], n)
tp = boogieBassLine.transpose(i)
for lyr in n.lyrics:
tp.notes.first().addLyric(lyr.text)
Expand Down Expand Up @@ -483,7 +483,7 @@ def generateTripletBlues(blRealization=None, numRepeats=5): # 12/8

newBassLine = stream.Part()
for n in sampleScore[1].notes:
i = interval.notesToInterval(tripletBassLine[0], n)
i = interval.Interval(tripletBassLine[0], n)
tp = tripletBassLine.transpose(i)
for lyr in n.lyrics:
tp.notes.first().addLyric(lyr.text)
Expand Down
Loading