MCPcopy Create free account
hub / github.com/cjcliffe/CubicSDR / runDemodChannels

Method runDemodChannels

src/sdr/SDRPostThread.cpp:303–398  ·  view source on GitHub ↗

Handle active channels, channel 0 offset correction, de-interlacing and push data to demodulators

Source from the content-addressed store, hash-verified

301
302// Handle active channels, channel 0 offset correction, de-interlacing and push data to demodulators
303void SDRPostThread::runDemodChannels(int channelBandwidth) {
304 DemodulatorInstancePtr activeDemod = wxGetApp().getDemodMgr().getCurrentModem();
305
306 // Calculate channel data size
307 size_t chanDataSize = dataOut.size()/numChannels;
308
309 // Channel for the 'active' demod that's displaying visual data
310 int activeDemodChannel = -1;
311
312 for (int i = 0, iMax = numChannels+1; i < iMax; i++) {
313 demodChannelActive[i] = 0;
314 }
315
316 // Find nearest channel for each demodulator
317 for (size_t i = 0; i < runDemods.size(); i++) {
318 DemodulatorInstancePtr demod = runDemods[i];
319 demodChannel[i] = getChannelAt(demod->getFrequency());
320 if (demod == activeDemod) {
321 activeDemodChannel = demodChannel[i];
322 }
323 }
324
325 // Count the demods per-channel
326 for (size_t i = 0; i < runDemods.size(); i++) {
327 if (demodChannel[i] >= 0) {
328 demodChannelActive[demodChannel[i]]++;
329 }
330 }
331
332 // Run channels
333 for (int i = 0; i < numChannels+1; i++) {
334 bool doDemodVis = (activeDemodChannel == i) && (iqActiveDemodVisualQueue != nullptr);
335
336 if (!doDemodVis && demodChannelActive[i] == 0) {
337 // Nothing to do for this channel? continue.
338 continue;
339 }
340
341 // Get a channel buffer
342 DemodulatorThreadIQDataPtr demodDataOut = buffers.getBuffer();
343 demodDataOut->frequency = chanCenters[i];
344 demodDataOut->sampleRate = channelBandwidth;
345
346 // Resize and update capacity of buffer if necessary
347 if (demodDataOut->data.size() != chanDataSize) {
348 if (demodDataOut->data.capacity() < chanDataSize) {
349 demodDataOut->data.reserve(chanDataSize);
350 }
351 demodDataOut->data.resize(chanDataSize);
352 }
353
354 // Start copying interleaved data at given channel index
355 int idx = i;
356
357 // Extra channel wraps left side band of lowest channel
358 // to fix frequency gap on right side of spectrum
359 if (i == numChannels) {
360 idx = (numChannels/2);

Callers

nothing calls this directly

Calls 8

getCurrentModemMethod · 0.80
getBufferMethod · 0.80
capacityMethod · 0.80
reserveMethod · 0.80
try_pushMethod · 0.80
getIQInputDataPipeMethod · 0.80
sizeMethod · 0.45
getFrequencyMethod · 0.45

Tested by

no test coverage detected