Mercurial > hg > svgui
diff layer/SpectrumLayer.cpp @ 275:bbe57afe9d7d
* avoid trying to calculate fft from incomplete decoded audio file in spectrum
author | Chris Cannam |
---|---|
date | Mon, 02 Jul 2007 14:57:01 +0000 |
parents | b9380f679f70 |
children | 8acd30ed735c |
line wrap: on
line diff
--- a/layer/SpectrumLayer.cpp Mon Jul 02 13:04:17 2007 +0000 +++ b/layer/SpectrumLayer.cpp Mon Jul 02 14:57:01 2007 +0000 @@ -31,7 +31,8 @@ m_channelSet(false), m_windowSize(1024), m_windowType(HanningWindow), - m_windowHopLevel(2) + m_windowHopLevel(2), + m_newFFTNeeded(true) { Preferences *prefs = Preferences::getInstance(); connect(prefs, SIGNAL(propertyChanged(PropertyContainer::PropertyName)), @@ -52,7 +53,7 @@ { if (m_originModel == model) return; m_originModel = model; - setupFFT(); +//!!! setupFFT(); } void @@ -99,7 +100,7 @@ m_channel = channel; - if (!fft) setupFFT(); +//!!! if (!fft) setupFFT(); emit layerParametersChanged(); } @@ -218,7 +219,8 @@ { if (m_windowSize == ws) return; m_windowSize = ws; - setupFFT(); +//!!! setupFFT(); + m_newFFTNeeded = true; emit layerParametersChanged(); } @@ -227,7 +229,8 @@ { if (m_windowHopLevel == v) return; m_windowHopLevel = v; - setupFFT(); +//!!! setupFFT(); + m_newFFTNeeded = true; emit layerParametersChanged(); } @@ -236,7 +239,8 @@ { if (m_windowType == w) return; m_windowType = w; - setupFFT(); +//!!! setupFFT(); + m_newFFTNeeded = true; emit layerParametersChanged(); } @@ -536,6 +540,20 @@ } void +SpectrumLayer::paint(View *v, QPainter &paint, QRect rect) const +{ + if (!m_originModel || !m_originModel->isOK() || + !m_originModel->isReady()) return; + + if (m_newFFTNeeded) { + const_cast<SpectrumLayer *>(this)->setupFFT(); //ugh + m_newFFTNeeded = false; + } + + SliceLayer::paint(v, paint, rect); +} + +void SpectrumLayer::getBiasCurve(BiasCurve &curve) const { curve = m_biasCurve;