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

Cache and interpolate resolutions when drawing sample waveforms #7574

Closed

Conversation

sakertooth
Copy link
Contributor

@sakertooth sakertooth commented Nov 11, 2024

This PR is meant to improve performance when drawing sample waveforms by:

  1. Caching multiple waveform resolutions that are decimated in logarithms (currently by powers of 2)
  2. Interpolating between the cached waveform resolutions to get the resolution necessary for the current zoom level (currently done using linear interpolation)

That's about it. I do want to note that when stretching sample clips vertically and using continuous scrolling, there is still a major drop in performance due to the drawing that's being done on the CPU. In the future, we should migrate such drawing to be done by the GPU using something like OpenGL.

Below is an attachment for the results of perf when sampling cycles in the scenario stated above: as shown, most of the overhead in this case lies within the Qt library itself, more specifically its software rasterization that is done on the CPU.
image

I have also omitted RMS calculations from the waveform visualization since most DAWs (and now even Audacity when using default settings) don't consider this, and I wanted to prioritize more performance.

@sakertooth sakertooth changed the title Cache and interpolate when drawing sample waveforms Cache and interpolate resolutions when drawing sample waveforms Nov 11, 2024
@khoidauminh
Copy link
Contributor

khoidauminh commented Nov 11, 2024

Pretty decent performance! Though I'm seeing some bugs

The sample zoom jitter is still there:

Screencast.From.2024-11-11.11-00-59.mp4

Some sample shape artifacts when zooming:

Screencast.From.2024-11-11.11-30-13.mp4

Waveform not being drawn in SlicerT (or you haven't drawn it yet):

ảnh

Incorrect rendering in AFP:

Screencast.From.2024-11-11.11-02-52.mp4

Also iirc, this one also uses more ram, but it's not a big problem.

Have you tested how this compares to my implementation?

@khoidauminh
Copy link
Contributor

If you don't mind, I'll push some fixes

@sakertooth
Copy link
Contributor Author

If you don't mind, I'll push some fixes

Yeah, that's fine with me.

Co-authored-by: Dalton Messmer <[email protected]>
@sakertooth sakertooth marked this pull request as draft November 11, 2024 04:30
@sakertooth
Copy link
Contributor Author

@khoidauminh, I tested your PR. I don't remember the implementation being that good, wow. I think I might close this PR actually and continue contributing to what you have over there. And the ideas we did here are the same, at least in terms of caching, but I'm shocked at how the continuous scrolling is that fast with your PR.

@sakertooth sakertooth closed this Nov 11, 2024
@khoidauminh
Copy link
Contributor

@sakertooth Damn thank you

Though I think my PR is only faster because I clipped rendering to the visible region

This PR did make me realize how messy my code still is lol. I'll see what I can clean up

@sakertooth sakertooth deleted the optimize-sample-visualization branch November 11, 2024 05:21
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.

3 participants