mirror of
https://github.com/LMMS/lmms.git
synced 2026-05-09 23:35:33 -04:00
Improve spectrum analyzer performance by caching most used computations (#6003)
This commit is contained in:
@@ -225,12 +225,9 @@ void SaProcessor::analyze(LocklessRingBuffer<sampleFrame> &ring_buffer)
|
||||
if (band_end - band_start > 1.0)
|
||||
{
|
||||
// band spans multiple pixels: draw all pixels it covers
|
||||
for (target = (int)band_start; target < (int)band_end; target++)
|
||||
for (target = std::max((int)band_start, 0); target < band_end && target < waterfallWidth(); target++)
|
||||
{
|
||||
if (target >= 0 && target < waterfallWidth())
|
||||
{
|
||||
pixel[target] = makePixel(m_normSpectrumL[i], m_normSpectrumR[i]);
|
||||
}
|
||||
pixel[target] = makePixel(m_normSpectrumL[i], m_normSpectrumR[i]);
|
||||
}
|
||||
// save remaining portion of the band for the following band / pixel
|
||||
// (in case the next band uses sub-pixel drawing)
|
||||
@@ -265,12 +262,9 @@ void SaProcessor::analyze(LocklessRingBuffer<sampleFrame> &ring_buffer)
|
||||
else
|
||||
{
|
||||
// Linear: always draws one or more pixels per band
|
||||
for (target = (int)band_start; target < band_end; target++)
|
||||
for (target = std::max((int)band_start, 0); target < band_end && target < waterfallWidth(); target++)
|
||||
{
|
||||
if (target >= 0 && target < waterfallWidth())
|
||||
{
|
||||
pixel[target] = makePixel(m_normSpectrumL[i], m_normSpectrumR[i]);
|
||||
}
|
||||
pixel[target] = makePixel(m_normSpectrumL[i], m_normSpectrumR[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -573,6 +567,9 @@ float SaProcessor::getFreqRangeMax() const
|
||||
|
||||
|
||||
// Map frequency to pixel x position on a display of given width.
|
||||
// NOTE: Results of this function may be cached by SaSpectrumView. If you use
|
||||
// a new function call or variable that can affect results of this function,
|
||||
// make sure to also add it as a trigger for cache update in SaSpectrumView.
|
||||
float SaProcessor::freqToXPixel(float freq, unsigned int width) const
|
||||
{
|
||||
if (m_controls->m_logXModel.value())
|
||||
|
||||
Reference in New Issue
Block a user