Mercurial > hg > svgui
comparison layer/SpectrogramLayer.cpp @ 1044:4e5c1c326794 3.0-integration
Make ViewProxy objects share the ids of their Views; fixes incorrect colour scale drawing
author | Chris Cannam |
---|---|
date | Tue, 09 Feb 2016 10:59:36 +0000 |
parents | fccee028a522 |
children | 5e5873c24142 |
comparison
equal
deleted
inserted
replaced
1043:fccee028a522 | 1044:4e5c1c326794 |
---|---|
46 | 46 |
47 #ifndef __GNUC__ | 47 #ifndef __GNUC__ |
48 #include <alloca.h> | 48 #include <alloca.h> |
49 #endif | 49 #endif |
50 | 50 |
51 //#define DEBUG_SPECTROGRAM_REPAINT 1 | 51 #define DEBUG_SPECTROGRAM_REPAINT 1 |
52 | 52 |
53 using namespace std; | 53 using namespace std; |
54 | 54 |
55 SpectrogramLayer::SpectrogramLayer(Configuration config) : | 55 SpectrogramLayer::SpectrogramLayer(Configuration config) : |
56 m_model(0), | 56 m_model(0), |
580 } | 580 } |
581 | 581 |
582 void | 582 void |
583 SpectrogramLayer::invalidateImageCaches() | 583 SpectrogramLayer::invalidateImageCaches() |
584 { | 584 { |
585 #ifdef DEBUG_SPECTROGRAM | |
586 cerr << "SpectrogramLayer::invalidateImageCaches called" << endl; | |
587 #endif | |
585 for (ViewImageCache::iterator i = m_imageCaches.begin(); | 588 for (ViewImageCache::iterator i = m_imageCaches.begin(); |
586 i != m_imageCaches.end(); ++i) { | 589 i != m_imageCaches.end(); ++i) { |
587 i->second.invalidate(); | 590 i->second.invalidate(); |
588 } | 591 } |
589 } | 592 } |
1533 } | 1536 } |
1534 | 1537 |
1535 void | 1538 void |
1536 SpectrogramLayer::invalidateFFTModels() | 1539 SpectrogramLayer::invalidateFFTModels() |
1537 { | 1540 { |
1541 #ifdef DEBUG_SPECTROGRAM | |
1542 cerr << "SpectrogramLayer::invalidateFFTModels called" << endl; | |
1543 #endif | |
1538 for (ViewFFTMap::iterator i = m_fftModels.begin(); | 1544 for (ViewFFTMap::iterator i = m_fftModels.begin(); |
1539 i != m_fftModels.end(); ++i) { | 1545 i != m_fftModels.end(); ++i) { |
1540 delete i->second; | 1546 delete i->second; |
1541 } | 1547 } |
1542 for (PeakCacheMap::iterator i = m_peakCaches.begin(); | 1548 for (PeakCacheMap::iterator i = m_peakCaches.begin(); |
1555 } | 1561 } |
1556 | 1562 |
1557 void | 1563 void |
1558 SpectrogramLayer::invalidateMagnitudes() | 1564 SpectrogramLayer::invalidateMagnitudes() |
1559 { | 1565 { |
1566 #ifdef DEBUG_SPECTROGRAM | |
1567 cerr << "SpectrogramLayer::invalidateMagnitudes called" << endl; | |
1568 #endif | |
1560 m_viewMags.clear(); | 1569 m_viewMags.clear(); |
1561 for (vector<MagnitudeRange>::iterator i = m_columnMags.begin(); | 1570 for (vector<MagnitudeRange>::iterator i = m_columnMags.begin(); |
1562 i != m_columnMags.end(); ++i) { | 1571 i != m_columnMags.end(); ++i) { |
1563 *i = MagnitudeRange(); | 1572 *i = MagnitudeRange(); |
1564 } | 1573 } |
1595 } | 1604 } |
1596 } | 1605 } |
1597 | 1606 |
1598 #ifdef DEBUG_SPECTROGRAM_REPAINT | 1607 #ifdef DEBUG_SPECTROGRAM_REPAINT |
1599 cerr << "SpectrogramLayer::updateViewMagnitudes returning from cols " | 1608 cerr << "SpectrogramLayer::updateViewMagnitudes returning from cols " |
1600 << s0 << " -> " << s1 << " inclusive" << endl; | 1609 << s0 << " -> " << s1 << " inclusive" << endl; |
1610 cerr << "SpectrogramLayer::updateViewMagnitudes: for view id " << v->getId() | |
1611 << ": min is " << mag.getMin() << ", max is " << mag.getMax() << endl; | |
1601 #endif | 1612 #endif |
1602 | 1613 |
1603 if (!mag.isSet()) return false; | 1614 if (!mag.isSet()) return false; |
1604 if (mag == m_viewMags[v->getId()]) return false; | 1615 if (mag == m_viewMags[v->getId()]) return false; |
1605 m_viewMags[v->getId()] = mag; | 1616 m_viewMags[v->getId()] = mag; |
3121 double max = m_viewMags[v->getId()].getMax(); | 3132 double max = m_viewMags[v->getId()].getMax(); |
3122 | 3133 |
3123 double dBmin = AudioLevel::multiplier_to_dB(min); | 3134 double dBmin = AudioLevel::multiplier_to_dB(min); |
3124 double dBmax = AudioLevel::multiplier_to_dB(max); | 3135 double dBmax = AudioLevel::multiplier_to_dB(max); |
3125 | 3136 |
3137 #ifdef DEBUG_SPECTROGRAM_REPAINT | |
3138 cerr << "paintVerticalScale: for view id " << v->getId() | |
3139 << ": min = " << min << ", max = " << max | |
3140 << ", dBmin = " << dBmin << ", dBmax = " << dBmax << endl; | |
3141 #endif | |
3142 | |
3126 if (dBmax < -60.f) dBmax = -60.f; | 3143 if (dBmax < -60.f) dBmax = -60.f; |
3127 else top = QString("%1").arg(lrint(dBmax)); | 3144 else top = QString("%1").arg(lrint(dBmax)); |
3128 | 3145 |
3129 if (dBmin < dBmax - 60.f) dBmin = dBmax - 60.f; | 3146 if (dBmin < dBmax - 60.f) dBmin = dBmax - 60.f; |
3130 bottom = QString("%1").arg(lrint(dBmin)); | 3147 bottom = QString("%1").arg(lrint(dBmin)); |