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

avoid confusion between visual waveform samples and frames #12356

Merged
merged 2 commits into from
Nov 26, 2023

Conversation

m0dB
Copy link
Contributor

@m0dB m0dB commented Nov 26, 2023

Avoid confusion between visual waveform samples and frames by better naming and use correct range (was double!)

Continuation of #12205 for simple, filtered and hsv allshader waveform renderers

…naming and use correct range (was double!) for simple, filtered and hsv allshader waveforms
@m0dB m0dB changed the title avoid confusion between visual waveform samples and frames by better … avoid confusion between visual waveform samples and frames Nov 26, 2023
@JoergAtGithub
Copy link
Member

Is this PR ready for merge or work in progress?

@m0dB
Copy link
Contributor Author

m0dB commented Nov 26, 2023

ready for merge

@daschuer
Copy link
Member

I have a review in progress ..


visualIndexStart = std::max(visualIndexStart, 0);
visualIndexStop = std::min(visualIndexStop, dataSize);
const int visualFrameStart = int(xVisualFrame - maxSamplingRange + 0.5);
Copy link
Member

Choose a reason for hiding this comment

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

we prefer static_cast(). Did you consider to use round()?
The same applies to the other waveforms

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i believe this got copied from the legacy waveforms, but I agree. I will replace all this with std::lround

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

const int visualFrameStart = int(xVisualFrame - maxSamplingRange + 0.5);
const int visualFrameStop = int(xVisualFrame + maxSamplingRange + 0.5);

const int visualIndexStart = math_clamp(visualFrameStart * 2, 0, dataSize - 1);
Copy link
Member

Choose a reason for hiding this comment

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

Is -1 correct here, We don't want to swap L and R.
Maybe we should rename dataSize to visualSampleSize or such.

Alternative: Make all frames and ..

      for (int i = visualFrameStart; i < visualFrameStop; i += 2) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well spotted. I will change this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But note that for (int i = visualFrameStart; i < visualFrameStop; i += 2) { is wrong. I added some comments in waveformrenderersimple.cpp to explain everything.

@@ -69,10 +67,10 @@ void WaveformRendererHSV::paintGL() {
const float breadth = static_cast<float>(m_waveformRenderer->getBreadth()) * devicePixelRatio;
const float halfBreadth = breadth / 2.0f;

const float heightFactor = allGain * halfBreadth / 256.f;
const float heightFactor = allGain * halfBreadth / 255.f;
Copy link
Member

Choose a reason for hiding this comment

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

I am in doubt this change is correct. At least 255 it is a "magic number" here.
I think the code would be clearer if e change if we normalize maxAll to 1.0f
What is the maxAll value maximum?

The same applies to the other waveforms.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it because it was 255.f elsewhere. But yes, I do think 255 is correct, it the waveform data filtered members are uint8_t. Shall I change it to const float maxValue = static_cast<float>(numeric_limits<uint8_t>::max()) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@daschuer
Copy link
Member

I think the current state is already an improvement. I have just stumbled over some details that can be improved.
Just give a hint if you have interest to do this additional clean up.

@m0dB
Copy link
Contributor Author

m0dB commented Nov 26, 2023

Yes, I will do the additional clean up.

@m0dB
Copy link
Contributor Author

m0dB commented Nov 26, 2023

I have addressed your comments @daschuer

@daschuer
Copy link
Member

Still works good. Thank you.

@daschuer daschuer merged commit 07ca475 into mixxxdj:2.4 Nov 26, 2023
12 checks passed
@daschuer daschuer added this to the 2.4.0 milestone Nov 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants