music21.features.native¶
Original music21 feature extractors.
ChordBassMotionFeature¶
- class music21.features.native.ChordBassMotionFeature(dataOrStream=None, **keywords)¶
A twelve element feature that reports the fraction of all chord motion of music21.harmony.Harmony objects that move up by i-half-steps. (a half-step motion down would be stored in i = 11). i = 0 is always 0.0 since consecutive chords on the same pitch are ignored (unless there are 0 or 1 harmonies, in which case it is 1)
Sample test on Dylan’s Blowing In The Wind (not included), showing all motion is 3rds, 6ths, or especially 4ths and 5ths.
s = corpus.parse(‘demos/BlowinInTheWind’) fe = features.native.ChordBassMotionFeature(s) fe.extract().vector
[0.0, 0.0, 0.0, 0.0416…, 0.0416…, 0.166…, 0.0, 0.54166…, 0.0, 0.0, 0.2083… 0.0]
For comparison, the Beatles Here Comes the Sun has more tone motion
- [0.0, 0.05…, 0.14…, 0.03…, 0.06…, 0.3…, 0.008…, 0.303…,
0.0, 0.0, 0.07…, 0.008…]
Post 1990s music has a lot more semitone motion.
ChordBassMotionFeature bases
ChordBassMotionFeature methods
- ChordBassMotionFeature.process()¶
Do processing necessary, storing result in feature.
Methods inherited from FeatureExtractor:
ComposerPopularity¶
- class music21.features.native.ComposerPopularity(dataOrStream=None, **keywords)¶
REMOVED in v7 because Google’s repsonse no longer includes result counts. Empty class still here so that id won’t be reused, but it’s been removed from this module’s list of features.
ComposerPopularity bases
ComposerPopularity methods
Methods inherited from FeatureExtractor:
DiminishedSeventhSimultaneityPrevalence¶
- class music21.features.native.DiminishedSeventhSimultaneityPrevalence(dataOrStream=None, **keywords)¶
Percentage of all simultaneities that are diminished seventh chords.
>>> s = corpus.parse('bwv66.6') >>> fe = features.native.DiminishedSeventhSimultaneityPrevalence(s) >>> fe.extract().vector [0.0]
DiminishedSeventhSimultaneityPrevalence bases
DiminishedSeventhSimultaneityPrevalence methods
- DiminishedSeventhSimultaneityPrevalence.process()¶
Do processing necessary, storing result in feature.
Methods inherited from FeatureExtractor:
DiminishedTriadSimultaneityPrevalence¶
- class music21.features.native.DiminishedTriadSimultaneityPrevalence(dataOrStream=None, **keywords)¶
Percentage of all simultaneities that are diminished triads.
>>> s = corpus.parse('bwv66.6') >>> fe = features.native.DiminishedTriadSimultaneityPrevalence(s) >>> fe.extract().vector [0.019...]
DiminishedTriadSimultaneityPrevalence bases
DiminishedTriadSimultaneityPrevalence methods
- DiminishedTriadSimultaneityPrevalence.process()¶
Do processing necessary, storing result in feature.
Methods inherited from FeatureExtractor:
DominantSeventhSimultaneityPrevalence¶
- class music21.features.native.DominantSeventhSimultaneityPrevalence(dataOrStream=None, **keywords)¶
Percentage of all simultaneities that are dominant seventh.
>>> s = corpus.parse('bwv66.6') >>> fe = features.native.DominantSeventhSimultaneityPrevalence(s) >>> fe.extract().vector [0.076...]
DominantSeventhSimultaneityPrevalence bases
DominantSeventhSimultaneityPrevalence methods
- DominantSeventhSimultaneityPrevalence.process()¶
Do processing necessary, storing result in feature.
Methods inherited from FeatureExtractor:
FirstBeatAttackPrevalence¶
- class music21.features.native.FirstBeatAttackPrevalence(dataOrStream=None, **keywords)¶
NOT IMPLEMENTED!
>>> s = corpus.parse('bwv66.6') >>> fe = features.native.FirstBeatAttackPrevalence(s) >>> f = fe.extract() >>> f.vector [0]
TODO: Implement!
FirstBeatAttackPrevalence bases
FirstBeatAttackPrevalence methods
Methods inherited from FeatureExtractor:
IncorrectlySpelledTriadPrevalence¶
- class music21.features.native.IncorrectlySpelledTriadPrevalence(dataOrStream=None, **keywords)¶
Percentage of all triads that are spelled incorrectly.
example:
Mozart k155 movement 2 has a single instance of an incorrectly spelled triad (m. 17, where the C# of an A-major chord has a lower neighbor B# thus temporarily creating an incorrectly spelled A-minor chord).
We would expect highly chromatic music such as Reger or Wagner to have a higher percentage, or automatically rendered MIDI transcriptions (which don’t distinguish between D# and Eb).
>>> s = corpus.parse('bwv66.6') >>> fe = features.native.IncorrectlySpelledTriadPrevalence(s) >>> fe.extract().vector [0.02...]
IncorrectlySpelledTriadPrevalence bases
IncorrectlySpelledTriadPrevalence methods
- IncorrectlySpelledTriadPrevalence.process()¶
Do processing necessary, storing result in feature.
Methods inherited from FeatureExtractor:
LandiniCadence¶
- class music21.features.native.LandiniCadence(dataOrStream=None, **keywords)¶
Return a boolean if one or more Parts end with a Landini-like cadential figure.
LandiniCadence bases
LandiniCadence methods
- LandiniCadence.process()¶
Do processing necessary, storing result in feature.
Methods inherited from FeatureExtractor:
LanguageFeature¶
- class music21.features.native.LanguageFeature(dataOrStream=None, **keywords)¶
language of text as a number the number is the index of text.LanguageDetector.languageCodes + 1 or 0 if there is no language.
Detect that the language of a Handel aria is Italian.
>>> s = corpus.parse('handel/rinaldo/lascia_chio_pianga') >>> fe = features.native.LanguageFeature(s) >>> fe.extract().vector [3]
LanguageFeature bases
LanguageFeature methods
- LanguageFeature.process()¶
Do processing necessary, storing result in feature.
Methods inherited from FeatureExtractor:
MajorTriadSimultaneityPrevalence¶
- class music21.features.native.MajorTriadSimultaneityPrevalence(dataOrStream=None, **keywords)¶
Percentage of all simultaneities that are major triads.
>>> s = corpus.parse('bwv66.6') >>> fe = features.native.MajorTriadSimultaneityPrevalence(s) >>> fe.extract().vector [0.46...]
MajorTriadSimultaneityPrevalence bases
MajorTriadSimultaneityPrevalence methods
- MajorTriadSimultaneityPrevalence.process()¶
Do processing necessary, storing result in feature.
Methods inherited from FeatureExtractor:
MinorTriadSimultaneityPrevalence¶
- class music21.features.native.MinorTriadSimultaneityPrevalence(dataOrStream=None, **keywords)¶
Percentage of all simultaneities that are minor triads.
>>> s = corpus.parse('bwv66.6') >>> fe = features.native.MinorTriadSimultaneityPrevalence(s) >>> fe.extract().vector # same as major in this work [0.211...]
MinorTriadSimultaneityPrevalence bases
MinorTriadSimultaneityPrevalence methods
- MinorTriadSimultaneityPrevalence.process()¶
Do processing necessary, storing result in feature.
Methods inherited from FeatureExtractor:
MostCommonNoteQuarterLength¶
- class music21.features.native.MostCommonNoteQuarterLength(dataOrStream=None, **keywords)¶
>>> s = corpus.parse('bwv66.6') >>> fe = features.native.MostCommonNoteQuarterLength(s) >>> fe.extract().vector [1.0]
MostCommonNoteQuarterLength bases
MostCommonNoteQuarterLength methods
- MostCommonNoteQuarterLength.process()¶
Do processing necessary, storing result in feature.
Methods inherited from FeatureExtractor:
MostCommonNoteQuarterLengthPrevalence¶
- class music21.features.native.MostCommonNoteQuarterLengthPrevalence(dataOrStream=None, **keywords)¶
>>> s = corpus.parse('bwv66.6') >>> fe = features.native.MostCommonNoteQuarterLengthPrevalence(s) >>> fe.extract().vector [0.60...]
MostCommonNoteQuarterLengthPrevalence bases
MostCommonNoteQuarterLengthPrevalence methods
- MostCommonNoteQuarterLengthPrevalence.process()¶
Do processing necessary, storing result in feature.
Methods inherited from FeatureExtractor:
MostCommonPitchClassSetSimultaneityPrevalence¶
- class music21.features.native.MostCommonPitchClassSetSimultaneityPrevalence(dataOrStream=None, **keywords)¶
Fraction of all pitch class simultaneities that are the most common simultaneity.
>>> s = corpus.parse('bwv66.6') >>> fe = features.native.MostCommonPitchClassSetSimultaneityPrevalence(s) >>> fe.extract().vector [0.134...]
MostCommonPitchClassSetSimultaneityPrevalence bases
MostCommonPitchClassSetSimultaneityPrevalence methods
- MostCommonPitchClassSetSimultaneityPrevalence.process()¶
Do processing necessary, storing result in feature.
Methods inherited from FeatureExtractor:
MostCommonSetClassSimultaneityPrevalence¶
- class music21.features.native.MostCommonSetClassSimultaneityPrevalence(dataOrStream=None, **keywords)¶
Fraction of all set class simultaneities that the most common simultaneity occupies.
>>> s = corpus.parse('bwv66.6') >>> fe = features.native.MostCommonSetClassSimultaneityPrevalence(s) >>> fe.extract().vector [0.653...] >>> s2 = corpus.parse('schoenberg/opus19', 6) >>> fe2 = features.native.MostCommonSetClassSimultaneityPrevalence(s2) >>> fe2.extract().vector [0.228...]
MostCommonSetClassSimultaneityPrevalence bases
MostCommonSetClassSimultaneityPrevalence methods
- MostCommonSetClassSimultaneityPrevalence.process()¶
Do processing necessary, storing result in feature.
Methods inherited from FeatureExtractor:
QualityFeature¶
- class music21.features.native.QualityFeature(dataOrStream=None, **keywords)¶
Extends the jSymbolic QualityFeature to automatically find mode.
Set to 0 if the key signature indicates that a recording is major, set to 1 if it indicates that it is minor. A Music21 addition: if no key mode is found in the piece, or conflicting modes in the keys, analyze the piece to discover what mode it is most likely in.
Example: Handel, Rinaldo Aria (musicxml) is explicitly encoded as being in Major:
>>> s = corpus.parse('handel/rinaldo/lascia_chio_pianga') >>> fe = features.native.QualityFeature(s) >>> f = fe.extract() >>> f.vector [0]
now we will try it with the last movement of Schoenberg’s opus 19 which has no mode explicitly encoded in the musicxml but which our analysis routines believe (having very little to go on) fits the profile of e minor best.
>>> schoenberg19mvmt6 = corpus.parse('schoenberg/opus19', 6) >>> fe2 = features.native.QualityFeature(schoenberg19mvmt6) >>> f2 = fe2.extract() >>> f2.vector [1]
QualityFeature bases
QualityFeature methods
- QualityFeature.process()¶
Do processing necessary, storing result in feature.
Methods inherited from FeatureExtractor:
RangeOfNoteQuarterLengths¶
- class music21.features.native.RangeOfNoteQuarterLengths(dataOrStream=None, **keywords)¶
Difference between the longest and shortest quarter lengths.
>>> s = corpus.parse('bwv66.6') >>> fe = features.native.RangeOfNoteQuarterLengths(s) >>> fe.extract().vector [1.5]
RangeOfNoteQuarterLengths bases
RangeOfNoteQuarterLengths methods
- RangeOfNoteQuarterLengths.process()¶
Do processing necessary, storing result in feature.
Methods inherited from FeatureExtractor:
TonalCertainty¶
- class music21.features.native.TonalCertainty(dataOrStream=None, **keywords)¶
>>> s = corpus.parse('bwv66.6') >>> fe = features.native.TonalCertainty(s) >>> f = fe.extract() >>> f.vector [1.26...]
>>> pitches = [56, 55, 56, 57, 58, 57, 58, 59, 60, 59, 60, 61, 62, 61, ... 62, 63, 64, 63, 64, 65, 66, 65, 66, 67] >>> s = stream.Stream() >>> for pitch in pitches: ... s.append(note.Note(pitch)) >>> features.native.TonalCertainty(s).extract().vector [0.0]
TonalCertainty bases
TonalCertainty methods
- TonalCertainty.process()¶
Do processing necessary, storing result in feature.
Methods inherited from FeatureExtractor:
TriadSimultaneityPrevalence¶
- class music21.features.native.TriadSimultaneityPrevalence(dataOrStream=None, **keywords)¶
Gives the proportion of all simultaneities which form triads (major, minor, diminished, or augmented)
>>> s = corpus.parse('bwv66.6') >>> fe = features.native.TriadSimultaneityPrevalence(s) >>> fe.extract().vector [0.692...] >>> s2 = corpus.parse('schoenberg/opus19', 2) >>> fe2 = features.native.TriadSimultaneityPrevalence(s2) >>> fe2.extract().vector [0.021739...]
TriadSimultaneityPrevalence bases
TriadSimultaneityPrevalence methods
- TriadSimultaneityPrevalence.process()¶
Do processing necessary, storing result in feature.
Methods inherited from FeatureExtractor:
UniqueNoteQuarterLengths¶
- class music21.features.native.UniqueNoteQuarterLengths(dataOrStream=None, **keywords)¶
>>> s = corpus.parse('bwv66.6') >>> fe = features.native.UniqueNoteQuarterLengths(s) >>> fe.extract().vector [3]
UniqueNoteQuarterLengths bases
UniqueNoteQuarterLengths methods
- UniqueNoteQuarterLengths.process()¶
Do processing necessary, storing result in feature.
Methods inherited from FeatureExtractor:
UniquePitchClassSetSimultaneities¶
- class music21.features.native.UniquePitchClassSetSimultaneities(dataOrStream=None, **keywords)¶
Number of unique pitch class simultaneities.
>>> s = corpus.parse('bwv66.6') >>> fe = features.native.UniquePitchClassSetSimultaneities(s) >>> fe.extract().vector [27]
UniquePitchClassSetSimultaneities bases
UniquePitchClassSetSimultaneities methods
- UniquePitchClassSetSimultaneities.process()¶
Do processing necessary, storing result in feature.
Methods inherited from FeatureExtractor:
UniqueSetClassSimultaneities¶
- class music21.features.native.UniqueSetClassSimultaneities(dataOrStream=None, **keywords)¶
Number of unique set class simultaneities.
>>> s = corpus.parse('bwv66.6') >>> fe = features.native.UniqueSetClassSimultaneities(s) >>> fe.extract().vector [14]
UniqueSetClassSimultaneities bases
UniqueSetClassSimultaneities methods
- UniqueSetClassSimultaneities.process()¶
Do processing necessary, storing result in feature.
Methods inherited from FeatureExtractor: