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

Linear display of Spectrum analyzer seems to show too small values #5089

Closed
michaelgregorius opened this issue Jul 22, 2019 · 17 comments
Closed

Comments

@michaelgregorius
Copy link
Contributor

How to reproduce:

  1. Play one of the example songs and visualize it using the new Spectrum Analyzer.
  2. Freeze the analyzer.
  3. Switch the Y scale between linear display and logarithmic display.

The linear display seems to show too small values compared to the logarithmic display. Here's an example.

Logarithmic display:
SpectrumAnalyzer-LogDisplay-Small

Linear display:
SpectrumAnalyzer-LinearView-Small

The logarithmic display has its peak at -9 dB but the linear display only at around 0.12. Assuming the the conversion from linear lin to logarithmic db is db = 20*log(lin) then for a value of -9 dB we should get a value of around 0.35 because lin = 10^(db/20). For the specific example this means that lin = 10^(-9/20) = 10^(-0.45).

@he29-net
Copy link
Contributor

Hi,
the conversion I'm using is actually dB = 10*log(linear). So you get about 0.125, which matches the display. I.e., I'm treating the returned linear FFT result as a unit of power, that is, 3 dB increase means "twice as much".

I wasn't able to make much sense out of all the articles talking about decibels in relation to audio. Some simply care only about voltage / signal amplitude and use the amplitude ratio (twice as much is 6 dB), others talk about it in relation to driving some audio output where the end result depends on the power delivered to speakers and therefore use the power ratio, and yet others argue that it does not matter, because human hearing treats sound pressure levels more along the lines of "twice as much is 10 dB"...

I wasn't able to find three sources that would be comprehensible and agree with the other two. So I basically gave up, picked one way that seemed reasonable (and useful in terms of grid resolution), and used that. If there is a good reason to change it -- why not, it probably doesn't make that much difference.

@michaelgregorius
Copy link
Contributor Author

Hi @he29-net,

I have to admit that I am also still a bit confused with regards to which type of conversion (10 vs. 20) should be used in which (practical) situation. 😄

My theoretical understanding so far is that you can use the conversion with a factor of 20 whenever you compute with values that are squared during the computation. So if you have something that computes as f(x) = 10*log(x^2/c^2) then you can compute it directly as f(x) = 10 * 2 * log(x/c) = 20 * log(x/c) due to the logarithm rule of log(a^b) = b * log(a).

I have just gathered an overview of how some other analyzers behave. To do so I have used Audacity to create a sine signal at 440 Hz with peak values of 1 and -1 and checked how this signal displays in various signal analyzers (most of them in their default state except for SPAN where I have set the slope to 0). Here are the results:

Analyzer dB readout
LMMS -3 dB
SPAN -3 dB
Signal Analyzer 0dB
REAPER Signal Analyzer 0dB
Signalizer 0dB

Using a 20 conversion for the linear scale might be a bit more practical as it makes more use of the available space. With the 10 conversion the users would mostly set a rather flat spectrum.

Great work on the new analyzer by the way! 👍

@he29-net
Copy link
Contributor

Using 20* instead of the 10* conversion won't affect the linear scale in any way, by the way. The linear scale is basically the direct, raw FFT result, so if we decide to change the dB scale, it won't be affected in any way.

The only thing we can change is, essentially, whether "twice as much" is defined as 3 dB or as 6 dB. Or, in other words, whether the Y axis labels on Audible range go from 10 to -50 or from 20 to -100. The displayed spectrum itself should remain exactly the same (after the ranges are adjusted), it's only the logarithmic labels that will be affected.

@enp2s0
Copy link
Contributor

enp2s0 commented Jul 25, 2019

I feel like 10 to -50 is much more common in other audio applications that 20 to -100. Perhaps a "zoom"/"scale" feature would be useful for the linear mode?

@he29-net
Copy link
Contributor

Well, there already is a zoom / scale feature, it's the range selector.

The problem is just that the ranges are optimized for the logarithmic display, which will be used most of the time. I could add a new range with -3 dB upper bound, so the linear scale would go from 0.5 to 0, making everything twice as big. But then there would be a new range, say -3 to -50 dB, when there already is a 0 to -50 dB range -- most users not using linear scale would be probably confused as for why is it there.

Or there could be a different set of ranges for linear and logarithmic scales, which would be even worse -- when I switch ling / log, I expect the displayed content to be consistent with what I saw before, not to jump around on its own accord.

To make the linear scale more useful, I'm thinking of moving the upper bound of Noise range from -20 dB to -10 dB, which would make it (0.1 to 0) in the linear space, instead of current (0.01 to 0). That is, values would appear 10 times bigger compared to the default. At the same time, I would probably rename it to Silent, to be consistent with the new name for current Default.

But at the end of the day, using any linear range, most of the values will probably still be either too small or grow outside of the graph. It is just the nature of the linear scale -- the fact it is hard to read is why it is almost never used.

@he29-net
Copy link
Contributor

Also, to explain why I went with a fixed set of ranges instead of a slider or a knob -- simply to make everything more consistent. When you switch to a range you already used for a while, you immediately know what to expect, you don't even have to look at the Y scale most of the time.

If you load 10 projects in sequence and the range of each is set to two different arbitrary points, you have no clear frame of reference. Each time, you need to examine the Y axis and figure out what would you expect to see for such a range.

@enp2s0
Copy link
Contributor

enp2s0 commented Jul 25, 2019

Personally I'd have the slider over the dropdown menus. If you want to keep the menus, why not have a different set of ranges when the display is in linear mode (i.e. "Extended" covers a different range in linear vs logarithmic, etc)

@Spekular
Copy link
Member

Spekular commented Jul 25, 2019 via email

@michaelgregorius
Copy link
Contributor Author

It is just the nature of the linear scale -- the fact it is hard to read is why it is almost never used.

I therefore propose to drop the option of the linear scale completely. I guess it's just there because the previous implementation of the analyzer had it and I assume that no one knows anymore why it had it. 😄

I have also checked the four analyzers mentioned above again and none of them has the option to switch to a linear scale.

The linear scale is not helpful because it does not match the sensitivity of the human ear. A linear drop in the logarithmic scale, e.g. from -6 to -12 dB, corresponds to an exponential drop in the linear scale and this is the reason why the graph quickly vanishes and you cannot see anything anymore.

@he29-net
Copy link
Contributor

You could always have both, right? So you could select preset ranges via combobox for comparative purposes, but also adjust the range when desired.

That's a good point, that could work quite well. Although it also leads to another problem -- where to put the sliders or knobs? The controls section is already quite crowded and it will take even more space for "advanced settings" button in a future upgrade..

There is some space between the combo boxes, compared to the "LED switches" on the left, which are already squished harder than intended by their design. With just a little bit of extra space, a simple line-like slider thingy could fit under each combo box, and have two points corresponding to the minimum and maximum. I quite like that idea, but it will probably require a custom control widget, so it's definitely not a quick fix.

I therefore propose to drop the option of the linear scale completely.

I don't see a good reason for dropping it. The indicator icon will stay there anyway, even if only to be consistent with the X axis -- and I can already see the bug reports coming, saying that the "linear Y switch does not work". The linear scale may be not useful for mixing, but it may still find some use for technical reasons or for education.

@michaelgregorius
Copy link
Contributor Author

I don't see a good reason for dropping it.

The reasons that in my opinion would favour dropping the linear scale are:

If the GUI does not indicate that it's possible to switch to a linear scale then there shouldn't be any bug reports. If we keep it then there might also be bug reports like "I cannot see the high frequencies when the linear scale is active." And I also already ran into the problem that I thought that the linear scale is broken because all I saw was a black screen because the scale was set too high." However, I think you are already aware of that problem (#5090).

I also don't see any big educational value and removing it would be somewhat along the line of the KISS principle.

@he29-net
Copy link
Contributor

@michaelgregorius If you think removing the linear scale option contributes to KISS, we may as well remove all the switches and settings above and just force the user to use "the one true chosen configuration". :))

It may be not helpful for mixing, but you can still use it to check whether your signal is clipping (since you can be sure linear 1.0 is always the limit; with dB scale, you do not know for certain what the author used as reference) and to figure out which dB conversion is used (20*log() or 10*log()) without reading documentation (which we do not have) or having to craft test signals with known linear levels in external software.

Also, you can use it for a quick log<-> linear conversion -- just set a cursor location and switch linear / log. And there may be other use cases I'm not currently aware of -- why should we limit what the user can and cannot do?

Seeing that the signal looks really small on linear scale is by itself an educational experience, it tells you without words why is the dB scale used in the first place. People may wonder "why I don't see high frequencies", but that should result in Google searches, not in bug reports -- when I push a button and nothing obvious happens, I assume I don't know what exactly the button does, not that it does not work.

@he29-net
Copy link
Contributor

So, while I was looking around before opening a new issue regarding various units and ranges constants (probably tomorrow), I noticed that while the linear scale matches the selected dB units, it does not work quite in the way as I originally intended.

Specifically, sine wave that goes from -1.0 to 1.0 is nearly clipping, so it should measure as being at 0 dBFS or 1.0 linear. But it is half the size (-3 dB log., 0.5 linear). So in a way, the title of this issue is still valid, it would probably make more sense having everything doubled.

The issue is not in the dB conversion formula, but probably in the interpretation of FFTW results or in normalization. I actually never realized that units called dBFS are a thing, and that it is what LMMS uses. Having a name for the "1.0 reference" certainly helps to clear some of my "dB confusion". :)

So, in the next Analyzer update, I will change it so that -1.0 to 1.0 sine wave measures 0 dB, since it makes more sense and matches most spectrum analyzers tested by @michaelgregorius earlier in this thread. That's in addition to the change in the upper limit of the Audible scale, so after that, the linear values should be reasonably visible at all ranges except Extended (which is just ridiculously large, it should be probably renamed to Placebo).

@he29-net
Copy link
Contributor

he29-net commented Dec 4, 2019

This issue was fixed (or improved, since values looking small in linear scale is just property of the scale that can't be "fixed") in #5160. The linear scale had a small problem (now fixed) that essentially caused the values to be 50 % of what they were intended to be, so the update should improve the visibility a bit.

@DomClark
Copy link
Member

DomClark commented Jan 8, 2020

This issue was fixed (or improved...)

Does that mean this can be closed now?

@he29-net
Copy link
Contributor

he29-net commented Jan 8, 2020

Probably. I did not suggest either way as I expected @michaelgregorius to comment on whether the solution / updated version is satisfactory or not.

@michaelgregorius
Copy link
Contributor Author

Hi @DomClark, hi @he29-net,

I think we can close this issue. The vertical axis now scales with the selected preset and I think it is impossible to get anything usable out of the linear scale anyway regardless of how we would change it. 😉

@DomClark DomClark closed this as completed Jan 9, 2020
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

No branches or pull requests

5 participants