6 #define MAX_FFT_SIZE 4096 9 inline double log2f(
double n)
25 m_needMoreSamples(false),
27 m_glSpectrum(glSpectrum),
29 m_avgMode(AvgModeNone),
33 m_mutex(QMutex::Recursive)
35 setObjectName(
"SpectrumVis");
47 unsigned int averagingNb,
56 void SpectrumVis::feedTriggered(
const SampleVector::const_iterator& triggerPoint,
const SampleVector::const_iterator& end,
bool positiveOnly)
58 feed(triggerPoint, end, positiveOnly);
77 void SpectrumVis::feed(
const SampleVector::const_iterator& cbegin,
const SampleVector::const_iterator& end,
bool positiveOnly)
89 SampleVector::const_iterator begin(cbegin);
93 std::size_t todo = end - begin;
96 if (todo >= samplesNeeded)
101 for (std::size_t
i = 0;
i < samplesNeeded; ++
i, ++begin)
122 for (std::size_t
i = 0;
i < halfSize;
i++)
125 v = c.real() * c.real() + c.imag() * c.imag();
133 for (std::size_t
i = 0;
i < halfSize;
i++)
135 c = fftOut[
i + halfSize];
136 v = c.real() * c.real() + c.imag() * c.imag();
141 v = c.real() * c.real() + c.imag() * c.imag();
154 for (std::size_t
i = 0;
i < halfSize;
i++)
157 v = c.real() * c.real() + c.imag() * c.imag();
166 for (std::size_t
i = 0;
i < halfSize;
i++)
168 c = fftOut[
i + halfSize];
169 v = c.real() * c.real() + c.imag() * c.imag();
175 v = c.real() * c.real() + c.imag() * c.imag();
192 for (std::size_t
i = 0;
i < halfSize;
i++)
195 v = c.real() * c.real() + c.imag() * c.imag();
207 for (std::size_t
i = 0;
i < halfSize;
i++)
209 c = fftOut[
i + halfSize];
210 v = c.real() * c.real() + c.imag() * c.imag();
219 v = c.real() * c.real() + c.imag() * c.imag();
239 for (std::size_t
i = 0;
i < halfSize;
i++)
242 v = c.real() * c.real() + c.imag() * c.imag();
254 for (std::size_t
i = 0;
i < halfSize;
i++)
256 c = fftOut[
i + halfSize];
257 v = c.real() * c.real() + c.imag() * c.imag();
266 v = c.real() * c.real() + c.imag() * c.imag();
296 m_fftBufferFill += todo;
333 unsigned int averageNb,
340 QMutexLocker mutexLocker(&
m_mutex);
346 else if (fftSize < 64)
351 if (overlapPercent > 100)
355 else if (overlapPercent < 0)
SpectrumVis(Real scalef, GLSpectrum *glSpectrum=0)
void push(Message *message, bool emitSignal=true)
Push message onto queue.
GLSpectrum * m_glSpectrum
void resize(unsigned int width, unsigned int depth)
std::size_t m_overlapSize
void create(Function function, int n)
FixedAverage2D< double > m_fixedAverage
void apply(const std::vector< Real > &in, std::vector< Real > *out)
virtual bool handleMessage(const Message &message)
Processing of a message. Returns true if message has actually been processed.
std::size_t m_overlapPercent
bool storeAndGetAvg(T &avg, T v, unsigned int index)
virtual void transform()=0
bool storeAndGetMax(T &max, T v, unsigned int index)
virtual void configure(int n, bool inverse)=0
void resize(unsigned int width, unsigned int size)
void * create(QString type)
#define MESSAGE_CLASS_DEFINITION(Name, BaseClass)
void resize(unsigned int width, unsigned int size)
Fixed< IntType, IntBits > log(Fixed< IntType, IntBits > const &x)
std::vector< Real > m_powerSpectrum
std::size_t m_fftBufferFill
static bool match(const Message *message)
void newSpectrum(const std::vector< Real > &spectrum, int fftSize)
void handleConfigure(int fftSize, int overlapPercent, unsigned int averageNb, AvgMode averagingMode, FFTWindow::Function window, bool linear)
void feedTriggered(const SampleVector::const_iterator &triggerPoint, const SampleVector::const_iterator &end, bool positiveOnly)
virtual void feed(const SampleVector::const_iterator &begin, const SampleVector::const_iterator &end, bool positiveOnly)
void configure(MessageQueue *msgQueue, int fftSize, int overlapPercent, unsigned int averagingNb, int averagingMode, FFTWindow::Function window, bool m_linear)
virtual Complex * out()=0
T storeAndGetAvg(T v, unsigned int index)
MovingAverage2D< double > m_movingAverage
std::complex< Real > Complex
T max(const T &x, const T &y)
std::vector< Complex > m_fftBuffer