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

Fix: [Spectrogram] fix cropping and scaling issues #3796

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jonom
Copy link

@jonom jonom commented Jul 22, 2024

Short description

Resolves #3663, #3140

Implementation details

I've attempted to address some issues with the spectrogram rendering creating an image of the wrong height for the target container, causing it to be too tall or short to fill the area, and meaning the frequency labels do not line up with data in the image. There are some magic numbers in here (E.g. division by 2 or 4) I don't understand so appreciate if someone else can vet this!

(Marked as draft for now as I'm running tests locally but it's taking quite a while.)

Separate to this I've implemented some caching of the result of getFrequencies() as well as the rendered bitmaps as this can be quite slow, and for my use case we allow zooming in and out so I wanted to speed up the rendering. If this is something you'd like included I can add to this PR or open another one later.

How to test it

Screenshots

Checklist

  • This PR is covered by e2e tests
  • It introduces no breaking API changes

@katspaugh
Copy link
Owner

@jonom thanks for the PR! How did your tests go, did it solve those issues for you?

@jonom
Copy link
Author

jonom commented Aug 9, 2024

I'm not exactly sure how the e2e tests are supposed to be ran - after a while I worked out I could run them manually, but I didn't see snapshots to compare with expected results.

One thing I have found since is that setting sampleRate on the ws instance doesn't seem to affect rendering, except that if it's too small, the upper range of the spectrogram may be missing. So I've been setting it to 88200 and then it seems to always work 🤷‍♂️

@katspaugh
Copy link
Owner

I've commented out Spectrogram tests for now, they mysteriously always fail on GitHub Actions but work locally.

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.

fftSamples shouldn't scale the spectrogram image
2 participants