Mercurial > hg > svgui
diff layer/SpectrogramLayer.cpp @ 1395:32bbb86094c3
Merge from branch spectrogramparam
author | Chris Cannam |
---|---|
date | Wed, 14 Nov 2018 14:23:17 +0000 |
parents | 2df1af7ac752 |
children | ba1f0234efa7 |
line wrap: on
line diff
--- a/layer/SpectrogramLayer.cpp Tue Nov 06 15:42:06 2018 +0000 +++ b/layer/SpectrogramLayer.cpp Wed Nov 14 14:23:17 2018 +0000 @@ -61,6 +61,7 @@ m_windowSize(1024), m_windowType(HanningWindow), m_windowHopLevel(2), + m_oversampling(1), m_gain(1.0), m_initialGain(1.0), m_threshold(1.0e-8f), @@ -236,6 +237,7 @@ list.push_back("Colour Scale"); list.push_back("Window Size"); list.push_back("Window Increment"); + list.push_back("Oversampling"); list.push_back("Normalization"); list.push_back("Bin Display"); list.push_back("Threshold"); @@ -254,6 +256,7 @@ if (name == "Colour Scale") return tr("Colour Scale"); if (name == "Window Size") return tr("Window Size"); if (name == "Window Increment") return tr("Window Overlap"); + if (name == "Oversampling") return tr("Oversampling"); if (name == "Normalization") return tr("Normalization"); if (name == "Bin Display") return tr("Bin Display"); if (name == "Threshold") return tr("Threshold"); @@ -287,7 +290,8 @@ if (name == "Bin Display" || name == "Frequency Scale") return tr("Bins"); if (name == "Window Size" || - name == "Window Increment") return tr("Window"); + name == "Window Increment" || + name == "Oversampling") return tr("Window"); if (name == "Colour" || name == "Threshold" || name == "Colour Rotation") return tr("Colour"); @@ -376,7 +380,17 @@ *deflt = 2; val = m_windowHopLevel; - + + } else if (name == "Oversampling") { + + *min = 0; + *max = 3; + *deflt = 0; + + val = 0; + int ov = m_oversampling; + while (ov > 1) { ov >>= 1; val ++; } + } else if (name == "Min Frequency") { *min = 0; @@ -485,6 +499,15 @@ case 5: return tr("93.75 %"); } } + if (name == "Oversampling") { + switch (value) { + default: + case 0: return tr("1x"); + case 1: return tr("2x"); + case 2: return tr("4x"); + case 3: return tr("8x"); + } + } if (name == "Min Frequency") { switch (value) { default: @@ -578,6 +601,8 @@ setWindowSize(32 << value); } else if (name == "Window Increment") { setWindowHopLevel(value); + } else if (name == "Oversampling") { + setOversampling(1 << value); } else if (name == "Min Frequency") { switch (value) { default: @@ -707,8 +732,58 @@ } int -SpectrogramLayer::getFFTOversampling() const +SpectrogramLayer::getFFTSize() const { + return m_windowSize * m_oversampling; +} + +void +SpectrogramLayer::setWindowSize(int ws) +{ + if (m_windowSize == ws) return; + invalidateRenderers(); + m_windowSize = ws; + recreateFFTModel(); + emit layerParametersChanged(); +} + +int +SpectrogramLayer::getWindowSize() const +{ + return m_windowSize; +} + +void +SpectrogramLayer::setWindowHopLevel(int v) +{ + if (m_windowHopLevel == v) return; + invalidateRenderers(); + m_windowHopLevel = v; + recreateFFTModel(); + emit layerParametersChanged(); +} + +int +SpectrogramLayer::getWindowHopLevel() const +{ + return m_windowHopLevel; +} + +void +SpectrogramLayer::setOversampling(int oversampling) +{ + if (m_oversampling == oversampling) return; + invalidateRenderers(); + m_oversampling = oversampling; + recreateFFTModel(); + emit layerParametersChanged(); +} + +int +SpectrogramLayer::getOversampling() const +{ + return m_oversampling; + /*!!! if (m_binDisplay != BinDisplay::AllBins) { return 1; } @@ -722,52 +797,7 @@ } return 4; -} - -int -SpectrogramLayer::getFFTSize() const -{ - return m_windowSize * getFFTOversampling(); -} - -void -SpectrogramLayer::setWindowSize(int ws) -{ - if (m_windowSize == ws) return; - - invalidateRenderers(); - - m_windowSize = ws; - - recreateFFTModel(); - - emit layerParametersChanged(); -} - -int -SpectrogramLayer::getWindowSize() const -{ - return m_windowSize; -} - -void -SpectrogramLayer::setWindowHopLevel(int v) -{ - if (m_windowHopLevel == v) return; - - invalidateRenderers(); - - m_windowHopLevel = v; - - recreateFFTModel(); - - emit layerParametersChanged(); -} - -int -SpectrogramLayer::getWindowHopLevel() const -{ - return m_windowHopLevel; + */ } void @@ -2500,11 +2530,13 @@ s += QString("channel=\"%1\" " "windowSize=\"%2\" " "windowHopLevel=\"%3\" " - "gain=\"%4\" " - "threshold=\"%5\" ") + "oversampling=\"%4\" " + "gain=\"%5\" " + "threshold=\"%6\" ") .arg(m_channel) .arg(m_windowSize) .arg(m_windowHopLevel) + .arg(m_oversampling) .arg(m_gain) .arg(m_threshold); @@ -2583,6 +2615,9 @@ } } + int oversampling = attributes.value("oversampling").toUInt(&ok); + if (ok) setOversampling(oversampling); + float gain = attributes.value("gain").toFloat(&ok); if (ok) setGain(gain);