# HG changeset patch # User Chris Cannam # Date 1183388221 0 # Node ID bbe57afe9d7dc7c96d322c1b8588ebe15d281715 # Parent b9380f679f70a462edf3f6178db12cb88955f46a * avoid trying to calculate fft from incomplete decoded audio file in spectrum diff -r b9380f679f70 -r bbe57afe9d7d layer/SpectrumLayer.cpp --- 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(this)->setupFFT(); //ugh + m_newFFTNeeded = false; + } + + SliceLayer::paint(v, paint, rect); +} + +void SpectrumLayer::getBiasCurve(BiasCurve &curve) const { curve = m_biasCurve; diff -r b9380f679f70 -r bbe57afe9d7d layer/SpectrumLayer.h --- a/layer/SpectrumLayer.h Mon Jul 02 13:04:17 2007 +0000 +++ b/layer/SpectrumLayer.h Mon Jul 02 14:57:01 2007 +0000 @@ -44,6 +44,8 @@ virtual QString getFeatureDescription(View *v, QPoint &) const; + virtual void paint(View *v, QPainter &paint, QRect rect) const; + virtual PropertyList getProperties() const; virtual QString getPropertyLabel(const PropertyName &) const; virtual PropertyType getPropertyType(const PropertyName &) const; @@ -100,6 +102,7 @@ size_t m_windowSize; WindowType m_windowType; size_t m_windowHopLevel; + mutable bool m_newFFTNeeded; void setupFFT();