Skip to content

Commit

Permalink
Add Webern, Dormi Jesu
Browse files Browse the repository at this point in the history
Fix problem with corpus paths where filename contains directory name.

Fix repeated words

Fix problem with indexing scores with only unpitched objects

Rename potentially offensive variable name.
  • Loading branch information
mscuthbert committed Jan 2, 2024
1 parent a938a8c commit acdabc2
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 15 deletions.
15 changes: 9 additions & 6 deletions music21/analysis/discrete.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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."
'''
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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."
'''
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion music21/common/pathTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Binary file modified music21/corpus/_metadataCache/core.p.gz
Binary file not shown.
1 change: 1 addition & 0 deletions music21/corpus/corpora.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file not shown.
8 changes: 7 additions & 1 deletion music21/corpus/work.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions music21/features/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 6 additions & 1 deletion music21/metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -2352,7 +2354,7 @@ def _convertValue(uniqueName: str, value: t.Any) -> ValueType:
>>> metadata.Metadata._convertValue('dateCreated', metadata.Text('1938'))
<music21.metadata.primitives.DateSingle 1938/--/-->
>>> metadata.Metadata._convertValue('dateCreated',
... metadata.DateBetween(['1938','1939']))
... metadata.DateBetween(['1938', '1939']))
<music21.metadata.primitives.DateBetween 1938/--/-- to 1939/--/-->
'''
valueType: type[ValueType] | None = properties.UNIQUE_NAME_TO_VALUE_TYPE.get(
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit acdabc2

Please sign in to comment.