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

dqpsk.h

Go to the documentation of this file.
00001 /*
00002  * SPUC - Signal processing using C++ - A DSP library
00003  * 
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2, or (at your option)
00007  * any later version.
00008  * 
00009  * This program 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
00012  * GNU General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 */
00018 #include <complex.h>
00019 namespace SPUC {
00028 
00029 
00030 
00031 class dqpsk {
00032  public:
00033   int datbase[4][4];
00034   int previous_encoded_symbol;
00035   int previous_decoded_symbol;
00036 
00037   dqpsk() {
00038         //  Initialize previous symbol to zero 
00039         //  Set up encoding data base as a two element array with arguments of
00040         //   i) current input symbol, and ii) previous encoded symbol 
00041 
00042         //      static int datbase[4][4] = {0,1,2,3,1,3,0,2,2,0,3,1,3,2,1,0};
00043         datbase[0][0] = 0;
00044         datbase[0][1] = 1;
00045         datbase[0][2] = 2;
00046         datbase[0][3] = 3;
00047 
00048         datbase[1][0] = 1;
00049         datbase[1][1] = 3;
00050         datbase[1][2] = 0;
00051         datbase[1][3] = 2;
00052 
00053         datbase[2][0] = 2;
00054         datbase[2][1] = 0;
00055         datbase[2][2] = 3;
00056         datbase[2][3] = 1;
00057 
00058         datbase[3][0] = 3;
00059         datbase[3][1] = 2;
00060         datbase[3][2] = 1;
00061         datbase[3][3] = 0;
00062         previous_encoded_symbol = 0;
00063         previous_decoded_symbol = 0;
00064   }
00071   complex<long> encode(complex<long> c)
00072         {
00073           int insym,outsym; 
00074           insym = qpsk_sym(c);
00075           outsym = datbase[insym][previous_encoded_symbol];
00076           previous_encoded_symbol = outsym;
00077           return(convbits(outsym));
00078         }
00081   complex<long> decode(complex<long> c)
00082         {
00083           int insym,outsym; 
00084           insym = qpsk_sym(c);
00085           outsym = datbase[insym][previous_decoded_symbol];
00086           previous_decoded_symbol = insym;
00087           return(convbits(outsym));
00088         }
00091   complex<long> convbits(int sym)
00092         {
00093           if(sym==0) return(complex<long>(-1,-1));
00094           else if(sym==1) return(complex<long>(-1,1));
00095           else if(sym==2) return(complex<long>(1,-1));
00096           else return(complex<long>(1,1));
00097         }
00100   int qpsk_sym(complex<long> c)
00101         {
00102           int insym;
00103           if(c.real()==-1.) {
00104                 if(c.imag()==-1) insym = 0;            
00105                 else insym = 1;
00106           }
00107           else  {
00108                 if(c.imag()==-1) insym = 2;            
00109                 else insym = 3;
00110           }
00111           return(insym);
00112         }
00113 };
00114 } // namespace SPUC 

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