| 222 | } |
| 223 | |
| 224 | void |
| 225 | SpectrumView::feedHistogramMode( |
| 226 | const SUFLOAT *psdData, |
| 227 | SUFREQ freqMin, |
| 228 | SUFREQ freqMax) |
| 229 | { |
| 230 | SUFREQ relBw = (freqMax - freqMin) / this->freqRange; |
| 231 | SUFREQ fStart = (freqMin - this->freqMin) / this->freqRange; |
| 232 | SUFREQ fEnd = (freqMax - this->freqMin) / this->freqRange; |
| 233 | SUFLOAT t; |
| 234 | SUFLOAT inv = 1. / SIGDIGGER_SCANNER_SPECTRUM_SIZE; |
| 235 | unsigned int i; |
| 236 | SUFLOAT accum = 0; |
| 237 | |
| 238 | fStart *= SIGDIGGER_SCANNER_SPECTRUM_SIZE; |
| 239 | fEnd *= SIGDIGGER_SCANNER_SPECTRUM_SIZE; |
| 240 | relBw *= SIGDIGGER_SCANNER_SPECTRUM_SIZE; |
| 241 | |
| 242 | unsigned int j = static_cast<unsigned int>(fStart); |
| 243 | |
| 244 | // Now, relBw represents the relative size of the range |
| 245 | // with respecto to the spectrum bin. |
| 246 | |
| 247 | for (i = 0; i < SIGDIGGER_SCANNER_SPECTRUM_SIZE; ++i) |
| 248 | accum += psdData[i]; |
| 249 | |
| 250 | accum *= inv; |
| 251 | |
| 252 | assert(!std::isnan(inv)); |
| 253 | assert(!std::isnan(accum)); |
| 254 | |
| 255 | if (floor(fStart) != floor(fEnd)) { |
| 256 | // Between two bins. |
| 257 | t = static_cast<SUFLOAT>((fStart - floor(fStart)) / relBw); |
| 258 | |
| 259 | this->psdCount[j] += 1 - t; |
| 260 | this->psdAccum[j] += (1 - t) * accum; |
| 261 | |
| 262 | if (j + 1 < SIGDIGGER_SCANNER_SPECTRUM_SIZE) { |
| 263 | this->psdCount[j + 1] += t; |
| 264 | this->psdAccum[j + 1] += t * accum; |
| 265 | } |
| 266 | } else { |
| 267 | this->psdCount[j] += 1; |
| 268 | this->psdAccum[j] += accum; |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | void |
| 273 | SpectrumView::feed( |