Setronon
28th November 2012, 16:18
Hello,
I'm using this class:
#ifndef WAVE_H
#define WAVE_H
#include <QAudioFormat>
#include <QVector>
namespace ffft
{
template <typename T>
class FFTReal;
}
class Wave {
private:
QVector<unsigned char> buffer;
QAudioFormat format;
int dirtyBegin, dirtyEnd; // dirty = modified with respect to parent
Wave* parent;
QString name;
int disposed;
ffft::FFTReal<float>* fftreal;
QList<QVector<float> > fftChunks;
// Helper functions for get/set left/right
short getLeftRight (int index, bool left) const;
void initfft();
QVector<float> do_fft(QVector<float> input);
QVector<float> do_ifft(QVector<float> input);
QVector<float> fftChunkLeftRight(int i);
void ifftChunkLeftRight(int i, QVector<float> input);
void setLeftRight (int index, short value, bool left);
public:
// Ctor
Wave(QString name, const QVector<unsigned char>& buffer, const QAudioFormat& format);
// Copy ctor
explicit Wave(const Wave& wave);
// Name
QString getName() const { return name; }
void setName(QString name) { this->name=name; }
// High level API
int sampleCount() const;
void stretch(int samples);
int frequency() const;
int channels() const;
short getLeft(int index) const { return getLeftRight(index,true); }
short getRight(int index) const { return getLeftRight(index,false); }
void setLeft(int index, short value) { setLeftRight(index,value,true); }
void setRight(int index, short value);
// Low level API
const QAudioFormat& getFormat() const { return format; }
const QVector<unsigned char>& getRealBuffer() const { return buffer; }
const QVector<unsigned char>& getBuffer();
void setFormat(const QAudioFormat& format);
void setBuffer(const QVector<unsigned char>& buffer);
// FFT operations
static const int fftChunkSize;
int countFftChunks() const { return sampleCount() / fftChunkSize + 1; }
QVector<float> fftChunkLeft(int i) { return fftChunkLeftRight(i*2); }
QVector<float> fftChunkRight(int i) { return fftChunkLeftRight(i*2+1); }
void ifftChunkLeft(int i, QVector<float> input) { ifftChunkLeftRight(i*2, input); }
void ifftChunkRight(int i, QVector<float> input) { ifftChunkLeftRight(i*2+1, input); }
friend class WaveManager;
};
#endif // WAVE_H
I want to use this function "QVector<float> do_fft(QVector<float> input);" but have no idea, where/how to get this input vector of floats. And if someone can explain what represents this input vector. Thanks in advance :)
I'm using this class:
#ifndef WAVE_H
#define WAVE_H
#include <QAudioFormat>
#include <QVector>
namespace ffft
{
template <typename T>
class FFTReal;
}
class Wave {
private:
QVector<unsigned char> buffer;
QAudioFormat format;
int dirtyBegin, dirtyEnd; // dirty = modified with respect to parent
Wave* parent;
QString name;
int disposed;
ffft::FFTReal<float>* fftreal;
QList<QVector<float> > fftChunks;
// Helper functions for get/set left/right
short getLeftRight (int index, bool left) const;
void initfft();
QVector<float> do_fft(QVector<float> input);
QVector<float> do_ifft(QVector<float> input);
QVector<float> fftChunkLeftRight(int i);
void ifftChunkLeftRight(int i, QVector<float> input);
void setLeftRight (int index, short value, bool left);
public:
// Ctor
Wave(QString name, const QVector<unsigned char>& buffer, const QAudioFormat& format);
// Copy ctor
explicit Wave(const Wave& wave);
// Name
QString getName() const { return name; }
void setName(QString name) { this->name=name; }
// High level API
int sampleCount() const;
void stretch(int samples);
int frequency() const;
int channels() const;
short getLeft(int index) const { return getLeftRight(index,true); }
short getRight(int index) const { return getLeftRight(index,false); }
void setLeft(int index, short value) { setLeftRight(index,value,true); }
void setRight(int index, short value);
// Low level API
const QAudioFormat& getFormat() const { return format; }
const QVector<unsigned char>& getRealBuffer() const { return buffer; }
const QVector<unsigned char>& getBuffer();
void setFormat(const QAudioFormat& format);
void setBuffer(const QVector<unsigned char>& buffer);
// FFT operations
static const int fftChunkSize;
int countFftChunks() const { return sampleCount() / fftChunkSize + 1; }
QVector<float> fftChunkLeft(int i) { return fftChunkLeftRight(i*2); }
QVector<float> fftChunkRight(int i) { return fftChunkLeftRight(i*2+1); }
void ifftChunkLeft(int i, QVector<float> input) { ifftChunkLeftRight(i*2, input); }
void ifftChunkRight(int i, QVector<float> input) { ifftChunkLeftRight(i*2+1, input); }
friend class WaveManager;
};
#endif // WAVE_H
I want to use this function "QVector<float> do_fft(QVector<float> input);" but have no idea, where/how to get this input vector of floats. And if someone can explain what represents this input vector. Thanks in advance :)