mirror of
				https://github.com/f4exb/sdrangel.git
				synced 2025-10-31 13:00:26 -04:00 
			
		
		
		
	Deep redesign: use references for the iterator parameters of the sample sinks feed method
This commit is contained in:
		
							parent
							
								
									fb2e601a03
								
							
						
					
					
						commit
						005eae774e
					
				| @ -38,7 +38,7 @@ public: | |||||||
| 
 | 
 | ||||||
| 	virtual void start(); | 	virtual void start(); | ||||||
| 	virtual void stop(); | 	virtual void stop(); | ||||||
| 	virtual void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly); | 	virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly); | ||||||
| 	virtual bool handleMessage(const Message& cmd); | 	virtual bool handleMessage(const Message& cmd); | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
|  | |||||||
| @ -28,7 +28,7 @@ public: | |||||||
| 
 | 
 | ||||||
| 	void configure(MessageQueue* msgQueue, const std::string& filename); | 	void configure(MessageQueue* msgQueue, const std::string& filename); | ||||||
| 
 | 
 | ||||||
| 	virtual void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly); | 	virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly); | ||||||
| 	virtual void start(); | 	virtual void start(); | ||||||
| 	virtual void stop(); | 	virtual void stop(); | ||||||
| 	virtual bool handleMessage(const Message& message); | 	virtual bool handleMessage(const Message& message); | ||||||
|  | |||||||
| @ -35,7 +35,7 @@ public: | |||||||
|         uint traceSize); |         uint traceSize); | ||||||
| 	void setOneShot(bool oneShot); | 	void setOneShot(bool oneShot); | ||||||
| 
 | 
 | ||||||
| 	virtual void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly); | 	virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly); | ||||||
| 	virtual void start(); | 	virtual void start(); | ||||||
| 	virtual void stop(); | 	virtual void stop(); | ||||||
| 	virtual bool handleMessage(const Message& message); | 	virtual bool handleMessage(const Message& message); | ||||||
|  | |||||||
| @ -14,7 +14,7 @@ public: | |||||||
| 	SpectrumScopeComboVis(SpectrumVis* spectrumVis, ScopeVis* scopeVis); | 	SpectrumScopeComboVis(SpectrumVis* spectrumVis, ScopeVis* scopeVis); | ||||||
| 	virtual ~SpectrumScopeComboVis(); | 	virtual ~SpectrumScopeComboVis(); | ||||||
| 
 | 
 | ||||||
| 	virtual void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly); | 	virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly); | ||||||
| 	virtual void start(); | 	virtual void start(); | ||||||
| 	virtual void stop(); | 	virtual void stop(); | ||||||
| 	virtual bool handleMessage(const Message& message); | 	virtual bool handleMessage(const Message& message); | ||||||
|  | |||||||
| @ -39,8 +39,8 @@ public: | |||||||
| 
 | 
 | ||||||
| 	void configure(MessageQueue* msgQueue, int fftSize, int overlapPercent, FFTWindow::Function window); | 	void configure(MessageQueue* msgQueue, int fftSize, int overlapPercent, FFTWindow::Function window); | ||||||
| 
 | 
 | ||||||
| 	virtual void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly); | 	virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly); | ||||||
| 	void feedTriggered(SampleVector::const_iterator triggerPoint, SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly); | 	void feedTriggered(const SampleVector::const_iterator& triggerPoint, const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly); | ||||||
| 	virtual void start(); | 	virtual void start(); | ||||||
| 	virtual void stop(); | 	virtual void stop(); | ||||||
| 	virtual bool handleMessage(const Message& message); | 	virtual bool handleMessage(const Message& message); | ||||||
|  | |||||||
| @ -16,7 +16,7 @@ public: | |||||||
| 
 | 
 | ||||||
| 	virtual void start() = 0; | 	virtual void start() = 0; | ||||||
| 	virtual void stop() = 0; | 	virtual void stop() = 0; | ||||||
| 	virtual void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly) = 0; | 	virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly) = 0; | ||||||
| 	virtual bool handleMessage(const Message& cmd) = 0; //!< Processing of a message. Returns true if message has actually been processed
 | 	virtual bool handleMessage(const Message& cmd) = 0; //!< Processing of a message. Returns true if message has actually been processed
 | ||||||
| 
 | 
 | ||||||
| 	MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } //!< Get the queue for asynchronous inbound communication
 | 	MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } //!< Get the queue for asynchronous inbound communication
 | ||||||
|  | |||||||
| @ -63,7 +63,7 @@ void AMDemod::configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBan | |||||||
| 	messageQueue->push(cmd); | 	messageQueue->push(cmd); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void AMDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool firstOfBurst) | void AMDemod::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool firstOfBurst) | ||||||
| { | { | ||||||
| 	Complex ci; | 	Complex ci; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -36,7 +36,7 @@ public: | |||||||
| 
 | 
 | ||||||
| 	void configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, Real volume, Real squelch); | 	void configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, Real volume, Real squelch); | ||||||
| 
 | 
 | ||||||
| 	virtual void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool po); | 	virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po); | ||||||
| 	virtual void start(); | 	virtual void start(); | ||||||
| 	virtual void stop(); | 	virtual void stop(); | ||||||
| 	virtual bool handleMessage(const Message& cmd); | 	virtual bool handleMessage(const Message& cmd); | ||||||
|  | |||||||
| @ -60,7 +60,7 @@ void ChannelAnalyzer::configure(MessageQueue* messageQueue, | |||||||
| 	messageQueue->push(cmd); | 	messageQueue->push(cmd); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ChannelAnalyzer::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly) | void ChannelAnalyzer::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly) | ||||||
| { | { | ||||||
| 	fftfilt::cmplx *sideband, sum; | 	fftfilt::cmplx *sideband, sum; | ||||||
| 	int n_out; | 	int n_out; | ||||||
|  | |||||||
| @ -43,7 +43,7 @@ public: | |||||||
| 		return m_sampleRate; | 		return m_sampleRate; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	virtual void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly); | 	virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly); | ||||||
| 	virtual void start(); | 	virtual void start(); | ||||||
| 	virtual void stop(); | 	virtual void stop(); | ||||||
| 	virtual bool handleMessage(const Message& cmd); | 	virtual bool handleMessage(const Message& cmd); | ||||||
|  | |||||||
| @ -236,7 +236,7 @@ int LoRaDemod::detect(Complex c, Complex a) | |||||||
| 	return m_result; | 	return m_result; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void LoRaDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool pO) | void LoRaDemod::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool pO) | ||||||
| { | { | ||||||
| 	int newangle; | 	int newangle; | ||||||
| 	Complex ci; | 	Complex ci; | ||||||
|  | |||||||
| @ -39,7 +39,7 @@ public: | |||||||
| 
 | 
 | ||||||
| 	void configure(MessageQueue* messageQueue, Real Bandwidth); | 	void configure(MessageQueue* messageQueue, Real Bandwidth); | ||||||
| 
 | 
 | ||||||
| 	virtual void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool pO); | 	virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool pO); | ||||||
| 	virtual void start(); | 	virtual void start(); | ||||||
| 	virtual void stop(); | 	virtual void stop(); | ||||||
| 	virtual bool handleMessage(const Message& cmd); | 	virtual bool handleMessage(const Message& cmd); | ||||||
|  | |||||||
| @ -106,7 +106,7 @@ Real angleDist(Real a, Real b) | |||||||
| 	return dist; | 	return dist; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void NFMDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool firstOfBurst) | void NFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool firstOfBurst) | ||||||
| { | { | ||||||
| 	Complex ci; | 	Complex ci; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -41,7 +41,7 @@ public: | |||||||
| 
 | 
 | ||||||
| 	void configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, Real volume, Real squelch); | 	void configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, Real volume, Real squelch); | ||||||
| 
 | 
 | ||||||
| 	virtual void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool po); | 	virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po); | ||||||
| 	virtual void start(); | 	virtual void start(); | ||||||
| 	virtual void stop(); | 	virtual void stop(); | ||||||
| 	virtual bool handleMessage(const Message& cmd); | 	virtual bool handleMessage(const Message& cmd); | ||||||
|  | |||||||
| @ -71,7 +71,7 @@ void SSBDemod::configure(MessageQueue* messageQueue, Real Bandwidth, Real LowCut | |||||||
| 	messageQueue->push(cmd); | 	messageQueue->push(cmd); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void SSBDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly) | void SSBDemod::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly) | ||||||
| { | { | ||||||
| 	Complex ci; | 	Complex ci; | ||||||
| 	fftfilt::cmplx *sideband, sum; | 	fftfilt::cmplx *sideband, sum; | ||||||
|  | |||||||
| @ -36,7 +36,7 @@ public: | |||||||
| 
 | 
 | ||||||
| 	void configure(MessageQueue* messageQueue, Real Bandwidth, Real LowCutoff, Real volume, int spanLog2); | 	void configure(MessageQueue* messageQueue, Real Bandwidth, Real LowCutoff, Real volume, int spanLog2); | ||||||
| 
 | 
 | ||||||
| 	virtual void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly); | 	virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly); | ||||||
| 	virtual void start(); | 	virtual void start(); | ||||||
| 	virtual void stop(); | 	virtual void stop(); | ||||||
| 	virtual bool handleMessage(const Message& cmd); | 	virtual bool handleMessage(const Message& cmd); | ||||||
|  | |||||||
| @ -71,7 +71,7 @@ void TCPSrc::setSpectrum(MessageQueue* messageQueue, bool enabled) | |||||||
| 	messageQueue->push(cmd); | 	messageQueue->push(cmd); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void TCPSrc::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly) | void TCPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly) | ||||||
| { | { | ||||||
| 	Complex ci; | 	Complex ci; | ||||||
| 	fftfilt::cmplx* sideband; | 	fftfilt::cmplx* sideband; | ||||||
|  | |||||||
| @ -32,7 +32,7 @@ public: | |||||||
| 	void configure(MessageQueue* messageQueue, SampleFormat sampleFormat, Real outputSampleRate, Real rfBandwidth, int tcpPort, int boost); | 	void configure(MessageQueue* messageQueue, SampleFormat sampleFormat, Real outputSampleRate, Real rfBandwidth, int tcpPort, int boost); | ||||||
| 	void setSpectrum(MessageQueue* messageQueue, bool enabled); | 	void setSpectrum(MessageQueue* messageQueue, bool enabled); | ||||||
| 
 | 
 | ||||||
| 	virtual void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly); | 	virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly); | ||||||
| 	virtual void start(); | 	virtual void start(); | ||||||
| 	virtual void stop(); | 	virtual void stop(); | ||||||
| 	virtual bool handleMessage(const Message& cmd); | 	virtual bool handleMessage(const Message& cmd); | ||||||
|  | |||||||
| @ -69,7 +69,7 @@ void WFMDemod::configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBa | |||||||
| 	messageQueue->push(cmd); | 	messageQueue->push(cmd); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void WFMDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool firstOfBurst) | void WFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool firstOfBurst) | ||||||
| { | { | ||||||
| 	Complex ci; | 	Complex ci; | ||||||
| 	fftfilt::cmplx *rf; | 	fftfilt::cmplx *rf; | ||||||
|  | |||||||
| @ -38,7 +38,7 @@ public: | |||||||
| 
 | 
 | ||||||
| 	void configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, Real volume, Real squelch); | 	void configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, Real volume, Real squelch); | ||||||
| 
 | 
 | ||||||
| 	virtual void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool po); | 	virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po); | ||||||
| 	virtual void start(); | 	virtual void start(); | ||||||
| 	virtual void stop(); | 	virtual void stop(); | ||||||
| 	virtual bool handleMessage(const Message& cmd); | 	virtual bool handleMessage(const Message& cmd); | ||||||
|  | |||||||
| @ -30,7 +30,7 @@ void Channelizer::configure(MessageQueue* messageQueue, int sampleRate, int cent | |||||||
| 	messageQueue->push(cmd); | 	messageQueue->push(cmd); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void Channelizer::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly) | void Channelizer::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly) | ||||||
| { | { | ||||||
| 	if(m_sampleSink == 0) { | 	if(m_sampleSink == 0) { | ||||||
| 		m_sampleBuffer.clear(); | 		m_sampleBuffer.clear(); | ||||||
|  | |||||||
| @ -30,7 +30,7 @@ void FileSink::configure(MessageQueue* msgQueue, const std::string& filename) | |||||||
| 	msgQueue->push(cmd); | 	msgQueue->push(cmd); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void FileSink::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly) | void FileSink::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly) | ||||||
| { | { | ||||||
|     // if no recording is active, send the samples to /dev/null
 |     // if no recording is active, send the samples to /dev/null
 | ||||||
|     if(!m_recordOn) |     if(!m_recordOn) | ||||||
|  | |||||||
| @ -55,8 +55,10 @@ void ScopeVis::configure(MessageQueue* msgQueue, | |||||||
| 	msgQueue->push(cmd); | 	msgQueue->push(cmd); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ScopeVis::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly) | void ScopeVis::feed(const SampleVector::const_iterator& cbegin, const SampleVector::const_iterator& end, bool positiveOnly) | ||||||
| { | { | ||||||
|  | 	SampleVector::const_iterator begin(cbegin); | ||||||
|  | 
 | ||||||
| 	if (m_triggerChannel == TriggerFreeRun) { | 	if (m_triggerChannel == TriggerFreeRun) { | ||||||
| 		m_triggerPoint = begin; | 		m_triggerPoint = begin; | ||||||
| 	} | 	} | ||||||
|  | |||||||
| @ -13,7 +13,7 @@ SpectrumScopeComboVis::~SpectrumScopeComboVis() | |||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void SpectrumScopeComboVis::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly) | void SpectrumScopeComboVis::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly) | ||||||
| { | { | ||||||
| 	m_scopeVis->feed(begin, end, false); | 	m_scopeVis->feed(begin, end, false); | ||||||
| 	SampleVector::const_iterator triggerPoint = m_scopeVis->getTriggerPoint(); | 	SampleVector::const_iterator triggerPoint = m_scopeVis->getTriggerPoint(); | ||||||
|  | |||||||
| @ -38,7 +38,7 @@ void SpectrumVis::configure(MessageQueue* msgQueue, int fftSize, int overlapPerc | |||||||
| 	msgQueue->push(cmd); | 	msgQueue->push(cmd); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void SpectrumVis::feedTriggered(SampleVector::const_iterator triggerPoint, SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly) | void SpectrumVis::feedTriggered(const SampleVector::const_iterator& triggerPoint, const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly) | ||||||
| { | { | ||||||
| 	feed(triggerPoint, end, positiveOnly); // normal feed from trigger point
 | 	feed(triggerPoint, end, positiveOnly); // normal feed from trigger point
 | ||||||
| 	/*
 | 	/*
 | ||||||
| @ -59,21 +59,31 @@ void SpectrumVis::feedTriggered(SampleVector::const_iterator triggerPoint, Sampl | |||||||
| 	}*/ | 	}*/ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void SpectrumVis::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly) | void SpectrumVis::feed(const SampleVector::const_iterator& cbegin, const SampleVector::const_iterator& end, bool positiveOnly) | ||||||
| { | { | ||||||
| 	// if no visualisation is set, send the samples to /dev/null
 | 	// if no visualisation is set, send the samples to /dev/null
 | ||||||
| 	if(m_glSpectrum == NULL) |  | ||||||
| 		return; |  | ||||||
| 
 | 
 | ||||||
| 	while(begin < end) { | 	if(m_glSpectrum == 0) | ||||||
|  | 	{ | ||||||
|  | 		return; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	SampleVector::const_iterator begin(cbegin); | ||||||
|  | 
 | ||||||
|  | 	while (begin < end) | ||||||
|  | 	{ | ||||||
| 		std::size_t todo = end - begin; | 		std::size_t todo = end - begin; | ||||||
| 		std::size_t samplesNeeded = m_refillSize - m_fftBufferFill; | 		std::size_t samplesNeeded = m_refillSize - m_fftBufferFill; | ||||||
| 
 | 
 | ||||||
| 		if(todo >= samplesNeeded) { | 		if (todo >= samplesNeeded) | ||||||
|  | 		{ | ||||||
| 			// fill up the buffer
 | 			// fill up the buffer
 | ||||||
| 			std::vector<Complex>::iterator it = m_fftBuffer.begin() + m_fftBufferFill; | 			std::vector<Complex>::iterator it = m_fftBuffer.begin() + m_fftBufferFill; | ||||||
| 			for(std::size_t i = 0; i < samplesNeeded; ++i, ++begin) | 
 | ||||||
|  | 			for (std::size_t i = 0; i < samplesNeeded; ++i, ++begin) | ||||||
|  | 			{ | ||||||
| 				*it++ = Complex(begin->real() / 32768.0, begin->imag() / 32768.0); | 				*it++ = Complex(begin->real() / 32768.0, begin->imag() / 32768.0); | ||||||
|  | 			} | ||||||
| 
 | 
 | ||||||
| 			// apply fft window (and copy from m_fftBuffer to m_fftIn)
 | 			// apply fft window (and copy from m_fftBuffer to m_fftIn)
 | ||||||
| 			m_window.apply(&m_fftBuffer[0], m_fft->in()); | 			m_window.apply(&m_fftBuffer[0], m_fft->in()); | ||||||
| @ -89,16 +99,21 @@ void SpectrumVis::feed(SampleVector::const_iterator begin, SampleVector::const_i | |||||||
| 			Real v; | 			Real v; | ||||||
| 			std::size_t halfSize = m_fftSize / 2; | 			std::size_t halfSize = m_fftSize / 2; | ||||||
| 
 | 
 | ||||||
| 			if ( positiveOnly ) { | 			if ( positiveOnly ) | ||||||
| 				for(std::size_t i = 0; i < halfSize; i++) { | 			{ | ||||||
|  | 				for (std::size_t i = 0; i < halfSize; i++) | ||||||
|  | 				{ | ||||||
| 					c = fftOut[i]; | 					c = fftOut[i]; | ||||||
| 					v = c.real() * c.real() + c.imag() * c.imag(); | 					v = c.real() * c.real() + c.imag() * c.imag(); | ||||||
| 					v = mult * log2f(v) + ofs; | 					v = mult * log2f(v) + ofs; | ||||||
| 					m_logPowerSpectrum[i * 2] = v; | 					m_logPowerSpectrum[i * 2] = v; | ||||||
| 					m_logPowerSpectrum[i * 2 + 1] = v; | 					m_logPowerSpectrum[i * 2 + 1] = v; | ||||||
| 				} | 				} | ||||||
| 			} else { | 			} | ||||||
| 				for(std::size_t i = 0; i < halfSize; i++) { | 			else | ||||||
|  | 			{ | ||||||
|  | 				for (std::size_t i = 0; i < halfSize; i++) | ||||||
|  | 				{ | ||||||
| 					c = fftOut[i + halfSize]; | 					c = fftOut[i + halfSize]; | ||||||
| 					v = c.real() * c.real() + c.imag() * c.imag(); | 					v = c.real() * c.real() + c.imag() * c.imag(); | ||||||
| 					v = mult * log2f(v) + ofs; | 					v = mult * log2f(v) + ofs; | ||||||
| @ -120,10 +135,15 @@ void SpectrumVis::feed(SampleVector::const_iterator begin, SampleVector::const_i | |||||||
| 			// start over
 | 			// start over
 | ||||||
| 			m_fftBufferFill = m_overlapSize; | 			m_fftBufferFill = m_overlapSize; | ||||||
| 			m_needMoreSamples = false; | 			m_needMoreSamples = false; | ||||||
| 		} else { | 		} | ||||||
|  | 		else | ||||||
|  | 		{ | ||||||
| 			// not enough samples for FFT - just fill in new data and return
 | 			// not enough samples for FFT - just fill in new data and return
 | ||||||
| 			for(std::vector<Complex>::iterator it = m_fftBuffer.begin() + m_fftBufferFill; begin < end; ++begin) | 			for(std::vector<Complex>::iterator it = m_fftBuffer.begin() + m_fftBufferFill; begin < end; ++begin) | ||||||
|  | 			{ | ||||||
| 				*it++ = Complex(begin->real() / 32768.0, begin->imag() / 32768.0); | 				*it++ = Complex(begin->real() / 32768.0, begin->imag() / 32768.0); | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
| 			m_fftBufferFill += todo; | 			m_fftBufferFill += todo; | ||||||
| 			m_needMoreSamples = true; | 			m_needMoreSamples = true; | ||||||
| 		} | 		} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user