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

Visualization.spectrum doesn't make use of pFreqData #48

Open
mattblovell opened this issue Nov 28, 2020 · 2 comments
Open

Visualization.spectrum doesn't make use of pFreqData #48

mattblovell opened this issue Nov 28, 2020 · 2 comments

Comments

@mattblovell
Copy link

It doesn't seem like this visualization.spectrum addon makes use of frequency information for its display.

The CVisualizationSpectrum::AudioData() function makes no use of pFreqData or iFreqDataLength. Instead, a somewhat odd sampling of the amplitude information carried by pAudioData is used instead:

int xscale[] = {0, 1, 2, 3, 5, 7, 10, 14, 20, 28, 40, 54, 74, 101, 137, 187, 255};
for(y = 15; y > 0; y--)
{
for(i = 0; i < 16; i++)
{
m_heights[y][i] = m_heights[y - 1][i];
}
}
for(i = 0; i < NUM_BANDS; i++)
{
for(c = xscale[i], y = 0; c < xscale[i + 1]; c++)
{
if (c<iAudioDataLength)
{
if((int)(pAudioData[c] * (INT16_MAX)) > y)
y = (int)(pAudioData[c] * (INT16_MAX));
}
else
continue;
}
y >>= 7;
if(y > 0)
val = (logf(y) * m_scale);
else
val = 0;
m_heights[0][i] = val;

I found mention of this in a kodi.tv forum back in a 2014 thread:

https://forum.kodi.tv/showthread.php?tid=204991&pid=1846424#pid1846424

the spectrum viz doesn't use fft data... there are no vizes in mainline using the fft data. it's still borked, but that is NOT a way to test it.

Wow. No wonder it looks nothing like a spectrum analyser display...
I really think it should be using the fft data (well assuming the fft data is fixed).

So it just uses a random subset of audio samples. That would explain why it looks like random noise.

and

well, it's amplitude bins for each data set. so not entirely random but surely not a proper spectrum.

@mattblovell
Copy link
Author

mattblovell commented Nov 28, 2020

The AudioData() member in this class can be contrasted with that in visualization.starburst:

https://github.com/xbmc/visualization.starburst/blob/c4d57064d023d4038b48027a1983d3c9bac2c228/src/StarBurst.cpp#L185

The StarBurst visualization also asserts wantFreq in its override of GetInfo(), in order to get pFreqData populated.

https://github.com/xbmc/visualization.starburst/blob/e2f781fbb00ab2cd422cc856d485d2e0480cc357/src/StarBurst.h#L63

@AlwinEsch
Copy link
Member

With #49 becomes the work about changed and to use FFT, after them is in becomes the issue here closed.

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

2 participants