Skip to content

Find an instrument's names by its class in getAllNamesForInstrument - #2056

Merged
mscuthbert merged 2 commits into
cuthbertLab:masterfrom
float3:instrument-names-by-class
Oct 2, 2026
Merged

mscuthbert merged 2 commits into
cuthbertLab:masterfrom
float3:instrument-names-by-class

Conversation

@float3

@float3 float3 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

getAllNamesForInstrument looked the instrument's instrumentName up among the class names the language tables map to, so it found names only where the two are spelled alike:

>>> instrument.getAllNamesForInstrument(instrument.AcousticBass(), 'english')
{'english': []}

It now uses the nearest class in the instrument's MRO that the tables name, which also covers a renamed instrument (Violin I) and a subclass. A generic Instrument is still found by its name.

AI-assisted (Claude).

getAllNamesForInstrument looked the instrument's display name up among
the class names the language tables map to, so it only found names where
the two are spelled alike -- Flute -- and none for an acoustic bass, whose
class is AcousticBass, or for a violin renamed for its part:

    >>> instrument.getAllNamesForInstrument(instrument.AcousticBass(), 'english')
    {'english': []}

It now uses the nearest class in the instrument's hierarchy that the
tables name, which also covers a subclass of one of music21's classes.
A generic Instrument, whose class the tables do not name, is still
looked up by its name.
@coveralls

coveralls commented Oct 2, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 93.368% (+0.002%) from 93.366% — float3:instrument-names-by-class into cuthbertLab:master

@mscuthbert mscuthbert left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks!

@mscuthbert
mscuthbert merged commit bf6faa5 into cuthbertLab:master Oct 2, 2026
7 checks passed
@float3
float3 deleted the instrument-names-by-class branch October 2, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants