summaryrefslogtreecommitdiff
path: root/fxotune.c
diff options
context:
space:
mode:
Diffstat (limited to 'fxotune.c')
-rw-r--r--fxotune.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/fxotune.c b/fxotune.c
index 312ecca..c5db4d1 100644
--- a/fxotune.c
+++ b/fxotune.c
@@ -49,6 +49,7 @@ static char *usage =
static short outbuf[TEST_DURATION];
static int debug = 0;
+static FILE *outfile = NULL;
/* Generates a tone of hz frequency. Index is the current sample
* to begenerated. For a normal waveform you need to increment
@@ -128,13 +129,10 @@ static int acim_tune(int whichzap, char *dialstr)
struct wctdm_echo_coefs coefs;
short inbuf[BUFFER_LENGTH];
int lowest = 0;
- FILE *outfile = NULL;
float acim_results[16];
-
- if (debug) {
- outfile = fopen("fxotune.vals", "w");
- if (!outfile) {
+ if (debug && !outfile) {
+ if (!(outfile = fopen("fxotune.vals", "w"))) {
fprintf(stdout, "Cannot create fxotune.vals\n");
return -1;
}
@@ -243,7 +241,8 @@ static int acim_tune(int whichzap, char *dialstr)
/* calculate power of response */
freq_results[(freq/200)-1] = power_of(inbuf+SKIP_BYTES, BUFFER_LENGTH-SKIP_BYTES, 1);
- if (debug) fprintf(outfile, "%d,%d,%f\n", acim, freq, freq_results[(freq/200)-1]);
+ if (debug)
+ fprintf(outfile, "%d,%d,%f\n", acim, freq, freq_results[(freq/200)-1]);
}
acim_results[acim] = power_of(freq_results, 15, 0);
}