FFTBinPrediction.C

00001 #include "FFTBinPrediction.H"
00002 
00003 #include <stdio.h>
00004 
00005 FFTBinAffinePrediction::FFTBinAffinePrediction(
00006                             int cheetah_bitrate, int fft_length,
00007                             double target_frequency, double slope,
00008                             double offset, int halfwidth)
00009  : m_bitrate(cheetah_bitrate), m_fft_length(fft_length),
00010    m_target_frequency(target_frequency), m_slope(slope),
00011    m_offset(offset), m_halfwidth(halfwidth) {
00012 
00013   // Use affine function to calculate sampling frequency
00014   m_sampling_frequency = m_slope * (double)m_bitrate + m_offset;
00015 
00016   // Use sampling frequency to determine FFT bin number for target frequency
00017   printf("%10.0f\n", m_target_frequency);
00018   printf("%10.0f\n", m_sampling_frequency);
00019   printf("%d\n", m_fft_length);
00020   m_target_bin = (double)m_target_frequency / (double)m_sampling_frequency * (double)m_fft_length;
00021   printf("%d\n", m_target_bin);
00022 }
00023 
00024 FFTBinAffinePrediction::~FFTBinAffinePrediction() {}
00025 
00026 // Accessors
00027 int FFTBinAffinePrediction::getBitrate() { return m_bitrate; }
00028 int FFTBinAffinePrediction::getFFTLength() { return m_fft_length; }
00029 double FFTBinAffinePrediction::getTargetFrequency() {
00030   return m_target_frequency;
00031 }
00032 double FFTBinAffinePrediction::getSlope() { return m_slope; }
00033 double FFTBinAffinePrediction::getOffset() { return m_offset; }
00034 int FFTBinAffinePrediction::getHalfwidth() { return m_halfwidth; }
00035 int FFTBinAffinePrediction::getTargetBin() { return m_target_bin; }
00036 double FFTBinAffinePrediction::getSamplingFrequency() {
00037   return m_sampling_frequency;
00038 }
00039 
00040 // Manipulators
00041 void FFTBinAffinePrediction::setBitrate(int bitrate) {
00042   m_bitrate = bitrate;
00043   updateTargetBin();
00044 }
00045 void FFTBinAffinePrediction::setFFTLength(int fft_length) {
00046   m_fft_length = fft_length;
00047   updateTargetBin();
00048 }
00049 void FFTBinAffinePrediction::setTargetFrequency(double frequency) {
00050   m_target_frequency = frequency;
00051   updateTargetBin();
00052 }
00053 void FFTBinAffinePrediction::setSlope(double slope) {
00054   m_slope = slope;
00055   updateTargetBin();
00056 }
00057 void FFTBinAffinePrediction::setOffset(double offset) {
00058   m_offset = offset;
00059   updateTargetBin();
00060 }
00061 void FFTBinAffinePrediction::setHalfwidth(int halfwidth) {
00062   m_halfwidth = halfwidth;
00063 }
00064 void FFTBinAffinePrediction::updateTargetBin() {
00065   // Use affine function to calculate sampling frequency
00066   m_sampling_frequency = m_slope * (double)m_bitrate + m_offset;
00067 
00068   // Use sampling frequency to determine FFT bin number for target frequency
00069   m_target_bin = (double)m_target_frequency / (double)m_sampling_frequency * (double)m_fft_length;
00070 }
00071 
Generated on Sun May 8 08:06:36 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3