diff --git a/src/analyzer/analyzerwaveform.h b/src/analyzer/analyzerwaveform.h index 38d4af22ac5..cfe49fb9368 100644 --- a/src/analyzer/analyzerwaveform.h +++ b/src/analyzer/analyzerwaveform.h @@ -27,9 +27,15 @@ inline CSAMPLE scaleSignal(CSAMPLE invalue, FilterIndex index = FilterCount) { return std::pow(invalue, 2.0f * 0.316f); } - // TODO this function needs an explanation of why this scaling is applied. - // Note that in the allshader waveform-renderers, this scaling is undone for - // the filtered.all band. + // According to this discussion + // https://github.com/mixxxdj/mixxx/issues/6352 + // it looks like this scaling is done to accentuate + // low level information. + + // This scaling can be undone with a function in + // waveform/renderers/waveformrenderersignalbase.h + // but arguable it would be better not to do this scaling here at all + // and do it (or not) at the waveform renderer side. } struct WaveformStride { diff --git a/src/waveform/renderers/allshader/waveformrendererhsv.cpp b/src/waveform/renderers/allshader/waveformrendererhsv.cpp index 85d983e42ec..a5d6143ab30 100644 --- a/src/waveform/renderers/allshader/waveformrendererhsv.cpp +++ b/src/waveform/renderers/allshader/waveformrendererhsv.cpp @@ -129,8 +129,9 @@ void WaveformRendererHSV::paintGL() { maxLow[chn] = static_cast(u8maxLow); maxMid[chn] = static_cast(u8maxMid); maxHigh[chn] = static_cast(u8maxHigh); - // Undo scaling with pow(value, 2.0f * 0.316f) done in analyzerwaveform.h - maxAll[chn] = unscale(u8maxAll); + maxAll[chn] = static_cast(u8maxAll); + // Uncomment to undo scaling with pow(value, 2.0f * 0.316f) done in analyzerwaveform.h + // maxAll[chn] = unscale(u8maxAll); } float total{}; diff --git a/src/waveform/renderers/allshader/waveformrendererlrrgb.cpp b/src/waveform/renderers/allshader/waveformrendererlrrgb.cpp index dfb87755f4c..5db7d3ed949 100644 --- a/src/waveform/renderers/allshader/waveformrendererlrrgb.cpp +++ b/src/waveform/renderers/allshader/waveformrendererlrrgb.cpp @@ -136,8 +136,9 @@ void WaveformRendererLRRGB::paintGL() { float maxLow = static_cast(u8maxLow); float maxMid = static_cast(u8maxMid); float maxHigh = static_cast(u8maxHigh); - // Undo scaling with pow(value, 2.0f * 0.316f) done in analyzerwaveform.h - float maxAll = unscale(u8maxAll); + float maxAll = static_cast(u8maxAll); + // Uncomment to undo scaling with pow(value, 2.0f * 0.316f) done in analyzerwaveform.h + // float maxAll = unscale(u8maxAll); // Calculate the squared magnitude of the maxLow, maxMid and maxHigh values. // We take the square root to get the magnitude below. diff --git a/src/waveform/renderers/allshader/waveformrendererrgb.cpp b/src/waveform/renderers/allshader/waveformrendererrgb.cpp index 890f00ab768..e20abc1aacb 100644 --- a/src/waveform/renderers/allshader/waveformrendererrgb.cpp +++ b/src/waveform/renderers/allshader/waveformrendererrgb.cpp @@ -138,8 +138,9 @@ void WaveformRendererRGB::paintGL() { float maxLow = static_cast(u8maxLow); float maxMid = static_cast(u8maxMid); float maxHigh = static_cast(u8maxHigh); - // Undo scaling with pow(value, 2.0f * 0.316f) done in analyzerwaveform.h - float maxAllChn[2]{unscale(u8maxAllChn[0]), unscale(u8maxAllChn[1])}; + float maxAllChn[2]{static_cast(u8maxAllChn[0]), static_cast(u8maxAllChn[1])}; + // Uncomment to undo scaling with pow(value, 2.0f * 0.316f) done in analyzerwaveform.h + // float maxAllChn[2]{unscale(u8maxAllChn[0]), unscale(u8maxAllChn[1])}; // Calculate the squared magnitude of the maxLow, maxMid and maxHigh values. // We take the square root to get the magnitude below. diff --git a/src/waveform/renderers/allshader/waveformrenderersimple.cpp b/src/waveform/renderers/allshader/waveformrenderersimple.cpp index 1a05cb7b78a..7d65ada387e 100644 --- a/src/waveform/renderers/allshader/waveformrenderersimple.cpp +++ b/src/waveform/renderers/allshader/waveformrenderersimple.cpp @@ -119,8 +119,10 @@ void WaveformRendererSimple::paintGL() { // data is interleaved left / right for (int i = visualIndexStart + chn; i < visualIndexStop + chn; i += 2) { const WaveformData& waveformData = data[i]; - // Undo scaling with pow(value, 2.0f * 0.316f) done in analyzerwaveform.h - const float filteredAll = unscale(waveformData.filtered.all); + const float filteredAll = static_cast(waveformData.filtered.all); + // Uncomment to undo scaling with pow(value, 2.0f * 0.316f) done + // in analyzerwaveform.h const float filteredAll = + // unscale(waveformData.filtered.all); max[chn] = math_max(max[chn], filteredAll); } diff --git a/src/waveform/renderers/waveformrenderersignalbase.h b/src/waveform/renderers/waveformrenderersignalbase.h index a0c23eb9c30..16d40513024 100644 --- a/src/waveform/renderers/waveformrenderersignalbase.h +++ b/src/waveform/renderers/waveformrenderersignalbase.h @@ -23,9 +23,11 @@ class WaveformRendererSignalBase : public WaveformRendererAbstract { void getGains(float* pAllGain, float* pLowGain, float* pMidGain, float* highGain); - // To undo scaling with pow(value, 2.0f * 0.316f) done in analyzerwaveform.h static float* unscaleTable(); inline float unscale(unsigned char value) { + // The all and hi components of the waveform data are scaled with pow(value, 2.0f * 0.316f) + // (see analyzerwaveform.h). This function can be used to undo that scaling, + // but apparently it is intentional. static const float* table = unscaleTable(); return table[value]; }