univrsal / spectralizer

Audio visualizer plugin for obs-studio
GNU General Public License v2.0
591 stars 58 forks source link

43Hz - 475Hz are in a very condensed zone, sacrificing detail #3

Open WizardCM opened 4 years ago

WizardCM commented 4 years ago

Years ago, I configured Lano Visualizer in Rainmeter on my third display as a way to have a fancy background when I wasn't actively using the display. I want to do something similar in my stream's intro.

I've done my best to configure this plugin with similar settings, but I noticed that quite a lot of detail in the low-mids is lost. Here's a video: http://file.wzd.li/2019-10-19_20-54-43.mp4

As the title states, it's most noticeable at 43Hz - 475Hz (10 seconds in) in favour of 2700Hz - 6500Hz. Detail in the plugin is set to 108.

Real world example with Approaching Nirvana's "Flashback" http://file.wzd.li/2019-10-19_21-07-49.mp4

Image

univrsal commented 4 years ago

I have very little to no experience with audio processing, which is why I stuck closely to what cli-visualizer uses, so I'm not sure I can do much about that. I would assume that this is responsible for it, but I don't know how I'd have to adjust it

jrwagz commented 4 years ago

I tend to agree that the two lines of code you referenced are the most likely candidates for the non-linear behaviors shown by the above examples. Should be simple enough to just remove those lines and see how the bars look with them removed. If that isn't the cause, then you'd likely need to go dig into the parameters being fed into the engine doing the actual FFT calculations on the audio, since in that case, it likely means that the FFT algorithm itself is not using a linear scale for the buckets (meaning each bar/frequency range) it's creating when calculating magnitude for each of them.

univrsal commented 4 years ago

it likely means that the FFT algorithm itself is not using a linear scale for the buckets (meaning each bar/frequency range) it's creating when calculating magnitude for each of them.

I was considering switching from fftw3 to kiss fft, which is what rainmeter uses, because it would remove the dependency. I'll have to test the performance though, because I don't know if the other library makes use of hardware extensions.

lookeypl commented 3 years ago

I recently decided to experiment with adding logarithmic frequency scale for Spectralizer, which is what usually is used for displaying a spectrum in visualizers, as it's far more relatable to human perception of sound. I only so far tested this on Linux and it's far from ideal but it probably is what OP was looking for. I recorded a sample of it over here for a quick glance (old linear behavior on top, my implementation on the bottom): https://www.youtube.com/watch?v=yZqgnThGXjw

Code is available on my Spectralizer fork if you want to take a look. I'm no digital sound processing expert/guru and I don't know how it collides with spectrum rewriting plans (I just found out about them reading through these issues) but I hope it's at least what @WizardCM had in mind regarding spectrum detail.

univrsal commented 3 years ago

@LKostyra did you compare it to the image Wizard posted (which doesn't seem to load for me right now)? You can try the tone generator here. But from what I saw in the video it definitely looks better. Do you mind making a pull request? I was working on switching to kiss_fft and the rainmeter implementation, but maybe this'll do too. I might still use kiss_fft as it would remove the dependency on fftw3 but for now I'd be happy with just the changes you made.

lookeypl commented 3 years ago

@univrsal The images didn't load for me either when I was posting my comment, but now it seems to be working again and the results are definitely closer: Screenshot from 2020-11-20 08-12-16

There still are some minor artifacts (like the small dip to the left of the peak in the above screenshot) which are most probably a side effect of interpolating from linear to logarithmic frequency domain. I'm planning on tinkering with the code over the course of this weekend to iron these out. Also, for some reason Wire renderer doesn't show anything for me, so I want to try and take a look at that as well. Afterwards, I'd be happy to put up a PR!

WizardCM commented 3 years ago

Yep, my apologies - the example photos/videos were on my site, and my site was down this week. It's back up as of a couple hours ago.

Thanks to both of you for experimenting with this! I'm exciting to test it when you're more comfortable with the implementation. :)

univrsal commented 3 years ago

@univrsal The images didn't load for me either when I was posting my comment, but now it seems to be working again and the results are definitely closer: Screenshot from 2020-11-20 08-12-16

There still are some minor artifacts (like the small dip to the left of the peak in the above screenshot) which are most probably a side effect of interpolating from linear to logarithmic frequency domain. I'm planning on tinkering with the code over the course of this weekend to iron these out. Also, for some reason Wire renderer doesn't show anything for me, so I want to try and take a look at that as well. Afterwards, I'd be happy to put up a PR!

Great, I started to add CI to this project, which isn't done yet but it shouldn't cause any merge conflicts. It might change your development setup though. Also thanks for the time you put into this, I should've done it myself but have been putting it off for quite while.

lookeypl commented 3 years ago

Apologies for being so late with my PR, real life marched in and left me with little to no time to work on code after hours. I did some tinkering and decided to submit what I have as PR #39 . I have some more stuff I want to do with this implementation which I highlighted in the PR, but it's more work than just small adjustments, so I decided to just push what I have now and take my time with adding more improvements. If I'll come up with anything worth sharing I'll submit these changes in another PR.

univrsal commented 3 years ago

Well CI is very broken, but the Windows run finished so @WizardCM if you want to try the changes you can get the installer or the binary now.

showengineer commented 3 years ago

@univrsal Count me in for beta testing :). I tried setting up a build environment for building OBS plugins but I didn't get it to work.

univrsal commented 3 years ago

@univrsal Count me in for beta testing :). I tried setting up a build environment for building OBS plugins but I didn't get it to work.

If you're on windows the build is at the bottom on this page, I'll fix the other platforms soon

showengineer commented 3 years ago

Is it me, or does it appear to be still using the wrong scale?

univrsal commented 3 years ago

Did you turn it on? There should be an option (I haven't tested it)

showengineer commented 3 years ago

Oh I totally missed the option part, hold on.

showengineer commented 3 years ago

Yep, this looks good!

univrsal commented 3 years ago

great, I'll try to finish up CI and then maybe switch to kiss fft if it doesn't impact performance too much. And then maybe make a release.

WizardCM commented 3 years ago

A basic test without my previous comparison definitely showed significant improvements. It might require a bit of tweaking, I'll test properly later today.

As a side note, the ZIP download didn't contain the fft dll, but the installer did.