comparison 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
comparison
equal deleted inserted replaced
274:b9380f679f70 275:bbe57afe9d7d
29 m_originModel(0), 29 m_originModel(0),
30 m_channel(-1), 30 m_channel(-1),
31 m_channelSet(false), 31 m_channelSet(false),
32 m_windowSize(1024), 32 m_windowSize(1024),
33 m_windowType(HanningWindow), 33 m_windowType(HanningWindow),
34 m_windowHopLevel(2) 34 m_windowHopLevel(2),
35 m_newFFTNeeded(true)
35 { 36 {
36 Preferences *prefs = Preferences::getInstance(); 37 Preferences *prefs = Preferences::getInstance();
37 connect(prefs, SIGNAL(propertyChanged(PropertyContainer::PropertyName)), 38 connect(prefs, SIGNAL(propertyChanged(PropertyContainer::PropertyName)),
38 this, SLOT(preferenceChanged(PropertyContainer::PropertyName))); 39 this, SLOT(preferenceChanged(PropertyContainer::PropertyName)));
39 setWindowType(prefs->getWindowType()); 40 setWindowType(prefs->getWindowType());
50 void 51 void
51 SpectrumLayer::setModel(DenseTimeValueModel *model) 52 SpectrumLayer::setModel(DenseTimeValueModel *model)
52 { 53 {
53 if (m_originModel == model) return; 54 if (m_originModel == model) return;
54 m_originModel = model; 55 m_originModel = model;
55 setupFFT(); 56 //!!! setupFFT();
56 } 57 }
57 58
58 void 59 void
59 SpectrumLayer::setupFFT() 60 SpectrumLayer::setupFFT()
60 { 61 {
97 return; 98 return;
98 } 99 }
99 100
100 m_channel = channel; 101 m_channel = channel;
101 102
102 if (!fft) setupFFT(); 103 //!!! if (!fft) setupFFT();
103 104
104 emit layerParametersChanged(); 105 emit layerParametersChanged();
105 } 106 }
106 107
107 Layer::PropertyList 108 Layer::PropertyList
216 void 217 void
217 SpectrumLayer::setWindowSize(size_t ws) 218 SpectrumLayer::setWindowSize(size_t ws)
218 { 219 {
219 if (m_windowSize == ws) return; 220 if (m_windowSize == ws) return;
220 m_windowSize = ws; 221 m_windowSize = ws;
221 setupFFT(); 222 //!!! setupFFT();
223 m_newFFTNeeded = true;
222 emit layerParametersChanged(); 224 emit layerParametersChanged();
223 } 225 }
224 226
225 void 227 void
226 SpectrumLayer::setWindowHopLevel(size_t v) 228 SpectrumLayer::setWindowHopLevel(size_t v)
227 { 229 {
228 if (m_windowHopLevel == v) return; 230 if (m_windowHopLevel == v) return;
229 m_windowHopLevel = v; 231 m_windowHopLevel = v;
230 setupFFT(); 232 //!!! setupFFT();
233 m_newFFTNeeded = true;
231 emit layerParametersChanged(); 234 emit layerParametersChanged();
232 } 235 }
233 236
234 void 237 void
235 SpectrumLayer::setWindowType(WindowType w) 238 SpectrumLayer::setWindowType(WindowType w)
236 { 239 {
237 if (m_windowType == w) return; 240 if (m_windowType == w) return;
238 m_windowType = w; 241 m_windowType = w;
239 setupFFT(); 242 //!!! setupFFT();
243 m_newFFTNeeded = true;
240 emit layerParametersChanged(); 244 emit layerParametersChanged();
241 } 245 }
242 246
243 void 247 void
244 SpectrumLayer::preferenceChanged(PropertyContainer::PropertyName name) 248 SpectrumLayer::preferenceChanged(PropertyContainer::PropertyName name)
534 538
535 return description; 539 return description;
536 } 540 }
537 541
538 void 542 void
543 SpectrumLayer::paint(View *v, QPainter &paint, QRect rect) const
544 {
545 if (!m_originModel || !m_originModel->isOK() ||
546 !m_originModel->isReady()) return;
547
548 if (m_newFFTNeeded) {
549 const_cast<SpectrumLayer *>(this)->setupFFT(); //ugh
550 m_newFFTNeeded = false;
551 }
552
553 SliceLayer::paint(v, paint, rect);
554 }
555
556 void
539 SpectrumLayer::getBiasCurve(BiasCurve &curve) const 557 SpectrumLayer::getBiasCurve(BiasCurve &curve) const
540 { 558 {
541 curve = m_biasCurve; 559 curve = m_biasCurve;
542 } 560 }
543 561