-
Notifications
You must be signed in to change notification settings - Fork 405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/figuredbass object #1614
Feature/figuredbass object #1614
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the right track -- some changes requested (and more tests and documentation).
In general, objects do not keep track of what Part they are in; so I'd need a very compelling reason why FiguredBass needs a correspondingPart when ChordSymbols etc. don't.
Thanks!
music21/figuredBass/notation.py
Outdated
prefixes = ['+', '#', '++', '##'] | ||
suffixes = ['\\'] | ||
|
||
modifiersDictXmlToM21 = {'sharp': '#', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent as
modifiersDictXmlToM21 = {
'sharp' :'#',
'flat': 'b',
...etc.
}
so that all keys begin on the same column and have four spaces showing they're inside a top-level dictionary. (same below)
music21/figuredBass/notation.py
Outdated
@@ -189,12 +234,15 @@ def __init__(self, notationColumn=None): | |||
self.origModStrings = None | |||
self.numbers = None | |||
self.modifierStrings = None | |||
self.extenders:list[bool] = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space before list[bool]
music21/figuredBass/notation.py
Outdated
self._parseNotationColumn() | ||
self._translateToLonghand() | ||
|
||
# Convert to convenient notation | ||
self.modifiers = None | ||
self.figures = None | ||
self.figuresFromNotationColumn: list(Figure) = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list[Figure] -- square brackets not parentheses.
music21/figuredBass/notation.py
Outdated
|
||
numbers = tuple(numbers) | ||
modifierStrings = tuple(modifierStrings) | ||
|
||
# extenders come from the optional argument when instantionting the object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo. instantiating.
music21/figuredBass/notation.py
Outdated
# extenders come from the optional argument when instantionting the object. | ||
# If nothing is provided, no extenders will be set. | ||
# Otherwise we have to look if amount of extenders and figure numbers match | ||
# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove blank #
music21/harmony.py
Outdated
self._figs = ','.join(figureString) | ||
else: | ||
self._figs = '' | ||
self._figNotation = notation.Notation(self._figs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs typing.
music21/harmony.py
Outdated
|
||
|
||
def __init__(self, | ||
figureString: str | list[str] | None = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After music21 moved to the world of typing extensions (around v6) figureString should just take a string. If someone wants to pass in a list of figures that can be a different keyword-only argument like figureStrings.
There are lots of cases in the current code that haven't moved to this paradigm because they're grandfathered in, but we're trying to make it so that new code mostly takes one type of object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would then add the two keywords figureString and figureStrings. If nothing at all is handed over, it will result in an empty FiguredBass.
music21/harmony.py
Outdated
def figNotation(self) -> notation.Notation: | ||
return self._figNotation | ||
|
||
@figNotation.setter | ||
def figNotation(self, figs: str | list[str] | None): | ||
self._figNotation = notation.Notation(figs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as noted above, this doesn't pass reflexive setters. (also no abbreviations. This should just be notation
)
Needs docs and tests.
it seems like there should be two sets of properties. One for getting/setting the Notation object, and one for getting/setting the string of figures -- changing one should change the other.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. I'm pushing a proposal.
music21/harmony.py
Outdated
It is created as a representation for <fb> tags in MEI and <figured-bass> tags in MusicXML. | ||
The FiguredBassIndication object derives from the Harmony object and can be used | ||
in the following way: | ||
>>> fb = harmony.FiguredBass('#,6#', correspondingPart='P1') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space before.
music21/harmony.py
Outdated
def __repr__(self): | ||
return f'<{self.__class__.__name__} figures: {self.figNotation.notationColumn} correspondingPart: {self.corresPart}>' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Music21Objects don't define __repr__
just _reprInternal
, which would be just the part from figures: {...}
to the end before >
-- let the Music21Object __repr__
take care of the class name, etc.
Generally the representation just provides the most relevant information, so I think it could just be return self.notation.notationColumn
. in .show('text') it'll be obvious what Part the FiguredBass object belongs to.
Keeping track of the associated bass Note or Pitch object for the figure and the Key object seems like it could be important--since unlike RomanNumerals or ChordSymbols, a FB doesn't make sense without a bass (and unlike ChordSymbols but like RN it doesn't make sense without a Key object). One thing that there are not yet tests on is .pitches -- we need to be able to get reasonable pitches out of the FB object. That's where breaking this PR up into its component parts has helped with the reasoning. There may be parts of the RN code that might be factored out to make more reusable there. Do you mind if I push code to this PR? I think I have an idea of how things may work... |
Sure you can contribute to the PR. It’d be a pleasure.
In general, it would be nice to have a pitch associated with the fb notation. Although I was careful with that, because there might be e.g. a rest with a figure in a score. In these cases the figure might just indicate the sonority, that sounds at a specific point (with the related bass note somewhere else in the score).
I’d like to be able to preserve the possibility to either to have FiguredBass without a bass note explicitly specified or to be able to compute the related note out of a score. Therefore an offset is might be sufficient.
… Am 20.06.2023 um 19:19 schrieb Michael Scott Asato Cuthbert ***@***.***>:
Keeping track of the associated bass Note or Pitch object for the figure and the Key object seems like it could be important--since unlike RomanNumerals or ChordSymbols, a FB doesn't make sense without a bass (and unlike ChordSymbols but like RN it doesn't make sense without a Key object).
One thing that there are not yet tests on is .pitches -- we need to be able to get reasonable pitches out of the FB object. That's where breaking this PR up into its component parts has helped with the reasoning.
There may be parts of the RN code that might be factored out to make more reusable there. Do you mind if I push code to this PR? I think I have an idea of how things may work...
—
Reply to this email directly, view it on GitHub <#1614 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AADOJL7IE7XOPAJ2UH44YXDXMHLRBANCNFSM6AAAAAAZMNEIRU>.
You are receiving this because you authored the thread.
|
yes -- there are definitely cases where the pitch being attached to is other than the one sounding (definitely in the case of 4-3 suspensions, etc.) so that's where a reference to a previous pitch would be helpful. |
I'm a little bit behind w/ other work, so I'll extend work on this into my sabbatical for a little bit (until July 10) -- if we can get this merged by then, I'll continue working on it. |
music21/figuredBass/notation.py
Outdated
extender = self.extenders[i] | ||
else: | ||
extender = False | ||
figure = Figure(number, modifierString, extender) | ||
figure = Figure(number, modifierString) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is immediately wiped out -- mistake? Not tested enough.
Check for what is not being covered by tests when adding new features please.
I'm opening this as a smaller step towards representing and importing figures bass information. PR #1613 is the big PR that is split here into three parts as suggested there.
One of the first things is to add the FiguredBass Object, that stores the information in the score/stream.
I'm comenting on the remarks by mscuthbert:
Done so now.
The Figure init does this now.
I changes the handling of extenders now slightly and decided that they only can be parsed as underscores. Extenders are a rather big problem. For now also the musicxml and mei parser can work with the underscore char.
changed the snake case things
it stores an "original" version with the original values. E. g. a figure number 3 would not be added to a pure '#'
Done
Done
Alright didn't know that. Done.
Done
renamed to "correspondingPart"
Should be solved. Although I'm not sure, if I got your point.
Hope this is going better in this way.