Mercurial > hg > svgui
comparison layer/SpectrogramLayer.cpp @ 1504:150d4e561b07
Only set maximum frequency on FFT model when in a special verticallyFixed mode
author | Chris Cannam |
---|---|
date | Thu, 12 Sep 2019 13:50:24 +0100 |
parents | 2c7a480f93ca |
children | e6362cf5ff1d |
comparison
equal
deleted
inserted
replaced
1503:2c7a480f93ca | 1504:150d4e561b07 |
---|---|
68 m_colourRotation(0), | 68 m_colourRotation(0), |
69 m_initialRotation(0), | 69 m_initialRotation(0), |
70 m_minFrequency(10), | 70 m_minFrequency(10), |
71 m_maxFrequency(8000), | 71 m_maxFrequency(8000), |
72 m_initialMaxFrequency(8000), | 72 m_initialMaxFrequency(8000), |
73 m_verticallyFixed(false), | |
73 m_colourScale(ColourScaleType::Log), | 74 m_colourScale(ColourScaleType::Log), |
74 m_colourScaleMultiple(1.0), | 75 m_colourScaleMultiple(1.0), |
75 m_colourMap(0), | 76 m_colourMap(0), |
76 m_colourInverted(false), | 77 m_colourInverted(false), |
77 m_binScale(BinScale::Linear), | 78 m_binScale(BinScale::Linear), |
129 | 130 |
130 SpectrogramLayer::~SpectrogramLayer() | 131 SpectrogramLayer::~SpectrogramLayer() |
131 { | 132 { |
132 invalidateRenderers(); | 133 invalidateRenderers(); |
133 deleteDerivedModels(); | 134 deleteDerivedModels(); |
135 } | |
136 | |
137 void | |
138 SpectrogramLayer::setVerticallyFixed() | |
139 { | |
140 if (m_verticallyFixed) return; | |
141 m_verticallyFixed = true; | |
142 recreateFFTModel(); | |
134 } | 143 } |
135 | 144 |
136 void | 145 void |
137 SpectrogramLayer::deleteDerivedModels() | 146 SpectrogramLayer::deleteDerivedModels() |
138 { | 147 { |
843 void | 852 void |
844 SpectrogramLayer::setMinFrequency(int mf) | 853 SpectrogramLayer::setMinFrequency(int mf) |
845 { | 854 { |
846 if (m_minFrequency == mf) return; | 855 if (m_minFrequency == mf) return; |
847 | 856 |
857 if (m_verticallyFixed) { | |
858 throw std::logic_error("setMinFrequency called with value differing from the default, on SpectrogramLayer with verticallyFixed true"); | |
859 } | |
860 | |
848 // SVDEBUG << "SpectrogramLayer::setMinFrequency: " << mf << endl; | 861 // SVDEBUG << "SpectrogramLayer::setMinFrequency: " << mf << endl; |
849 | 862 |
850 invalidateRenderers(); | 863 invalidateRenderers(); |
851 invalidateMagnitudes(); | 864 invalidateMagnitudes(); |
852 | 865 |
864 void | 877 void |
865 SpectrogramLayer::setMaxFrequency(int mf) | 878 SpectrogramLayer::setMaxFrequency(int mf) |
866 { | 879 { |
867 if (m_maxFrequency == mf) return; | 880 if (m_maxFrequency == mf) return; |
868 | 881 |
882 if (m_verticallyFixed) { | |
883 throw std::logic_error("setMaxFrequency called with value differing from the default, on SpectrogramLayer with verticallyFixed true"); | |
884 } | |
885 | |
869 // SVDEBUG << "SpectrogramLayer::setMaxFrequency: " << mf << endl; | 886 // SVDEBUG << "SpectrogramLayer::setMaxFrequency: " << mf << endl; |
870 | 887 |
871 invalidateRenderers(); | 888 invalidateRenderers(); |
872 invalidateMagnitudes(); | 889 invalidateMagnitudes(); |
873 | 890 |
874 m_maxFrequency = mf; | 891 m_maxFrequency = mf; |
875 | |
876 if (auto fftModel = ModelById::getAs<FFTModel>(m_fftModel)) { | |
877 fftModel->setMaximumFrequency(m_maxFrequency); | |
878 } | |
879 | 892 |
880 emit layerParametersChanged(); | 893 emit layerParametersChanged(); |
881 } | 894 } |
882 | 895 |
883 int | 896 int |
1422 tr("Failed to create the FFT model for this spectrogram.\n" | 1435 tr("Failed to create the FFT model for this spectrogram.\n" |
1423 "There may be insufficient memory or disc space to continue.")); | 1436 "There may be insufficient memory or disc space to continue.")); |
1424 return; | 1437 return; |
1425 } | 1438 } |
1426 | 1439 |
1427 newFFTModel->setMaximumFrequency(getMaxFrequency()); | 1440 if (m_verticallyFixed) { |
1441 newFFTModel->setMaximumFrequency(getMaxFrequency()); | |
1442 } | |
1428 | 1443 |
1429 m_fftModel = ModelById::add(newFFTModel); | 1444 m_fftModel = ModelById::add(newFFTModel); |
1430 | 1445 |
1431 bool createWholeCache = false; | 1446 bool createWholeCache = false; |
1432 checkCacheSpace(&m_peakCacheDivisor, &createWholeCache); | 1447 checkCacheSpace(&m_peakCacheDivisor, &createWholeCache); |
1795 if (m_minFrequency == minf && m_maxFrequency == maxf) return true; | 1810 if (m_minFrequency == minf && m_maxFrequency == maxf) return true; |
1796 | 1811 |
1797 invalidateRenderers(); | 1812 invalidateRenderers(); |
1798 invalidateMagnitudes(); | 1813 invalidateMagnitudes(); |
1799 | 1814 |
1815 if (m_verticallyFixed && | |
1816 (m_minFrequency != minf || m_maxFrequency != maxf)) { | |
1817 throw std::logic_error("setDisplayExtents called with values differing from the defaults, on SpectrogramLayer with verticallyFixed true"); | |
1818 } | |
1819 | |
1800 m_minFrequency = minf; | 1820 m_minFrequency = minf; |
1801 m_maxFrequency = maxf; | 1821 m_maxFrequency = maxf; |
1802 | |
1803 if (auto fftModel = ModelById::getAs<FFTModel>(m_fftModel)) { | |
1804 fftModel->setMaximumFrequency(m_maxFrequency); | |
1805 } | |
1806 | 1822 |
1807 emit layerParametersChanged(); | 1823 emit layerParametersChanged(); |
1808 | 1824 |
1809 int vs = getCurrentVerticalZoomStep(); | 1825 int vs = getCurrentVerticalZoomStep(); |
1810 if (vs != m_lastEmittedZoomStep) { | 1826 if (vs != m_lastEmittedZoomStep) { |