-
Notifications
You must be signed in to change notification settings - Fork 185
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
Add MIDI time signatures for "common" and "cut" meterSig #3808
Add MIDI time signatures for "common" and "cut" meterSig #3808
Conversation
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.
Thanks for this PR, just a little note from my side.
if (meterSig->HasSym() && meterSig->GetSym() != METERSIGN_open) { | ||
midiFile->addTimeSignature(midiTrack, 0, meterSig->GetTotalCount(), meterSig->GetTotalCount()); | ||
} | ||
else if (meterSig->HasCount() && meterSig->HasUnit()) { |
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 think meter.count
and meter.unit
would overrule any written symbol, so it should be two simple if clauses.
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.
Would you want to have both added to the midi file? If not then the two conditions should be flipped.
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 should not have both added, of course. I would say if you have an explicit count and unit, those should be used. If there is no count/unit, then it should be inferred from the symbol, with common-time being 4/4 and cut-time being 2/2.
I am wondering about this duplication:
meterSig->GetTotalCount(), meterSig->GetTotalCount());
the total count is the top number, and but this has nothing to do with the bottom number (the unit), so there seems to be an assumption here which is based on "4/4' and "2/2" having the same number on the top and the bottom. But the top is the count and the bottom is the unit.
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.
Yeah, in the same way that, for common/cut sym, meterSig->HasCount() returns false but meterSig->GetTotalCount() stills gives a valid value (4 or 2), we should do the same for unit and return 4 or 2 when HasUnit() is false. But doing it on GetUnit() would look weird from the semantic point of view... maybe GetEffectiveUnit()? Or maybe GetTop()/GetBottom() / GetNum()/GetDem()
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 can simply have
int countAndUnit = (meterSig->GetSym() == METERSIGN_common) ? 4 : 2;
And use this.
Don't forget to flip the clauses since the priority should be on explicit @unit
and @count
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.
Yeah, my point here was to encapsulate the logic resolving common = 4/4 and cut = 2/2 inside the MeterSig class instead of resolving those details at the document level. Also the ternary operator here will add a 2/2 time signature for a MeterSig with "open" sym (or any other further supported symbol we might introduce).
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.
OK. You can add a MeterSig::GetSymImplicitUnit()
m_midiFile->addTimeSignature( | ||
m_midiTrack, currentTick, meterSig->GetTotalCount(), meterSig->GetTotalCount()); | ||
} | ||
else if (meterSig->HasCount() && meterSig->HasUnit()) { |
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.
same as above
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.
add a MeterSig::GetSymImplicitUnit()
Fix for issue #3807