Closed dotinspiredby closed 2 years ago
Thanks for writing. By analyzing the same stream.Part
twice, you have overwritten the old intervals with the new intervals, if any. Your unwanted result stems from re-analyzing the same part's notes against a different part and only partially overwriting the results due to the rests, giving you left over intervals from the old analysis.
I suggest retrieving the results and clearing the editorial objects before re-analyzing the part, or else making a deep copy.
Reopening to track the possibility of clearing the previous result when re-analyzing.
diff --git a/music21/stream/base.py b/music21/stream/base.py
index 6eefbfc53..9304a7e69 100644
--- a/music21/stream/base.py
+++ b/music21/stream/base.py
@@ -10592,6 +10592,7 @@ class Stream(core.StreamCoreMixin, base.Music21Object):
None
'''
for n in self.notes:
+ n.editorial.pop('harmonicInterval', None)
# get simultaneous elements form other stream
simultEls = cmpStream.getElementsByOffset(self.elementOffset(n),
mustBeginInSpan=False,
attachIntervalsBetweenStreams has always been a bit of a mess -- it was a tool for a specific task that didn't need voices or chords or any other complication -- , but I agree that cleaning editorial first is a good idea.
@jacobtylerwalls Thank you a lot! Your help really made my day!!
@mscuthbert Yes, I was aware that .attachIntervals...> method was not supposed for voices/chords.
Thank you very much once again and wishing you a great day!
music21 version
6.7.1
Dear music21 Team! Recently I found in the Stream method attachIntervalsBetweenStreams some unusual thing. I made a piece of code, which returns a list of the intervals between each Part from the SATB Score, and it happened so that instead of None (in place of the rest) it returns the interval from the neighbour pair of Parts. In particular - here is the fragment of the Score, where Bass line is rested at the offset 4.0, but the method returns somehow the P8, which is evidently from the Tenor-Soprano interval at offset 4.0. Also Maybe there is something unclear for me how attachIntervalsBetweenStreams works, but how is it going the way that the third voice is involved in the interval analysis?
Sorry in advance for the bulky piece of code:) - in fact the entire class ScoreDocument isn't needed, it's just to show how I get the list of Part objects for the interval analysis. And as for __make_interval_list method - there is just some logic for spotting the voice crossing (by searching the "-" in the string name of the interval and removing it). And also what makes it more complicated is the fact that intervals are identified by offsets of the left-hand-side stream, so to get the whole picture I need to run the method twice (for example: Soprano-Tenor, Tenor-Soprano).
I would be so grateful for any help or recommendation!
Steps to reproduce
Tenor-v0 Soprano-v0 [[('m6', 2.0), ('P8', 4.0)]] Soprano-v0 Tenor-v0 [[('m6', 2.0), ('P8', 4.0), ('P8', 6.0)]] Bass-v0 Soprano-v0 [[('P12', 6.0)]] Soprano-v0 Bass-v0 [[('m10', 2.0), ('P8', 4.0), ('P12', 6.0)]] P8 at 4.0 does not exist Bass-v0 Tenor-v0 [[('P5', 0.0), ('P5', 6.0)]] Tenor-v0 Bass-v0 [[('P5', 0.0), ('P5', 2.0), ('P8', 4.0)]] same situation
More information