00001 #ifndef SEABEA_SONAR_FFTBINPREDICTION_H 00002 #define SEABEA_SONAR_FFTBINPREDICTION_H 00003 00004 00005 // The FFTBinAffinePrediciton class uses an affine function defined by its 00006 // slope and offset to predict the bin number that a frequency will occupy 00007 // in an FFT based on the bitrate selected for the Cheetah SPI device. The 00008 // affine function has been selected as the prediction modeled based on 00009 // experimental data collected from the TotalPhase Cheetah SPI device. 00010 class FFTBinAffinePrediction { 00011 public: 00012 FFTBinAffinePrediction(int cheetah_bitrate, int fft_length, 00013 double target_frequency, double slope, 00014 double offset, int halfwidth); 00015 ~FFTBinAffinePrediction(); 00016 00017 // Accessors 00018 int getBitrate(); 00019 int getFFTLength(); 00020 double getTargetFrequency(); 00021 double getSlope(); 00022 double getOffset(); 00023 int getHalfwidth(); 00024 int getTargetBin(); 00025 double getSamplingFrequency(); 00026 00027 // Manipulators 00028 void setBitrate(int bitrate); 00029 void setFFTLength(int fft_length); 00030 void setTargetFrequency(double frequency); 00031 void setSlope(double slope); 00032 void setOffset(double offset); 00033 void setHalfwidth(int halfwidth); 00034 void updateTargetBin(); 00035 00036 private: 00037 int m_bitrate; // x in y = m * x + b 00038 int m_fft_length; 00039 double m_target_frequency; // in Hz 00040 double m_slope; // m in y = m * x + b 00041 double m_offset; // b in y = m * x + b 00042 int m_halfwidth; // Window halfwidth about target bin 00043 double m_sampling_frequency; // y in y = m * x + b 00044 int m_target_bin; // Calculated FFT bin 00045 }; 00046 00047 #endif // SEABEA_SONAR_FFTBINPREDICTION_H Defined