Mercurial > hg > svgui
comparison layer/SpectrogramLayer.cpp @ 193:57c2350a8c40
* Add slice layers (so you can display a slice of a colour 3d plot as if it were
a spectrum)
* Make spectrum layer a subclass of slice layer
author | Chris Cannam |
---|---|
date | Fri, 26 Jan 2007 16:59:57 +0000 |
parents | dd573e090eed |
children | 22c99c8aa1e0 |
comparison
equal
deleted
inserted
replaced
192:fcc043f75c41 | 193:57c2350a8c40 |
---|---|
37 #include <cmath> | 37 #include <cmath> |
38 | 38 |
39 //#define DEBUG_SPECTROGRAM_REPAINT 1 | 39 //#define DEBUG_SPECTROGRAM_REPAINT 1 |
40 | 40 |
41 SpectrogramLayer::SpectrogramLayer(Configuration config) : | 41 SpectrogramLayer::SpectrogramLayer(Configuration config) : |
42 Layer(), | |
43 m_model(0), | 42 m_model(0), |
44 m_channel(0), | 43 m_channel(0), |
45 m_windowSize(1024), | 44 m_windowSize(1024), |
46 m_windowType(HanningWindow), | 45 m_windowType(HanningWindow), |
47 m_windowHopLevel(2), | 46 m_windowHopLevel(2), |
60 m_normalizeColumns(false), | 59 m_normalizeColumns(false), |
61 m_normalizeVisibleArea(false), | 60 m_normalizeVisibleArea(false), |
62 m_lastEmittedZoomStep(-1), | 61 m_lastEmittedZoomStep(-1), |
63 m_updateTimer(0), | 62 m_updateTimer(0), |
64 m_candidateFillStartFrame(0), | 63 m_candidateFillStartFrame(0), |
65 m_exiting(false) | 64 m_exiting(false), |
65 m_sliceableModel(0) | |
66 { | 66 { |
67 if (config == MelodicRange) { | 67 if (config == MelodicRange) { |
68 setWindowSize(8192); | 68 setWindowSize(8192); |
69 setWindowHopLevel(4); | 69 setWindowHopLevel(4); |
70 // setWindowType(ParzenWindow); | 70 // setWindowType(ParzenWindow); |
899 | 899 |
900 invalidatePixmapCaches(); | 900 invalidatePixmapCaches(); |
901 m_pixmapCaches.erase(v); | 901 m_pixmapCaches.erase(v); |
902 | 902 |
903 if (m_fftModels.find(v) != m_fftModels.end()) { | 903 if (m_fftModels.find(v) != m_fftModels.end()) { |
904 | |
905 if (m_sliceableModel == m_fftModels[v].first) { | |
906 bool replaced = false; | |
907 for (ViewFFTMap::iterator i = m_fftModels.begin(); | |
908 i != m_fftModels.end(); ++i) { | |
909 if (i->second.first != m_sliceableModel) { | |
910 emit sliceableModelReplaced(m_sliceableModel, i->second.first); | |
911 replaced = true; | |
912 break; | |
913 } | |
914 } | |
915 if (!replaced) emit sliceableModelReplaced(m_sliceableModel, 0); | |
916 } | |
917 | |
904 delete m_fftModels[v].first; | 918 delete m_fftModels[v].first; |
905 m_fftModels.erase(v); | 919 m_fftModels.erase(v); |
906 } | 920 } |
907 | 921 |
908 } else { | 922 } else { |
1624 delete model; | 1638 delete model; |
1625 m_fftModels[v] = FFTFillPair(0, 0); | 1639 m_fftModels[v] = FFTFillPair(0, 0); |
1626 return 0; | 1640 return 0; |
1627 } | 1641 } |
1628 | 1642 |
1643 if (!m_sliceableModel) { | |
1644 std::cerr << "SpectrogramLayer: emitting sliceableModelReplaced(0, " << model << ")" << std::endl; | |
1645 ((SpectrogramLayer *)this)->sliceableModelReplaced(0, model); | |
1646 m_sliceableModel = model; | |
1647 } | |
1648 | |
1629 m_fftModels[v] = FFTFillPair(model, 0); | 1649 m_fftModels[v] = FFTFillPair(model, 0); |
1630 | 1650 |
1631 model->resume(); | 1651 model->resume(); |
1632 | 1652 |
1633 delete m_updateTimer; | 1653 delete m_updateTimer; |
1638 } | 1658 } |
1639 | 1659 |
1640 return m_fftModels[v].first; | 1660 return m_fftModels[v].first; |
1641 } | 1661 } |
1642 | 1662 |
1663 const Model * | |
1664 SpectrogramLayer::getSliceableModel() const | |
1665 { | |
1666 if (m_sliceableModel) return m_sliceableModel; | |
1667 if (m_fftModels.empty()) return 0; | |
1668 m_sliceableModel = m_fftModels.begin()->second.first; | |
1669 return m_sliceableModel; | |
1670 } | |
1671 | |
1643 void | 1672 void |
1644 SpectrogramLayer::invalidateFFTModels() | 1673 SpectrogramLayer::invalidateFFTModels() |
1645 { | 1674 { |
1646 for (ViewFFTMap::iterator i = m_fftModels.begin(); | 1675 for (ViewFFTMap::iterator i = m_fftModels.begin(); |
1647 i != m_fftModels.end(); ++i) { | 1676 i != m_fftModels.end(); ++i) { |
1648 delete i->second.first; | 1677 delete i->second.first; |
1649 } | 1678 } |
1650 | 1679 |
1651 m_fftModels.clear(); | 1680 m_fftModels.clear(); |
1681 | |
1682 if (m_sliceableModel) { | |
1683 std::cerr << "SpectrogramLayer: emitting sliceableModelReplaced(" << m_sliceableModel << ", 0)" << std::endl; | |
1684 emit sliceableModelReplaced(m_sliceableModel, 0); | |
1685 m_sliceableModel = 0; | |
1686 } | |
1652 } | 1687 } |
1653 | 1688 |
1654 void | 1689 void |
1655 SpectrogramLayer::invalidateMagnitudes() | 1690 SpectrogramLayer::invalidateMagnitudes() |
1656 { | 1691 { |