Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

agc.h

Go to the documentation of this file.
00001 namespace SPUC {
00002 
00003 /*
00004  * SPUC - Signal processing using C++ - A DSP library
00005  * 
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2, or (at your option)
00009  * any later version.
00010  * 
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  * 
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019 */
00020 #ifndef QPSKAGC
00021 #define QPSKAGC
00022 #endif
00023 //:
00028 class agc {
00029  public:        
00030         long agc_acc;
00031         long agc_bit;
00032         long agc_thres;
00033 
00034         agc(long thres=32) : agc_thres(thres) {
00035                 agc_acc = 0;
00036                 agc_bit = 0;
00037         }
00038         long run(complex<long> adc) {
00039                 long    abs_level = abs(adc.re) + abs(adc.im);
00040                 long agc_diff = abs_level - agc_thres + 32;
00041                 if (agc_diff > 64) agc_diff = 64;
00042                 if (agc_diff < 0) agc_diff = 0;
00043                 agc_acc += agc_diff;
00044                 agc_bit = (agc_acc & 0x40) ? 0 : 1;
00045                 agc_acc &= 0x3f; // Clear overflow bit
00046                 return(agc_bit);
00047         }
00048 };
00049 } // namespace SPUC 

Generated on Fri Sep 16 11:02:23 2005 for spuc by  doxygen 1.4.4