00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef SPECTRAL_METER_H
00025 #define SPECTRAL_METER_H
00026
00027 #include "Plugin.h"
00028 #include "defines.h"
00029 #include <fftw3.h>
00030 #include <RingBufferNPT.h>
00031 #include <QVector>
00032
00033 class AudioBus;
00034
00035 struct SpectralMeterData
00036 {
00037 audio_sample_t* bufferLeft;
00038 audio_sample_t* bufferRight;
00039 };
00040
00041 class SpectralMeter : public Plugin
00042 {
00043 Q_OBJECT
00044
00045 public:
00046 SpectralMeter();
00047 ~SpectralMeter();
00048
00049 int init();
00050 QDomNode get_state(QDomDocument doc);
00051 int set_state(const QDomNode & node );
00052 void process(AudioBus* bus, unsigned long nframes);
00053 QString get_name();
00054 int get_fr_size();
00055 void set_fr_size(int);
00056 int get_windowing_function();
00057 void set_windowing_function(int);
00058
00059 int get_data(QVector<float>& specl, QVector<float>& specr);
00060
00061
00062 private:
00063 int m_frlen;
00064 int m_windowingFunction;
00065 int m_bufferreadouts;
00066
00067
00068 fftw_plan pfegl, pfegr;
00069 fftw_complex *fftspecl,*fftspecr;
00070 double *fftsigl,*fftsigr,*win;
00071 RingBufferNPT<float>* m_databufferL;
00072 RingBufferNPT<float>* m_databufferR;
00073
00074 float *NFArray(int size){
00075 float *p;
00076 p = (float *)calloc(size,sizeof(*p));
00077 return p;
00078 }
00079 double *NDArray(int size){
00080 double *p;
00081 p = (double *)calloc(size,sizeof(*p));
00082 return p;
00083 }
00084 int *NIArray(int size){
00085 int *p;
00086 p = (int *)calloc(size,sizeof(*p));
00087 return p;
00088 }
00089 fftw_complex *NFFTWArray(int size){
00090 fftw_complex *p;
00091 p = (fftw_complex *)fftw_malloc(size*sizeof(*p));
00092 return p;
00093 }
00094 };
00095
00096
00097 #endif