mirror of
				https://github.com/cjcliffe/CubicSDR.git
				synced 2025-11-03 13:10:27 -05:00 
			
		
		
		
	svp header update
This commit is contained in:
		
							parent
							
								
									2e6b173fb1
								
							
						
					
					
						commit
						125a967ee3
					
				@ -69,75 +69,3 @@ private:
 | 
			
		||||
    std::atomic_int desiredInputSize;
 | 
			
		||||
    std::mutex busy_run;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class FFTDataDistributor : public VisualProcessor<DemodulatorThreadIQData, DemodulatorThreadIQData> {
 | 
			
		||||
public:
 | 
			
		||||
    FFTDataDistributor() : linesPerSecond(DEFAULT_WATERFALL_LPS), lineRateAccum(0.0) {
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    void setFFTSize(int fftSize) {
 | 
			
		||||
        this->fftSize = fftSize;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    void setLinesPerSecond(int lines) {
 | 
			
		||||
        this->linesPerSecond = lines;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    int getLinesPerSecond() {
 | 
			
		||||
        return this->linesPerSecond;
 | 
			
		||||
    }
 | 
			
		||||
protected:
 | 
			
		||||
    void process() {
 | 
			
		||||
        while (!input->empty()) {
 | 
			
		||||
            if (!isAnyOutputEmpty()) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            DemodulatorThreadIQData *inp;
 | 
			
		||||
            input->pop(inp);
 | 
			
		||||
 | 
			
		||||
            int fftSize = this->fftSize;
 | 
			
		||||
            
 | 
			
		||||
            if (fftSize > inp->data.size()) {
 | 
			
		||||
                fftSize = inp->data.size();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // number of milliseconds contained in input
 | 
			
		||||
            double inputTime = (double)inp->data.size() / (double)inp->sampleRate;
 | 
			
		||||
            // number of lines in input
 | 
			
		||||
            int inputLines = floor((double)inp->data.size()/(double)fftSize);
 | 
			
		||||
            
 | 
			
		||||
            // ratio required to achieve the desired rate
 | 
			
		||||
            double lineRateStep = ((double)linesPerSecond * inputTime)/(double)inputLines;
 | 
			
		||||
            
 | 
			
		||||
            if (inp) {
 | 
			
		||||
                if (inp->data.size() >= fftSize) {
 | 
			
		||||
                    if (lineRateAccum + (lineRateStep * floor((double)inp->data.size()/(double)fftSize)) < 1.0) {
 | 
			
		||||
                         // move along, nothing to see here..
 | 
			
		||||
                        lineRateAccum += (lineRateStep * inp->data.size()/fftSize);
 | 
			
		||||
                    } else for (int i = 0, iMax = inp->data.size()-fftSize; i <= iMax; i += fftSize) {
 | 
			
		||||
                        lineRateAccum += lineRateStep;
 | 
			
		||||
                        
 | 
			
		||||
                        if (lineRateAccum >= 1.0) {
 | 
			
		||||
                            DemodulatorThreadIQData *outp = outputBuffers.getBuffer();
 | 
			
		||||
                            outp->frequency = inp->frequency;
 | 
			
		||||
                            outp->sampleRate = inp->sampleRate;
 | 
			
		||||
                            outp->data.assign(inp->data.begin()+i,inp->data.begin()+i+fftSize);
 | 
			
		||||
                            distribute(outp);
 | 
			
		||||
                            
 | 
			
		||||
                            while (lineRateAccum >= 1.0) {
 | 
			
		||||
                                lineRateAccum -= 1.0;
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                inp->decRefCount();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    ReBuffer<DemodulatorThreadIQData> outputBuffers;
 | 
			
		||||
    int fftSize;
 | 
			
		||||
    int linesPerSecond;
 | 
			
		||||
    double lineRateAccum;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user