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

fix #12971: note collisions in playback #3513

Closed
wants to merge 1 commit into from

Conversation

mirabilos
Copy link
Contributor

MIDI export will still have colliding note if they are in
different staves; same stave is fixed though

@MarcSabatella
Copy link
Contributor

I haven't really analyzed the logic of your fixupMIDI() function, but it appears it would take only O(n) time and not O(n^2), which is good. And in any case it shouldn't affect overall score responsiveness, just the delay when hitting the play button. It should be tested with a reasonably large score. to be sure it isn't too bad. But I think your overall approach is sound.

@Jojo-Schmitz
Copy link
Contributor

There are a couple MIDI tests failing in Travis CI. Well possible that the references need fixing, not the code

if (it->second.type() == ME_NOTEON) {
unsigned short np = nowPlaying[it->second.channel()][it->second.pitch()];
if (it->second.velo() == 0) {
if (np == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too many unneeded braces for my taste

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Some people at work insist on them, but I agree and will remove them (and see after the tests).

Copy link
Contributor

@Jojo-Schmitz Jojo-Schmitz Mar 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And maybe using if ((np == 0) || (--np > 0)) here? Not sure though whether this might undefined behavoir.

Edit: as per https://en.wikipedia.org/wiki/Sequence_point this should be clean, the || is a sequence point.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, okay. I had a few debugging fprintf(stderr, …); in between, which is why I had the separate logic.

@mirabilos
Copy link
Contributor Author

@Jojo-Schmitz style concerns addressed, tests fixed, commits squashed

int _highestChannel = 15;
public:
void fixupMIDI();
void haveChannel(int c) { if (c > _highestChannel) _highestChannel = c; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about the method title. has* prefix is usually used to specify functions checking presence of something like
bool hasValue() or something like that. I would never assume that such methods can assign some values inside.
Maybe, 'setHighestChannel()' is better?

Copy link
Contributor

@Jojo-Schmitz Jojo-Schmitz Mar 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I've stumbled across this too, this is not a getter method as the name suggests, but a setter

@mirabilos
Copy link
Contributor Author

mirabilos commented Mar 6, 2018 via email

MIDI export will still have colliding note if they are in
different staves; same stave is fixed though.

Also adjust MIDI testcases: the reference output did
hardcode the old behaviour of not refcounting.
@mirabilos
Copy link
Contributor Author

@Jojo-Schmitz @anatoly-os renamed

@lasconic
Copy link
Contributor

Let's focus on #3514 since it contains this PR.

@lasconic lasconic closed this Mar 12, 2018
@mirabilos mirabilos deleted the midi-fixes branch March 16, 2018 01:05
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.

None yet

5 participants