# HG changeset patch # User Chris Cannam # Date 1155740267 0 # Node ID 13949a6970abd8a877be12a7d130e6007131025a # Parent 9e6b3e239b9d77579c59edf029c4aee548a76d37 * Use peaks instead of means for calculating display values in pixels that cover more than one bin diff -r 9e6b3e239b9d -r 13949a6970ab layer/SpectrogramLayer.cpp --- a/layer/SpectrogramLayer.cpp Fri Aug 04 17:01:37 2006 +0000 +++ b/layer/SpectrogramLayer.cpp Wed Aug 16 14:57:47 2006 +0000 @@ -1953,8 +1953,11 @@ displayMaxFreq = getEffectiveMaxFrequency(); } + //!!! we will probably only want one of "ymag+ydiv" and "ypeak", + //but we leave them both calculated here for test purposes float ymag[h]; float ydiv[h]; + float ypeak[h]; float yval[bins + 1]; //!!! cache this? size_t increment = getWindowIncrement(); @@ -1976,8 +1979,9 @@ for (int x = 0; x < w; ++x) { for (int y = 0; y < h; ++y) { - ymag[y] = 0.0; - ydiv[y] = 0.0; + ymag[y] = 0.f; + ydiv[y] = 0.f; + ypeak[y] = 0.f; } float s0 = 0, s1 = 0; @@ -2064,6 +2068,7 @@ if (y == y1i) yprop *= y1 - y; ymag[y] += yprop * value; ydiv[y] += yprop; + if (value > ypeak[y]) ypeak[y] = value; } } @@ -2086,7 +2091,8 @@ unsigned char pixel = 0; float avg = ymag[y] / ydiv[y]; - pixel = getDisplayValue(v, avg); +//!!! pixel = getDisplayValue(v, avg); + pixel = getDisplayValue(v, ypeak[y]); assert(x <= m_drawBuffer.width()); QColor c = m_colourMap.getColour(pixel);