MCPcopy Create free account
hub / github.com/BatchDrake/SigDigger / feedHistogramMode

Method feedHistogramMode

Panoramic/Scanner.cpp:224–270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222}
223
224void
225SpectrumView::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
272void
273SpectrumView::feed(

Callers 1

feedMethod · 0.95

Calls 1

isnanFunction · 0.85

Tested by

no test coverage detected