root/experimental/components/Demodulator/src/DemodulatorDSP.cpp @ 3994

Revision 3994, 3.7 KB (checked in by jgaeddert, 6 years ago)

Adding funcitonality to Demodulator component

  • Property svn:eol-style set to native
Line 
1/****************************************************************************
2
3Copyright 2007 Virginia Polytechnic Institute and State University
4
5This file is part of the OSSIE Demodulator.
6
7OSSIE Demodulator is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
11
12OSSIE Demodulator is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with OSSIE Demodulator; if not, write to the Free Software
19Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
21****************************************************************************/
22
23
24#include <iostream>
25#include "DemodulatorDSP.h"
26#include <math.h>
27
28// Default constructor
29DemodulatorDSP::DemodulatorDSP()
30{
31    bitsPerSymbol = 1;
32    Demodulate = &DemodulateBPSK;
33    state_i = 0;
34    state_q = 0;
35}
36
37// Destructor
38DemodulatorDSP::~DemodulatorDSP()
39{
40}
41
42// Set modulation scheme
43void DemodulatorDSP::SetModulationScheme( ModulationScheme _ms )
44{
45    switch ( _ms ) {
46    case MOD_BPSK:
47        Demodulate = &DemodulateBPSK;
48        bitsPerSymbol = 1;
49        break;
50    case MOD_QPSK:
51        Demodulate = &DemodulateQPSK;
52        bitsPerSymbol = 2;
53        break;
54    case MOD_8PSK:
55        Demodulate = &Demodulate8PSK;
56        bitsPerSymbol = 3;
57        break;
58    case MOD_16QAM:
59        Demodulate = &Demodulate16QAM;
60        bitsPerSymbol = 4;
61        break;
62    case MOD_4PAM:
63        Demodulate = &Demodulate4PAM;
64        bitsPerSymbol = 2;
65        break;
66    case MOD_DBPSK:
67        state_i = 0;
68        state_q = 0;
69        Demodulate = &DemodulateBPSK;
70        bitsPerSymbol = 1;
71        break;
72    case MOD_DQPSK:
73        state_i = 0;
74        state_q = 0;
75        Demodulate = &DemodulateQPSK;
76        bitsPerSymbol = 2;
77        break;
78    case MOD_D8PSK:
79        state_i = 0;
80        state_q = 0;
81        Demodulate = &Demodulate8PSK;
82        bitsPerSymbol = 3;
83        break;
84    default:
85        std::cerr << "ERROR: DemodulatorDSP::SetModulationScheme(): "
86                  << "unknown mod. scheme " << _ms << std::endl;
87        std::cerr << "  => Using BPSK instead" << std::endl;
88        SetModulationScheme( MOD_BPSK );
89        //throw 0;
90    }
91   
92    mod_scheme = _ms;
93}
94
95///
96void DemodulatorDSP::DemodulateSequence(
97        short * I_in,
98        short * Q_in,
99        unsigned int N_in,
100        char * bits_out)
101{
102    Demodulate(I_in, Q_in, N_in, bits_out);
103}
104
105
106//
107void DemodulateBPSK(
108    short * I_in,
109    short * Q_in,
110    unsigned int N_in,
111    char * bits_out)
112{
113    for (unsigned int i=0; i < N_in; i++)
114        bits_out[i] = ( I_in[i] > 0 ) ? BIT1 : BIT0;
115}
116
117//
118void DemodulateQPSK(
119    short * I_in,
120    short * Q_in,
121    unsigned int N_in,
122    char * bits_out)
123{
124    std::cerr << "ERROR: DemodulateQPSK not yet supported!" << std::endl;
125    throw 0;
126}
127
128//
129void Demodulate8PSK(
130    short * I_in,
131    short * Q_in,
132    unsigned int N_in,
133    char * bits_out)
134{
135    std::cerr << "ERROR: Demodulate8PSK not yet supported!" << std::endl;
136    throw 0;
137}
138
139//
140void Demodulate16QAM(
141    short * I_in,
142    short * Q_in,
143    unsigned int N_in,
144    char * bits_out)
145{
146    std::cerr << "ERROR: Demodulate16QAM not yet supported!" << std::endl;
147    throw 0;
148}
149
150//
151void Demodulate4PAM(
152    short * I_in,
153    short * Q_in,
154    unsigned int N_in,
155    char * bits_out)
156{
157    std::cerr << "ERROR: Demodulate4PAM not yet supported!" << std::endl;
158    throw 0;
159}
160
161
Note: See TracBrowser for help on using the browser.