comparison layer/SpectrogramLayer.cpp @ 1054:5e5873c24142 3.0-integration

Make peak cache divisor a member
author Chris Cannam
date Mon, 13 Jun 2016 11:42:51 +0100
parents 4e5c1c326794
children 00891cfaa4d3
comparison
equal deleted inserted replaced
1053:38a53c7b81f6 1054:5e5873c24142
76 m_normalization(NoNormalization), 76 m_normalization(NoNormalization),
77 m_lastEmittedZoomStep(-1), 77 m_lastEmittedZoomStep(-1),
78 m_synchronous(false), 78 m_synchronous(false),
79 m_haveDetailedScale(false), 79 m_haveDetailedScale(false),
80 m_exiting(false), 80 m_exiting(false),
81 m_peakCacheDivisor(8),
81 m_sliceableModel(0) 82 m_sliceableModel(0)
82 { 83 {
83 QString colourConfigName = "spectrogram-colour"; 84 QString colourConfigName = "spectrogram-colour";
84 int colourConfigDefault = int(ColourMapper::Green); 85 int colourConfigDefault = int(ColourMapper::Green);
85 86
1519 { 1520 {
1520 const View *view = v->getView(); 1521 const View *view = v->getView();
1521 if (!m_peakCaches[view->getId()]) { 1522 if (!m_peakCaches[view->getId()]) {
1522 FFTModel *f = getFFTModel(v); 1523 FFTModel *f = getFFTModel(v);
1523 if (!f) return 0; 1524 if (!f) return 0;
1524 m_peakCaches[view->getId()] = new Dense3DModelPeakCache(f, 8); 1525 m_peakCaches[view->getId()] =
1526 new Dense3DModelPeakCache(f, m_peakCacheDivisor);
1525 } 1527 }
1526 return m_peakCaches[view->getId()]; 1528 return m_peakCaches[view->getId()];
1527 } 1529 }
1528 1530
1529 const Model * 1531 const Model *
1928 } 1930 }
1929 } 1931 }
1930 if (m_drawBuffer.width() < bufwid || m_drawBuffer.height() != h) { 1932 if (m_drawBuffer.width() < bufwid || m_drawBuffer.height() != h) {
1931 m_drawBuffer = QImage(bufwid, h, QImage::Format_Indexed8); 1933 m_drawBuffer = QImage(bufwid, h, QImage::Format_Indexed8);
1932 } 1934 }
1933 usePeaksCache = (increment * 8) < zoomLevel; 1935 usePeaksCache = (increment * m_peakCacheDivisor) < zoomLevel;
1934 if (m_colourScale == PhaseColourScale) usePeaksCache = false; 1936 if (m_colourScale == PhaseColourScale) usePeaksCache = false;
1935 } 1937 }
1936 1938
1937 for (int pixel = 0; pixel < 256; ++pixel) { 1939 for (int pixel = 0; pixel < 256; ++pixel) {
1938 m_drawBuffer.setColor((unsigned char)pixel, 1940 m_drawBuffer.setColor((unsigned char)pixel,
2378 FFTModel *fft = 0; 2380 FFTModel *fft = 0;
2379 int divisor = 1; 2381 int divisor = 1;
2380 #ifdef DEBUG_SPECTROGRAM_REPAINT 2382 #ifdef DEBUG_SPECTROGRAM_REPAINT
2381 cerr << "SpectrogramLayer::paintDrawBuffer: Note: bin display = " << m_binDisplay << ", w = " << w << ", binforx[" << w-1 << "] = " << binforx[w-1] << ", binforx[0] = " << binforx[0] << endl; 2383 cerr << "SpectrogramLayer::paintDrawBuffer: Note: bin display = " << m_binDisplay << ", w = " << w << ", binforx[" << w-1 << "] = " << binforx[w-1] << ", binforx[0] = " << binforx[0] << endl;
2382 #endif 2384 #endif
2383 if (usePeaksCache) { //!!! 2385 if (usePeaksCache) {
2384 sourceModel = getPeakCache(v); 2386 sourceModel = getPeakCache(v);
2385 divisor = 8;//!!! 2387 divisor = m_peakCacheDivisor;
2386 minbin = 0; 2388 minbin = 0;
2387 maxbin = sourceModel->getHeight(); 2389 maxbin = sourceModel->getHeight();
2388 } else { 2390 } else {
2389 sourceModel = fft = getFFTModel(v); 2391 sourceModel = fft = getFFTModel(v);
2390 } 2392 }