dburgess | b3a0ca4 | 2011-10-12 07:44:40 +0000 | [diff] [blame] | 1 | /* |
| 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 | /* |
| 27 | Contributors: |
| 28 | Harvind S. Samra, hssamra@kestrelsp.com |
| 29 | */ |
| 30 | |
| 31 | |
| 32 | #include "sigProcLib.h" |
| 33 | //#include "radioInterface.h" |
| 34 | #include <Logger.h> |
| 35 | #include <Configuration.h> |
| 36 | |
| 37 | using namespace std; |
| 38 | |
| 39 | ConfigurationTable gConfig; |
| 40 | |
| 41 | int main(int argc, char **argv) { |
| 42 | |
| 43 | gLogInit("sigProcLibTest","DEBUG"); |
| 44 | |
| 45 | int samplesPerSymbol = 1; |
| 46 | |
| 47 | int TSC = 2; |
| 48 | |
| 49 | sigProcLibSetup(samplesPerSymbol); |
| 50 | |
| 51 | signalVector *gsmPulse = generateGSMPulse(2,samplesPerSymbol); |
| 52 | cout << *gsmPulse << endl; |
| 53 | |
| 54 | BitVector RACHBurstStart = "01010101"; |
| 55 | BitVector RACHBurstRest = "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; |
| 56 | |
| 57 | BitVector RACHBurst(BitVector(RACHBurstStart,gRACHSynchSequence),RACHBurstRest); |
| 58 | |
| 59 | |
| 60 | signalVector *RACHSeq = modulateBurst(RACHBurst, |
| 61 | *gsmPulse, |
| 62 | 9, |
| 63 | samplesPerSymbol); |
| 64 | |
| 65 | generateRACHSequence(*gsmPulse,samplesPerSymbol); |
| 66 | |
| 67 | complex a; float t; |
| 68 | detectRACHBurst(*RACHSeq, 5, samplesPerSymbol,&a,&t); |
| 69 | |
| 70 | //cout << *RACHSeq << endl; |
| 71 | //signalVector *autocorr = correlate(RACHSeq,RACHSeq,NULL,NO_DELAY); |
| 72 | |
| 73 | //cout << *autocorr; |
| 74 | |
| 75 | //exit(1); |
| 76 | |
| 77 | |
| 78 | /*signalVector x(6500); |
| 79 | x.fill(1.0); |
| 80 | |
| 81 | frequencyShift(&x,&x,0.48*M_PI); |
| 82 | |
| 83 | signalVector *y = polyphaseResampleVector(x,96,65,NULL); |
| 84 | |
| 85 | cout << *y << endl; |
| 86 | |
| 87 | exit(1);*/ |
| 88 | |
| 89 | //CommSig normalBurstSeg = "0000000000000000000000000000000000000000000000000000000000000"; |
| 90 | |
| 91 | BitVector normalBurstSeg = "0000101010100111110010101010010110101110011000111001101010000"; |
| 92 | |
| 93 | BitVector normalBurst(BitVector(normalBurstSeg,gTrainingSequence[TSC]),normalBurstSeg); |
| 94 | |
| 95 | |
| 96 | generateMidamble(*gsmPulse,samplesPerSymbol,TSC); |
| 97 | |
| 98 | |
| 99 | signalVector *modBurst = modulateBurst(normalBurst,*gsmPulse, |
| 100 | 0,samplesPerSymbol); |
| 101 | |
| 102 | |
| 103 | //delayVector(*rsVector2,6.932); |
| 104 | |
| 105 | complex ampl = 1; |
| 106 | float TOA = 0; |
| 107 | |
| 108 | //modBurst = rsVector2; |
| 109 | //delayVector(*modBurst,0.8); |
| 110 | |
| 111 | /* |
| 112 | signalVector channelResponse(4); |
| 113 | signalVector::iterator c=channelResponse.begin(); |
| 114 | *c = (complex) 9000.0; c++; |
| 115 | *c = (complex) 0.4*9000.0; c++; c++; |
| 116 | *c = (complex) -1.2*0; |
| 117 | |
| 118 | signalVector *guhBurst = convolve(modBurst,&channelResponse,NULL,NO_DELAY); |
| 119 | delete modBurst; modBurst = guhBurst; |
| 120 | */ |
| 121 | |
| 122 | signalVector *chanResp; |
| 123 | /* |
| 124 | double noisePwr = 0.001/sqrtf(2); |
| 125 | signalVector *noise = gaussianNoise(modBurst->size(),noisePwr); |
| 126 | */ |
| 127 | float chanRespOffset; |
| 128 | analyzeTrafficBurst(*modBurst,TSC,8.0,samplesPerSymbol,&l,&TOA,1,true,&chanResp,&chanRespOffset); |
| 129 | //addVector(*modBurst,*noise); |
| 130 | |
| 131 | cout << "ampl:" << ampl << endl; |
| 132 | cout << "TOA: " << TOA << endl; |
| 133 | //cout << "chanResp: " << *chanResp << endl; |
| 134 | SoftVector *demodBurst = demodulateBurst(*modBurst,*gsmPulse,samplesPerSymbol,(complex) ampl, TOA); |
| 135 | |
| 136 | cout << *demodBurst << endl; |
| 137 | |
| 138 | /* |
| 139 | COUT("chanResp: " << *chanResp); |
| 140 | |
| 141 | signalVector *w,*b; |
| 142 | designDFE(*chanResp,1.0/noisePwr,7,&w,&b); |
| 143 | COUT("w: " << *w); |
| 144 | COUT("b: " << *b); |
| 145 | |
| 146 | |
| 147 | SoftSig *DFEBurst = equalizeBurst(*modBurst,TOA-chanRespOffset,samplesPerSymbol,*w,*b); |
| 148 | COUT("DFEBurst: " << *DFEBurst); |
| 149 | |
| 150 | delete gsmPulse; |
| 151 | delete RACHSeq; |
| 152 | delete modBurst; |
| 153 | delete sendLPF; |
| 154 | delete rcvLPF; |
| 155 | delete rsVector; |
| 156 | //delete rsVector2; |
| 157 | delete autocorr; |
| 158 | delete chanResp; |
| 159 | delete noise; |
| 160 | delete demodBurst; |
| 161 | delete w; |
| 162 | delete b; |
| 163 | delete DFEBurst; |
| 164 | */ |
| 165 | |
| 166 | sigProcLibDestroy(); |
| 167 | |
| 168 | } |