blob: 4f9271769791938749242d5b14a8c84e766f2afb [file] [log] [blame]
dburgessb3a0ca42011-10-12 07:44:40 +00001/*
2* Copyright 2011 Free Software Foundation, Inc.
3* Copyright 2008, 2010 Kestrel Signal Processing, Inc.
4*
5* This software is distributed under the terms of the GNU Affero Public License.
6* See the COPYING file in the main directory for details.
7*
8* This use of this software may be subject to additional restrictions.
9* See the LEGAL file in the main directory for details.
10
11 This program is free software: you can redistribute it and/or modify
12 it under the terms of the GNU Affero General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU Affero General Public License for more details.
20
21 You should have received a copy of the GNU Affero General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>.
23
24*/
25
26/*
27Contributors:
28Harvind S. Samra, hssamra@kestrelsp.com
29*/
30
31
32#include "sigProcLib.h"
33//#include "radioInterface.h"
34#include <Logger.h>
35#include <Configuration.h>
Alexander Chemerisd734e2d2013-06-16 14:30:58 +040036#include <GSMCommon.h>
dburgessb3a0ca42011-10-12 07:44:40 +000037
38using namespace std;
Alexander Chemerisd734e2d2013-06-16 14:30:58 +040039using namespace GSM;
dburgessb3a0ca42011-10-12 07:44:40 +000040
41ConfigurationTable gConfig;
42
43int main(int argc, char **argv) {
44
45 gLogInit("sigProcLibTest","DEBUG");
46
47 int samplesPerSymbol = 1;
48
49 int TSC = 2;
50
51 sigProcLibSetup(samplesPerSymbol);
52
53 signalVector *gsmPulse = generateGSMPulse(2,samplesPerSymbol);
54 cout << *gsmPulse << endl;
55
56 BitVector RACHBurstStart = "01010101";
57 BitVector RACHBurstRest = "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
58
59 BitVector RACHBurst(BitVector(RACHBurstStart,gRACHSynchSequence),RACHBurstRest);
60
61
62 signalVector *RACHSeq = modulateBurst(RACHBurst,
63 *gsmPulse,
64 9,
65 samplesPerSymbol);
66
67 generateRACHSequence(*gsmPulse,samplesPerSymbol);
68
69 complex a; float t;
70 detectRACHBurst(*RACHSeq, 5, samplesPerSymbol,&a,&t);
71
72 //cout << *RACHSeq << endl;
73 //signalVector *autocorr = correlate(RACHSeq,RACHSeq,NULL,NO_DELAY);
74
75 //cout << *autocorr;
76
77 //exit(1);
78
79
80 /*signalVector x(6500);
81 x.fill(1.0);
82
83 frequencyShift(&x,&x,0.48*M_PI);
84
85 signalVector *y = polyphaseResampleVector(x,96,65,NULL);
86
87 cout << *y << endl;
88
89 exit(1);*/
90
91 //CommSig normalBurstSeg = "0000000000000000000000000000000000000000000000000000000000000";
92
93 BitVector normalBurstSeg = "0000101010100111110010101010010110101110011000111001101010000";
94
95 BitVector normalBurst(BitVector(normalBurstSeg,gTrainingSequence[TSC]),normalBurstSeg);
96
97
98 generateMidamble(*gsmPulse,samplesPerSymbol,TSC);
99
100
101 signalVector *modBurst = modulateBurst(normalBurst,*gsmPulse,
102 0,samplesPerSymbol);
103
104
105 //delayVector(*rsVector2,6.932);
106
107 complex ampl = 1;
108 float TOA = 0;
109
110 //modBurst = rsVector2;
111 //delayVector(*modBurst,0.8);
112
113 /*
114 signalVector channelResponse(4);
115 signalVector::iterator c=channelResponse.begin();
116 *c = (complex) 9000.0; c++;
117 *c = (complex) 0.4*9000.0; c++; c++;
118 *c = (complex) -1.2*0;
119
120 signalVector *guhBurst = convolve(modBurst,&channelResponse,NULL,NO_DELAY);
121 delete modBurst; modBurst = guhBurst;
122 */
123
124 signalVector *chanResp;
125 /*
126 double noisePwr = 0.001/sqrtf(2);
127 signalVector *noise = gaussianNoise(modBurst->size(),noisePwr);
128 */
129 float chanRespOffset;
130 analyzeTrafficBurst(*modBurst,TSC,8.0,samplesPerSymbol,&ampl,&TOA,1,true,&chanResp,&chanRespOffset);
131 //addVector(*modBurst,*noise);
132
133 cout << "ampl:" << ampl << endl;
134 cout << "TOA: " << TOA << endl;
135 //cout << "chanResp: " << *chanResp << endl;
136 SoftVector *demodBurst = demodulateBurst(*modBurst,*gsmPulse,samplesPerSymbol,(complex) ampl, TOA);
137
138 cout << *demodBurst << endl;
139
140 /*
141 COUT("chanResp: " << *chanResp);
142
143 signalVector *w,*b;
144 designDFE(*chanResp,1.0/noisePwr,7,&w,&b);
145 COUT("w: " << *w);
146 COUT("b: " << *b);
147
148
149 SoftSig *DFEBurst = equalizeBurst(*modBurst,TOA-chanRespOffset,samplesPerSymbol,*w,*b);
150 COUT("DFEBurst: " << *DFEBurst);
151
152 delete gsmPulse;
153 delete RACHSeq;
154 delete modBurst;
155 delete sendLPF;
156 delete rcvLPF;
157 delete rsVector;
158 //delete rsVector2;
159 delete autocorr;
160 delete chanResp;
161 delete noise;
162 delete demodBurst;
163 delete w;
164 delete b;
165 delete DFEBurst;
166 */
167
168 sigProcLibDestroy();
169
170}