Skip to content
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

Missing humdrumPosition in thisSpine.stream.flatten() with root cause analysis #1700

Open
awanger opened this issue Apr 1, 2024 · 1 comment

Comments

@awanger
Copy link

awanger commented Apr 1, 2024

music21 version

9.1.0

Problem summary

Loaded a krn format into music21 and received the following error message:

AttributeError: 'Dynamic' object has no attribute 'humdrumPosition'

Steps to reproduce

from music21 import converter
score = converter.parse('http://kern.ccarh.org/data?l=beethoven/sonatas&file=sonata06-1.krn')

Expected vs. actual behavior

Expecting the Sonata to render but get error message instead.

Root Cause Analysis

After running the debugger, I noticed that when the parse() method from the DynamSpine class is run in line 1445, and when eventC = 'p', then a Dynamic object is created <music21.dynamics.Dynamic p>. This object has a humdrumPosition attribute. But this attribute is removed from the object in line 1811 (del el.humdrumPosition) which is why when trying to access this attribute in line 1947 (prioritiesToSearch[dynamic.humdrumPosition] = dynamic), we receive the error message.

In this particular sonata, I noticed that the dynamic object is the piano marking in the pickup measure. Curiously, if we remove this marking from the .krn file (line 21), then everything works as expected.

To summarize, it is likely that music21 has difficulty parsing dynamic markings found in pickup measures

Miscellaneous Information
Apple M1 Pro
macOS Sonoma 14.3.1

@awanger awanger changed the title Missing humdrumPosition thisSpine.stream.flatten() with root cause analysis Missing humdrumPosition in thisSpine.stream.flatten() with root cause analysis Apr 1, 2024
@gregchapman-dev
Copy link
Contributor

FWIW, there is an alternate Humdrum reader for music21 over in converter21, based on a port of Craig Sapp's humlib (used by Verovio) to Python.

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

No branches or pull requests

2 participants