Skip to content

Stream.measures(): collect MetronomeMark by default#1895

Merged
mscuthbert merged 5 commits into
cuthbertLab:masterfrom
oxygen-dioxide:collect-metronomemark
May 16, 2026
Merged

Stream.measures(): collect MetronomeMark by default#1895
mscuthbert merged 5 commits into
cuthbertLab:masterfrom
oxygen-dioxide:collect-metronomemark

Conversation

@oxygen-dioxide
Copy link
Copy Markdown
Contributor

Summary
Add 'MetronomeMark' to the default collect tuple in Stream.measures().

Motivation
When extracting a region of measures via measures(), the method collects context elements (Clef, TimeSignature, Instrument, KeySignature, etc.) from the surrounding stream so the excerpt is self-contained and playable. However, MetronomeMark was missing from the default collection list.

This means if a tempo indication (e.g. MetronomeMark(number=80)) appears before the extracted region but not inside it, the excerpt will have no tempo marking, causing playback to fall back to a default tempo (often 120 quarter notes per minute in music21's default, but missing the actual intended tempo). Adding 'MetronomeMark' ensures the most recent tempo marking is preserved in the extracted excerpt, matching the behavior of the other context elements already collected.

@oxygen-dioxide oxygen-dioxide marked this pull request as draft May 16, 2026 13:59
Comment thread music21/stream/base.py Outdated
meter.TimeSignature,
instrument.Instrument,
key.KeySignature,
tempo.MetronomeMark
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.

comma at end.

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.

when each has its own line, we do comma dangle. when in line (as above) we don't

@mscuthbert
Copy link
Copy Markdown
Member

i'm +1 on this.

the PR demos that collect should eventually be typed and listed (as classes not strings) in one place (as defaultCollect) but do that later. Get the tests fixed in ASAP and it'll make the next release (today)

@oxygen-dioxide oxygen-dioxide marked this pull request as ready for review May 16, 2026 14:34
@coveralls
Copy link
Copy Markdown

Coverage Status

coverage: 93.067%. remained the same — oxygen-dioxide:collect-metronomemark into cuthbertLab:master

@mscuthbert mscuthbert merged commit e63c5ac into cuthbertLab:master May 16, 2026
8 checks passed
@mscuthbert
Copy link
Copy Markdown
Member

Thanks!

@mscuthbert
Copy link
Copy Markdown
Member

ah -- i did complete the release before bed last night -- i'll make a 10.1.1 tomorrow or the next day. this is good to get in.

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