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

Add MIDI time signatures for "common" and "cut" meterSig #3808

Conversation

fernandoherreradelasheras
Copy link
Contributor

Fix for issue #3807

Copy link
Contributor

@rettinghaus rettinghaus left a 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()) {
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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()

Copy link
Contributor

@lpugin lpugin Oct 4, 2024

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

Copy link
Contributor Author

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).

Copy link
Contributor

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()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

src/doc.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@lpugin lpugin left a 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()

@lpugin lpugin closed this in e44ffcc Oct 8, 2024
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.

4 participants