-
Notifications
You must be signed in to change notification settings - Fork 47
Fix envelope point navigation getting stuck on a point or skipping points when there are multiple points at the same position. #1243
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
Conversation
@LeonarddeR, I'd love a review on this if you have the time, but I totally understand if you don't. I really tried to come up with a simpler or cleaner way to do this, but I just couldn't. Is this readable? Am I missing a simpler approach? Thanks. |
…ints when there are multiple points at the same position.
I will have a look over the weekend. |
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 must admit that this is not the easiest code to read. The most important thing seems to me that it works. That said, could using a random access iterator, just as with MIDI events, improve readability? Or is that a totally wrong way of thinking?
src/envelopeCommands.cpp
Outdated
point -= direction; | ||
} | ||
} | ||
GetEnvelopePointEx(envelope, currentAutomationItem, point, &time, &value, |
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.
It occurs to me that this extra call is superfluous when the call at line 278/279 doesn't result in a skip. is that correct?
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.
You're quite correct. I originally thought that there were code paths that can reach here where the time, etc. hasn't been fetched yet. However, I'm now thinking that might be incorrect, so I might be able to move this inside the if block.
Thanks for the suggestion. I spent some time thinking about this just now, but I don't think a random access iterator will help here. There are a few key differences between envelope points and MIDI events. For envelope points:
|
I'm happy for someone to take a stab at rewriting this if they have a better idea; I'm not particularly fond of this code. That said, I really don't see how I can make this better despite more thinking about it today; I don't think an iterator is going to make the edge cases any simpler, but maybe I'm missing something. I'll merge it for now. |
Fixes #1242.