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

Method feedLinearMode

Panoramic/Scanner.cpp:103–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101}
102
103void
104SpectrumView::feedLinearMode(
105 const SUFLOAT *psdData,
106 const SUFLOAT *countData,
107 SUFREQ freqMin,
108 SUFREQ freqMax,
109 bool adjustSides)
110{
111 SUFREQ inpBw;
112 SUFREQ bw;
113 SUFLOAT fftCount; // Number of FFTs in a full spectrum
114 SUFLOAT bins;
115 int skip;
116 int i, j = 0, p = 0;
117 int pieceWidth;
118 int startBin, endBin;
119 int scaledLen;
120 SUFLOAT psdAccum = 0, psdCount = 0;
121 SUFREQ pos = 0;
122 SUFLOAT accPrev, accCurr;
123 SUFLOAT cntPrev, cntCurr;
124 SUFLOAT x, c;
125 SUFLOAT t = 0;
126 SUFLOAT delta;
127 SUFREQ freqSkip;
128 SUFLOAT tStart, tEnd;
129
130 // Compute subrange inside PSD message
131 inpBw = freqMax - freqMin;
132 if (adjustSides) {
133 skip = static_cast<int>(
134 .5f * (1 - this->fftRelBw) * SIGDIGGER_SCANNER_SPECTRUM_SIZE);
135 } else {
136 skip = 0;
137 }
138
139 freqSkip = static_cast<SUFREQ>(skip) / SIGDIGGER_SCANNER_SPECTRUM_SIZE
140 * inpBw;
141 pieceWidth = SIGDIGGER_SCANNER_SPECTRUM_SIZE - 2 * skip;
142 bw = inpBw - 2 * freqSkip;
143 assert(skip >= 0);
144
145 // Delicate step 1: Average in blocks of fftCount.
146 // In this range, we can fit fftCount = range / bw pieces
147 // Each piece is w = SIGDIGGER_SCANNER_SPECTRUM_SIZE / fftCount bins wide
148 // We must average SIGDIGGER_SCANNER_SPECTRUM_SIZE / w = fftCount bins
149
150 // Compute dimension variables.
151 fftCount = static_cast<SUFLOAT>(this->freqRange / bw); // How many FFTs fit in here.
152 bins = SIGDIGGER_SCANNER_SPECTRUM_SIZE / fftCount; // Target bin count
153 delta = static_cast<SUFLOAT>(pieceWidth - 1) / bins;
154 scaledLen = static_cast<int>(SU_FLOOR(bins));
155
156 if (scaledLen > SIGDIGGER_SCANNER_SPECTRUM_SIZE)
157 scaledLen = SIGDIGGER_SCANNER_SPECTRUM_SIZE;
158
159 // This is basically a linear scale
160 for (i = 0; i < scaledLen; ++i) {

Callers 1

feedMethod · 0.95

Calls 1

isnanFunction · 0.85

Tested by

no test coverage detected