Mercurial > hg > svgui
changeset 1381:2f4476993ae6 spectrogramparam
Merge from default branch
author | Chris Cannam |
---|---|
date | Tue, 06 Nov 2018 15:42:35 +0000 |
parents | b6cca362bbf4 (diff) 78eecb19e688 (current diff) |
children | 2df1af7ac752 |
files | |
diffstat | 2 files changed, 92 insertions(+), 51 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/SpectrogramLayer.cpp Tue Nov 06 15:42:06 2018 +0000 +++ b/layer/SpectrogramLayer.cpp Tue Nov 06 15:42:35 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,66 @@ } 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 +805,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
--- a/layer/SpectrogramLayer.h Tue Nov 06 15:42:06 2018 +0000 +++ b/layer/SpectrogramLayer.h Tue Nov 06 15:42:35 2018 +0000 @@ -111,6 +111,9 @@ void setWindowHopLevel(int level); int getWindowHopLevel() const; + void setOversampling(int oversampling); + int getOversampling() const; + void setWindowType(WindowType type); WindowType getWindowType() const; @@ -246,6 +249,7 @@ int m_windowSize; WindowType m_windowType; int m_windowHopLevel; + int m_oversampling; float m_gain; float m_initialGain; float m_threshold; @@ -300,8 +304,7 @@ else return m_windowSize / (1 << (m_windowHopLevel - 1)); } - int getFFTOversampling() const; - int getFFTSize() const; // m_windowSize * getFFTOversampling() + int getFFTSize() const; // m_windowSize * getOversampling() FFTModel *m_fftModel; FFTModel *getFFTModel() const { return m_fftModel; }