Bug Summary

File:src/../src/make_modem_godard_descriptor.c
Warning:line 100, column 5
Value stored to 'carrier' is never read

Annotated Source Code

1/*
2 * SpanDSP - a series of DSP components for telephony
3 *
4 * make_modem_godard_descriptor.c - Create coefficient sets for Godard
5 * symbol sync. filters as a pair of
6 * fixed and floating point descriptor
7 * structures for spandsp.
8 *
9 * Written by Steve Underwood <steveu@coppice.org>
10 *
11 * Copyright (C) 2009, 2024 Steve Underwood
12 *
13 * All rights reserved.
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License version 2, as
17 * published by the Free Software Foundation.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 */
28
29#include <inttypes.h>
30#include <stdlib.h>
31#include <unistd.h>
32#include <string.h>
33#include <stdio.h>
34#include <time.h>
35#include <fcntl.h>
36#include <math.h>
37#include <stdbool.h>
38#if defined(__sunos) || defined(__solaris) || defined(__sun)
39#include <getopt.h>
40#endif
41
42#include "spandsp/telephony.h"
43#include "spandsp/complex.h"
44#include "spandsp/godard.h"
45#include "filter_tools.h"
46
47#if !defined(M_PI3.14159265358979323846)
48#define M_PI3.14159265358979323846 3.14159265358979323
49#endif
50
51#define FP_FACTOR4096 4096
52
53static void create_godard_coeffs(double carrier,
54 double baud_rate,
55 double alpha,
56 double sample_rate,
57 double low_band_edge_coeff[3],
58 double high_band_edge_coeff[3],
59 double *mixed_band_edges_coeff_3)
60{
61 double low_edge;
62 double high_edge;
63
64 low_edge = 2.0*M_PI3.14159265358979323846*(carrier - baud_rate/2.0)/sample_rate;
65 high_edge = 2.0*M_PI3.14159265358979323846*(carrier + baud_rate/2.0)/sample_rate;
66
67 low_band_edge_coeff[0] = 2.0*alpha*cos(low_edge);
68 high_band_edge_coeff[0] = 2.0*alpha*cos(high_edge);
69 low_band_edge_coeff[1] =
70 high_band_edge_coeff[1] = -alpha*alpha;
71 low_band_edge_coeff[2] = -alpha*sin(low_edge);
72 high_band_edge_coeff[2] = -alpha*sin(high_edge);
73 *mixed_band_edges_coeff_3 = -alpha*alpha*(sin(high_edge)*cos(low_edge) - sin(low_edge)*cos(high_edge));
74}
75/*- End of function --------------------------------------------------------*/
76
77static void usage(void)
78{
79 fprintf(stderrstderr, "Usage: make_modem_godard_coefficients [-i] [-s] | <carrier> <baud rate> [<alpha>]\n");
80}
81/*- End of function --------------------------------------------------------*/
82
83int main(int argc, char **argv)
84{
85 int opt;
86 const char *tag;
87 double alpha;
88 double carrier;
89 double baud_rate;
90 double sample_rate;
91 double low_band_edge_coeff[3];
92 double high_band_edge_coeff[3];
93 double mixed_band_edges_coeff_3;
94 double coarse_trigger;
95 double fine_trigger;
96 int coarse_step;
97 int fine_step;
98
99 alpha = 0.99;
100 carrier = 1800.0;
Value stored to 'carrier' is never read
101 baud_rate = 2400.0;
102 sample_rate = 8000.0;
103 coarse_trigger = 1000.0f;
104 fine_trigger = 100.0f;
105 coarse_step = 15;
106 fine_step = 1;
107
108 if (optind < argc)
109 {
110 carrier = atof(argv[optind++]);
111 }
112 else
113 {
114 usage();
115 exit(2);
116 }
117 /*endif*/
118 if (optind < argc)
119 {
120 baud_rate = atof(argv[optind++]);
121 }
122 else
123 {
124 usage();
125 exit(2);
126 }
127 /*endif*/
128 if (optind < argc)
129 alpha = atof(argv[optind++]);
130 /*endif*/
131 if (optind < argc)
132 coarse_trigger = atof(argv[optind++]);
133 /*endif*/
134 if (optind < argc)
135 fine_trigger = atof(argv[optind++]);
136 /*endif*/
137 if (optind < argc)
138 coarse_step = atof(argv[optind++]);
139 /*endif*/
140 if (optind < argc)
141 fine_step = atof(argv[optind++]);
142 /*endif*/
143
144
145 create_godard_coeffs(carrier,
146 baud_rate,
147 alpha,
148 sample_rate,
149 low_band_edge_coeff,
150 high_band_edge_coeff,
151 &mixed_band_edges_coeff_3);
152
153 printf("/* THIS FILE WAS AUTOMATICALLY GENERATED - ANY MODIFICATIONS MADE TO THIS\n");
154 printf(" FILE MAY BE OVERWRITTEN DURING FUTURE BUILDS OF THE SOFTWARE */\n");
155 printf("\n");
156 printf("\n");
157 printf("static const godard_ted_descriptor_t godard_desc =\n");
158 printf("{\n");
159 printf(" /* %.1f samples/second , %.1fHz carrier, %.1f baud, %.3f alpha */\n",
160 sample_rate,
161 carrier,
162 baud_rate,
163 alpha);
164 printf("#if defined(SPANDSP_USE_FIXED_POINT)\n");
165 printf(" {\n");
166 printf(" %d,\n", (int) (FP_FACTOR4096*low_band_edge_coeff[0]));
167 printf(" %d,\n", (int) (FP_FACTOR4096*low_band_edge_coeff[1]));
168 printf(" %d,\n", (int) (FP_FACTOR4096*low_band_edge_coeff[2]));
169 printf(" },\n");
170 printf(" {\n");
171 printf(" %d,\n", (int) (FP_FACTOR4096*high_band_edge_coeff[0]));
172 printf(" %d,\n", (int) (FP_FACTOR4096*high_band_edge_coeff[1]));
173 printf(" %d,\n", (int) (FP_FACTOR4096*high_band_edge_coeff[2]));
174 printf(" },\n");
175 printf(" %d,\n", (int) (FP_FACTOR4096*mixed_band_edges_coeff_3));
176 printf(" %d,\n", (int) (FP_FACTOR4096*coarse_trigger));
177 printf(" %d,\n", (int) (FP_FACTOR4096*fine_trigger));
178 printf(" %d,\n", coarse_step);
179 printf(" %d\n", fine_step);
180 printf("#else\n");
181 printf(" {\n");
182 printf(" %10.6ff,\n", low_band_edge_coeff[0]);
183 printf(" %10.6ff,\n", low_band_edge_coeff[1]);
184 printf(" %10.6ff,\n", low_band_edge_coeff[2]);
185 printf(" },\n");
186 printf(" {\n");
187 printf(" %10.6ff,\n", high_band_edge_coeff[0]);
188 printf(" %10.6ff,\n", high_band_edge_coeff[1]);
189 printf(" %10.6ff,\n", high_band_edge_coeff[2]);
190 printf(" },\n");
191 printf(" %10.6ff,\n", mixed_band_edges_coeff_3);
192 printf(" %14.6ff,\n", coarse_trigger);
193 printf(" %14.6ff,\n", fine_trigger);
194 printf(" %d,\n", coarse_step);
195 printf(" %d\n", fine_step);
196 printf("#endif\n");
197 printf("};\n");
198 return 0;
199}
200/*- End of function --------------------------------------------------------*/
201/*- End of file ------------------------------------------------------------*/