]> git.rkrishnan.org Git - dttsp.git/blob - jDttSP/correctIQ.c
changes to speechproc, correct IQ -- restore squelch in sdr.c -- other minor stuff
[dttsp.git] / jDttSP / correctIQ.c
1 /* correctIQ.c
2
3 This routine restores quadrature between arms of an analytic signal
4 possibly distorted by ADC hardware.
5
6 This file is part of a program that implements a Software-Defined Radio.
7
8 Copyright (C) 2004 by Frank Brickle, AB2KT and Bob McGwier, N4HY
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
24 The authors can be reached by email at
25
26 ab2kt@arrl.net
27 or
28 rwmcgwier@comcast.net
29
30 or by paper mail at
31
32 The DTTS Microwave Society
33 6 Kathleen Place
34 Bridgewater, NJ 08807
35 */
36
37 #include <common.h>
38
39 IQ
40 newCorrectIQ(REAL phase, REAL gain) {
41   IQ iq = (IQ) safealloc(1, sizeof(iqstate), "IQ state");
42   iq->phase = phase;
43   iq->gain = gain;
44   return iq;
45 }
46
47 void 
48 delCorrectIQ(IQ iq) { safefree((char *) iq); }
49
50 void
51 correctIQ(CXB sigbuf, IQ iq) {
52   int i;
53   for (i = 0; i < CXBhave(sigbuf); i++) {
54     CXBimag(sigbuf, i) += iq->phase * CXBreal(sigbuf, i);
55     CXBreal(sigbuf, i) *= iq->gain;
56   }
57 }