00001 /* 00002 * Copyright: (C) 1999-2001 Bruce W. Forsberg 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this library; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Bruce Forsberg forsberg@tns.net 00019 * 00020 */ 00021 00022 00023 #ifndef _AFLIBAUDIOSPECTRUM_H_ 00024 #define _AFLIBAUDIOSPECTRUM_H_ 00025 00026 #ifdef HAVE_CONFIG_H 00027 #include <config.h> 00028 #endif 00029 00030 #include "aflibAudio.h" 00031 #include "aflibFFT.h" 00032 00033 #define MAX_ARRAY_SIZE 1024 00034 00035 typedef void (*powermeter_callback)(double *); 00036 typedef void (*spectrum_callback)(int, double *); 00037 00048 class aflibAudioSpectrum : public aflibAudio { 00049 00050 public: 00051 00052 // Available contructors and destructors 00053 aflibAudioSpectrum(aflibAudio& audio); 00054 ~aflibAudioSpectrum(); 00055 00056 bool 00057 setParameters( 00058 int num_samples, 00059 int resp_per_sec, 00060 int channels); 00061 00062 void 00063 setPowerMeterCallback( powermeter_callback func_ptr); 00064 00065 void 00066 setAudioSpectrumCallback( spectrum_callback func_ptr); 00067 00068 void 00069 setInputConfig(const aflibConfig& cfg); 00070 00071 aflibStatus 00072 compute_segment( 00073 list<aflibData *>& data, 00074 long long position = -1) ; 00075 00077 const char * 00078 getName() const { return "aflibAudioSpectrum";}; 00079 00080 protected: 00081 00082 virtual void 00083 setPowerMeter(double*); 00084 00085 virtual void 00086 setAudioSpectrum(int, double*); 00087 00088 bool _pm; 00089 bool _spectrum; 00090 private: 00091 00092 aflibAudioSpectrum(); 00093 00094 aflibAudioSpectrum(const aflibAudioSpectrum& op); 00095 00096 const aflibAudioSpectrum& 00097 operator=(const aflibAudioSpectrum& op); 00098 00099 void 00100 allocateMemory(); 00101 00102 aflibFFT _fft; 00103 int _num_samples; 00104 int _responses; 00105 int _channels; 00106 int _samples_between_responses; 00107 int _samples_counter; 00108 double * _in_real; 00109 double * _power_out; 00110 double * _spec_out; 00111 powermeter_callback _pm_func_ptr; 00112 spectrum_callback _spectrum_func_ptr; 00113 00114 }; 00115 00116 00117 #endif