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

Cue Frame Refactoring #4069

Merged
merged 8 commits into from
Jul 7, 2021
Merged

Conversation

Holzhaus
Copy link
Member

@Holzhaus Holzhaus commented Jul 7, 2021

This duplicates the Cue related methods in order to support Frame positions. This allows migrating the individual parts of the code individually instead of all at once. The original sample-based methods will be removed in #4061.

@Holzhaus Holzhaus added this to In Progress in Semanting Type Refactoring via automation Jul 7, 2021
@Holzhaus Holzhaus requested a review from uklotzde July 7, 2021 17:31
Copy link
Contributor

@uklotzde uklotzde left a comment

Choose a reason for hiding this comment

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

Some findings

}

TEST_F(AnalyzerSilenceTest, EndToEndToneTrack) {
// Fill the entire buffer with 1 kHz tone
double omega = 2.0 * M_PI * kTonePitchHz / pTrack->getSampleRate();
for (int i = 0; i < nTrackSampleDataLength; i++) {
pTrackSampleData[i] = static_cast<CSAMPLE>(cos(i / kChannelCount * omega));
pTrackSampleData[i] = static_cast<CSAMPLE>(cos(i * kChannelCount * omega));
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks suspicious. Why did the division become a multiplication? And if it is wrong then why does this not affect the result of the test?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, must have been slipped in while I was doing a regex replace and wasn't careful enough.

Copy link
Member Author

Choose a reason for hiding this comment

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

I reverted and amended the original commit. But it makes no difference for the test result.

src/test/analyzersilence_test.cpp Outdated Show resolved Hide resolved
src/test/analyzersilence_test.cpp Outdated Show resolved Hide resolved
src/test/analyzersilence_test.cpp Outdated Show resolved Hide resolved
mixxx::audio::SampleRate sampleRate) {
VERIFY_OR_DEBUG_ASSERT(sampleRate.isValid()) {
return std::nullopt;
}
if (positionSamples == Cue::kNoPosition) {
if (!position.isValid()) {
return std::nullopt;
}
// Try to avoid rounding errors
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this comment still apply? I guess it referred to limiting the number of divisions.

Copy link
Member Author

@Holzhaus Holzhaus Jul 7, 2021

Choose a reason for hiding this comment

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

Ok. I removed the comment. c86cbb6

src/track/cue.h Outdated
void setStartPosition(mixxx::audio::FramePos position);
void setStartPosition(double samplePosition) {
mixxx::audio::FramePos position;
if (samplePosition != Cue::kNoPosition) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not reuse fromEngineSamplePosMaybeInvalid() here and all other legacy adapter functions? This would require a static assertion that Cue::kNoPosition == kLegacyInvalidEnginePosition (which already exists as I just noticed).

Copy link
Member Author

Choose a reason for hiding this comment

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

if (!position.isValid()) {
return {};
}
return {position.toEngineSamplePos()};
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you use fromEngineSamplePosMaybeInvalid() (see below) but not toEngineSamplePosMaybeInvalid() here?

Copy link
Member Author

Choose a reason for hiding this comment

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

@Holzhaus Holzhaus force-pushed the frame-refactor-prerequisites branch from e9d76d8 to 902e4a8 Compare July 7, 2021 22:31
@Holzhaus
Copy link
Member Author

Holzhaus commented Jul 7, 2021

@uklotzde Sorry for the force push, I only reverted the unintended analyzersilencetest changes.

Copy link
Contributor

@uklotzde uklotzde left a comment

Choose a reason for hiding this comment

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

LGTM

@uklotzde uklotzde merged commit 13696bc into mixxxdj:main Jul 7, 2021
Semanting Type Refactoring automation moved this from In Progress to Done Jul 7, 2021
@Holzhaus
Copy link
Member Author

Holzhaus commented Jul 8, 2021

Sorry for the PR flood, but the main reason for adding both FramePos-based and samplepos-based methods was that all changes in related code can be done independently and we can keep each PR reasonably small.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants