diff --git a/music21/analysis/discrete.py b/music21/analysis/discrete.py index 203dce2bd..e8cd6a99a 100644 --- a/music21/analysis/discrete.py +++ b/music21/analysis/discrete.py @@ -723,7 +723,7 @@ class KrumhanslSchmuckler(KeyWeightKeyAnalysis): Implementation of Krumhansl-Schmuckler/Kessler weightings for Krumhansl-Schmuckler key determination algorithm. - Values from from https://extras.humdrum.org/man/keycor/, which describes these + Values from https://extras.humdrum.org/man/keycor/, which describes these weightings as "Strong tendency to identify the dominant key as the tonic." * Changed in v6.3: it used to be that these were different from the @@ -771,7 +771,7 @@ class AardenEssen(KeyWeightKeyAnalysis): ''' Implementation of Aarden-Essen weightings for Krumhansl-Schmuckler key determination algorithm. - Values from from https://extras.humdrum.org/man/keycor/, which + Values from https://extras.humdrum.org/man/keycor/, which describes these weightings as "Weak tendency to identify the subdominant key as the tonic." (N.B. -- we are not sure exactly where the minor weightings come from, and recommend @@ -816,7 +816,7 @@ class SimpleWeights(KeyWeightKeyAnalysis): Implementation of simple weights by Craig Sapp for Krumhansl-Schmuckler key determination algorithm. - Values from from https://extras.humdrum.org/man/keycor/, which describes + Values from https://extras.humdrum.org/man/keycor/, which describes these weightings as "Performs most consistently with large regions of music, becomes noisier with smaller regions of music." ''' @@ -853,7 +853,7 @@ class BellmanBudge(KeyWeightKeyAnalysis): ''' Implementation of Bellman-Budge weightings for Krumhansl-Schmuckler key determination algorithm. - Values from from https://extras.humdrum.org/man/keycor/, which describes these + Values from https://extras.humdrum.org/man/keycor/, which describes these weightings as "No particular tendencies for confusions with neighboring keys." ''' _DOC_ALL_INHERITED = False @@ -893,7 +893,7 @@ class TemperleyKostkaPayne(KeyWeightKeyAnalysis): Implementation of Temperley-Kostka-Payne weightings for Krumhansl-Schmuckler key determination algorithm. - Values from from https://extras.humdrum.org/man/keycor/, which describes + Values from https://extras.humdrum.org/man/keycor/, which describes these weightings as "Strong tendency to identify the relative major as the tonic in minor keys. Well-balanced for major keys." ''' @@ -980,7 +980,10 @@ def _generateColors(self, numColors=None): if numColors is None: if self._referenceStream is not None: # get total range for entire piece - self.minPitchObj, self.maxPitchObj = self.getPitchSpan(self._referenceStream) + pitchSpanReturn = self.getPitchSpan(self._referenceStream) + if pitchSpanReturn is None: + return + self.minPitchObj, self.maxPitchObj = pitchSpanReturn maxPitch = int(self.maxPitchObj.ps - self.minPitchObj.ps) else: maxPitch = 130 # a large default diff --git a/music21/common/pathTools.py b/music21/common/pathTools.py index d5226495f..f1bb7bb24 100644 --- a/music21/common/pathTools.py +++ b/music21/common/pathTools.py @@ -88,7 +88,7 @@ def getCorpusContentDirs() -> list[str]: 'nottingham-dataset', 'oneills1850', 'palestrina', 'ryansMammoth', 'schoenberg', 'schubert', 'schumann_clara', 'schumann_robert', - 'theoryExercises', 'trecento', 'verdi', 'weber'] + 'theoryExercises', 'trecento', 'verdi', 'weber', 'webern'] Make sure that all corpus data has a directoryInformation tag in CoreCorpus. diff --git a/music21/corpus/_metadataCache/core.p.gz b/music21/corpus/_metadataCache/core.p.gz index 54ceb1960..9794e97d5 100644 Binary files a/music21/corpus/_metadataCache/core.p.gz and b/music21/corpus/_metadataCache/core.p.gz differ diff --git a/music21/corpus/corpora.py b/music21/corpus/corpora.py index 1c3ed99ba..3e658c7d2 100644 --- a/music21/corpus/corpora.py +++ b/music21/corpus/corpora.py @@ -581,6 +581,7 @@ class CoreCorpus(Corpus): ('trecento', 'Fourteenth-Century Italian Music', False), ('verdi', 'Giuseppe Verdi', True), ('weber', 'Carl Maria von Weber', True), + ('webern', 'Anton Webern', True), ) _noCorpus = False diff --git a/music21/corpus/webern/webern_dormi_jesu_op_16_no_2.mxl b/music21/corpus/webern/webern_dormi_jesu_op_16_no_2.mxl new file mode 100644 index 000000000..7a0d9f86d Binary files /dev/null and b/music21/corpus/webern/webern_dormi_jesu_op_16_no_2.mxl differ diff --git a/music21/corpus/work.py b/music21/corpus/work.py index 752985767..b0cfa7a5f 100644 --- a/music21/corpus/work.py +++ b/music21/corpus/work.py @@ -72,7 +72,13 @@ def findWorks(self): for path in works: # split by the composer dir to get relative path # environLocal.printDebug(['dir composer', composerDirectory, path]) - junk, fileStub = str(path).split(self.directoryName) + try: + # only split once in case a composer name appears in the path and filename. + junk, fileStub = str(path).split(self.directoryName, 1) + except ValueError: # too many/few values to unpack + print('Error in processing path:', path, 'directoryName:', self.directoryName) + continue + if fileStub.startswith(os.sep): fileStub = fileStub[len(os.sep):] # break into file components diff --git a/music21/features/base.py b/music21/features/base.py index 795c5499b..e294807e7 100644 --- a/music21/features/base.py +++ b/music21/features/base.py @@ -1258,18 +1258,18 @@ def getIndex(featureString, extractorType=None): from music21.features import jSymbolic, native if extractorType is None or extractorType == 'jsymbolic': - indexCnt = 0 + indexCount = 0 for feature in jSymbolic.featureExtractors: if feature().name == featureString: - return (indexCnt, 'jsymbolic') - indexCnt += 1 + return (indexCount, 'jsymbolic') + indexCount += 1 if extractorType is None or extractorType == 'native': - indexCnt = 0 + indexCount = 0 for feature in native.featureExtractors: if feature().name == featureString: - return (indexCnt, 'native') - indexCnt += 1 + return (indexCount, 'native') + indexCount += 1 return None diff --git a/music21/metadata/__init__.py b/music21/metadata/__init__.py index 1faf327fc..53baf2b0e 100755 --- a/music21/metadata/__init__.py +++ b/music21/metadata/__init__.py @@ -154,6 +154,7 @@ from music21 import defaults from music21 import environment from music21 import exceptions21 +from music21 import interval from music21.metadata import properties from music21.metadata.properties import PropertyDescription @@ -2262,6 +2263,7 @@ def _add(self, name: str, value: t.Any | Iterable[t.Any], isCustom: bool): # add the convertedValues list to the existing list self._contents[name] = prevValues + convertedValues + # noinspection GrazieInspection def _set(self, name: str, value: t.Any | Iterable[t.Any], isCustom: bool): ''' Sets a single item or multiple items with this name, replacing any @@ -2352,7 +2354,7 @@ def _convertValue(uniqueName: str, value: t.Any) -> ValueType: >>> metadata.Metadata._convertValue('dateCreated', metadata.Text('1938')) >>> metadata.Metadata._convertValue('dateCreated', - ... metadata.DateBetween(['1938','1939'])) + ... metadata.DateBetween(['1938', '1939'])) ''' valueType: type[ValueType] | None = properties.UNIQUE_NAME_TO_VALUE_TYPE.get( @@ -2673,6 +2675,9 @@ def update(self, streamObj): self.pitchLowest = analysisObject.minPitchObj.nameWithOctave self.pitchHighest = analysisObject.maxPitchObj.nameWithOctave ambitusInterval = analysisObject.getSolution(streamObj) + if ambitusInterval is None: + ambitusInterval = interval.Interval('P1') + self.ambitus = AmbitusShort(semitones=ambitusInterval.semitones, diatonic=ambitusInterval.diatonic.simpleName, pitchLowest=self.pitchLowest,