Mercurial > hg > svgui
changeset 1027:dade9bfc7695 spectrogram-minor-refactor
Fix return value from paintDrawBuffer in rightToLeft case; propagate timing change to PeakFrequencies version as well
author | Chris Cannam |
---|---|
date | Tue, 26 Jan 2016 14:44:26 +0000 |
parents | 53110ace211f |
children | 78ece8cdfaee |
files | layer/SpectrogramLayer.cpp |
diffstat | 1 files changed, 34 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/SpectrogramLayer.cpp Tue Jan 26 13:19:53 2016 +0000 +++ b/layer/SpectrogramLayer.cpp Tue Jan 26 14:44:26 2016 +0000 @@ -2292,6 +2292,10 @@ float *values = (float *)alloca((maxbin - minbin + 1) * sizeof(float)); #endif + int minColumns = 4; + double maxTime = 0.15; // seconds; only for non-synchronous drawing + auto startTime = chrono::steady_clock::now(); + int start = 0; int finish = w; int step = 1; @@ -2302,8 +2306,12 @@ step = -1; } + int columnCount = 0; + for (int x = start; x != finish; x += step) { + ++columnCount; + if (binforx[x] < 0) continue; int sx0 = binforx[x]; @@ -2382,9 +2390,23 @@ } } } + + if (!m_synchronous) { + if (columnCount >= minColumns) { + auto t = chrono::steady_clock::now(); + double diff = chrono::duration<double>(t - startTime).count(); + if (diff > maxTime) { +#ifdef DEBUG_SPECTROGRAM_REPAINT + cerr << "SpectrogramLayer::paintDrawBufferPeakFrequencies: Max time " << maxTime << " sec exceeded after " + << x << " columns with time " << diff << endl; +#endif + return columnCount; + } + } + } } - return w; + return columnCount; } int @@ -2400,13 +2422,6 @@ { Profiler profiler("SpectrogramLayer::paintDrawBuffer"); - //!!! todo: propagate to paintDrawBufferPeakFrequencies - - int minColumns = 4; - double maxTime = 0.1; // seconds; only for non-synchronous drawing - - auto startTime = chrono::steady_clock::now(); - int minbin = int(binfory[0] + 0.0001); int maxbin = int(binfory[h-1]); @@ -2457,6 +2472,10 @@ const float *values = autoarray; DenseThreeDimensionalModel::Column c; + int minColumns = 4; + double maxTime = 0.1; // seconds; only for non-synchronous drawing + auto startTime = chrono::steady_clock::now(); + int start = 0; int finish = w; int step = 1; @@ -2466,8 +2485,12 @@ finish = -1; step = -1; } + + int columnCount = 0; for (int x = start; x != finish; x += step) { + + ++columnCount; if (binforx[x] < 0) continue; @@ -2638,7 +2661,7 @@ } if (!m_synchronous) { - if (x >= minColumns) { + if (columnCount >= minColumns) { auto t = chrono::steady_clock::now(); double diff = chrono::duration<double>(t - startTime).count(); if (diff > maxTime) { @@ -2646,13 +2669,13 @@ cerr << "SpectrogramLayer::paintDrawBuffer: Max time " << maxTime << " sec exceeded after " << x << " columns with time " << diff << endl; #endif - return x; + return columnCount; } } } } - return w; + return columnCount; } void