Skip to content

Tweaks to frequency spectrum and sound ellipse in visualizer - #464

Merged
arybczak merged 8 commits into
ncmpcpp:masterfrom
whooie:master
Aug 21, 2024
Merged

arybczak merged 8 commits into
ncmpcpp:masterfrom
whooie:master

Conversation

@whooie

@whooie whooie commented Mar 23, 2021 •

Copy link
Copy Markdown
Contributor

Brings back the linear(-ish) axis scaling from pre-0.9.x (see #453) while keeping DFT adjustments made in #397 and adding config options visualizer_spectrum_log_scale_x and visualizer_spectrum_log_scale_y for log scaling on either/both axes.

Also switches the character used for the sound ellipse to Config.visualizer_chars[0] from Config.visualizer_chars[1] (by default this is the round character rather than the bar) because I thought it looked silly otherwise.

Here's a sample of what the linear scaling looks like in my terminal:
2021-03-18-003020
and with visualizer_smooth_look = yes:
2021-03-23-031044

A couple additional notes:

  • I noticed that the cubic interpolation used with log-scaling caused a problem when linear-scaling where the leftmost column would not be cropped properly and instead wrap onto the top/bottom edges of the drawing area:
    2021-03-23-031515
    This usually isn't a problem with log scaling because the DFT always goes to zero at those low frequencies (assuming small enough visualizer_spectrum_hz_min), but here it's quite bothersome, so when doing x-axis linear scaling, I set the height for bins not directly computed by the DFT to zero rather than interpolate, since I think it's not needed in this case anyway.
  • visualizer_spectrum_gain is still in dB, for consistency with the visualizer_spectrum_log_scale_y = yes case. The constants setting the vertical scale are set to my personal preference for default gain = 10 and are slightly adjusted compared to pre-0.9.x (slightly less high-frequency boost).

@arybczak arybczak left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, that seems to do quite well what it advertises 👍

However, I can see that the leftmost column is always empty. Why that is?

Comment thread doc/config Outdated
Comment thread src/screens/visualizer.cpp Outdated
Comment thread src/screens/visualizer.h Outdated
@whooie

whooie commented Apr 9, 2021 •

Copy link
Copy Markdown
Contributor Author

However, I can see that the leftmost column is always empty. Why that is?

Hm, I guess I had my font size to small to have noticed that. It's probably because that column is not guaranteed to be directly computed by the DFT, and (to prevent that drawing bug I found that occurs when I have cubic interpolation on) I set those columns to zero height. Not sure what the proper fix for that is.

@arybczak

Copy link
Copy Markdown
Collaborator

that column is not guaranteed to be directly computed by the DFT

Can you explain?

@whooie

whooie commented Apr 29, 2021 •

Copy link
Copy Markdown
Contributor Author

This is what I think is happening: the DFT can only be computed for a set number of frequencies. When it's plotted on the terminal, you'll eventually run into a case where you have less than one DFT data point being used to draw one column of characters, and in this case you have to do some interpolation to make the plot look continuous. This happens all the time when plotting on a log-scaled horizontal axis, but for some reason happens only for the leftmost column on the linear-scaled one.

EDIT: I think if you used a super-small terminal font to increase the number of columns relative to the number of DFT points, you'd probably see more of this on the linear scale, but I haven't tested that.

@arybczak

Copy link
Copy Markdown
Collaborator

I know it's been ages, but if you're still interested in getting this merged, can you please:

  1. Rebase the PR.
  2. Clean up the diff (there are tons of irrelevant indentation changes, see the "Files changed" tab).

@whooie

whooie commented Jul 24, 2024

Copy link
Copy Markdown
Contributor Author

Hey, sorry-- yeah this really fell off my radar for a while. Will do when I can!

@whooie

whooie commented Jul 28, 2024

Copy link
Copy Markdown
Contributor Author

Hi, seems like this should be ready to go. Let me know if I need to do anything else (sorry if anything is wrong, this is my first time contributing to anyone else's project).

@arybczak

Copy link
Copy Markdown
Collaborator

Thanks!

@arybczak
arybczak merged commit 7078ed7 into ncmpcpp:master Aug 21, 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.

2 participants