Rename the parameter "coherent" to "FFSK" which is the correct meaning.

This commit is contained in:
Andreas Eversberg 2021-01-24 14:33:31 +01:00
parent a07764f0d9
commit 22cb70fb1b
2 changed files with 12 additions and 12 deletions

View File

@ -1,4 +1,4 @@
/* FSK audio processing (coherent FSK modem) /* FSK audio processing (FSK/FFSK modem)
* *
* (C) 2017 by Andreas Eversberg <jolly@eversberg.eu> * (C) 2017 by Andreas Eversberg <jolly@eversberg.eu>
* All Rights Reserved * All Rights Reserved
@ -37,9 +37,9 @@
* bitrate = bits per second * bitrate = bits per second
* f0, f1 = two frequencies for bit 0 and bit 1 * f0, f1 = two frequencies for bit 0 and bit 1
* level = level to modulate the frequencies * level = level to modulate the frequencies
* coherent = use coherent modulation (FFSK) * ffsk = use FFSK modulation (each symbol ends at zero crossing)
*/ */
int fsk_mod_init(fsk_mod_t *fsk, void *inst, int (*send_bit)(void *inst), int samplerate, double bitrate, double f0, double f1, double level, int coherent, int filter) int fsk_mod_init(fsk_mod_t *fsk, void *inst, int (*send_bit)(void *inst), int samplerate, double bitrate, double f0, double f1, double level, int ffsk, int filter)
{ {
int i; int i;
int rc; int rc;
@ -80,23 +80,23 @@ int fsk_mod_init(fsk_mod_t *fsk, void *inst, int (*send_bit)(void *inst), int sa
fsk->phaseshift65536[1] = f1 / (double)samplerate * 65536.0; fsk->phaseshift65536[1] = f1 / (double)samplerate * 65536.0;
PDEBUG(DDSP, DEBUG_DEBUG, "F1 = %.0f Hz (phaseshift65536[1] = %.4f)\n", f1, fsk->phaseshift65536[1]); PDEBUG(DDSP, DEBUG_DEBUG, "F1 = %.0f Hz (phaseshift65536[1] = %.4f)\n", f1, fsk->phaseshift65536[1]);
/* use coherent modulation, i.e. each bit has an integer number of /* use ffsk modulation, i.e. each bit has an integer number of
* half waves and starts/ends at zero crossing * half waves and starts/ends at zero crossing
*/ */
if (coherent) { if (ffsk) {
double waves; double waves;
PDEBUG(DDSP, DEBUG_DEBUG, "enable coherent FSK modulation mode\n"); PDEBUG(DDSP, DEBUG_DEBUG, "enable FFSK modulation mode\n");
fsk->coherent = 1; fsk->ffsk = 1;
waves = (f0 / bitrate); waves = (f0 / bitrate);
if (fabs(round(waves * 2) - (waves * 2)) > 0.001) { if (fabs(round(waves * 2) - (waves * 2)) > 0.001) {
fprintf(stderr, "Failed to set coherent mode, half waves of F0 does not fit exactly into one bit, please fix!\n"); fprintf(stderr, "Failed to set FFSK mode, half waves of F0 does not fit exactly into one bit, please fix!\n");
abort(); abort();
} }
fsk->cycles_per_bit65536[0] = waves * 65536.0; fsk->cycles_per_bit65536[0] = waves * 65536.0;
waves = (f1 / bitrate); waves = (f1 / bitrate);
if (fabs(round(waves * 2) - (waves * 2)) > 0.001) { if (fabs(round(waves * 2) - (waves * 2)) > 0.001) {
fprintf(stderr, "Failed to set coherent mode, half waves of F1 does not fit exactly into one bit, please fix!\n"); fprintf(stderr, "Failed to set FFSK mode, half waves of F1 does not fit exactly into one bit, please fix!\n");
abort(); abort();
} }
fsk->cycles_per_bit65536[1] = waves * 65536.0; fsk->cycles_per_bit65536[1] = waves * 65536.0;
@ -141,7 +141,7 @@ void fsk_mod_cleanup(fsk_mod_t *fsk)
* return -1. In this case, this function stops and returns the number of * return -1. In this case, this function stops and returns the number of
* samples that have been rendered so far, if any. * samples that have been rendered so far, if any.
* *
* For coherent mode (FSK), we round the phase on every bit change to the * For FFSK mode, we round the phase on every bit change to the
* next zero crossing. This prevents phase shifts due to rounding errors. * next zero crossing. This prevents phase shifts due to rounding errors.
*/ */
int fsk_mod_send(fsk_mod_t *fsk, sample_t *sample, int length, int add) int fsk_mod_send(fsk_mod_t *fsk, sample_t *sample, int length, int add)
@ -161,7 +161,7 @@ next_bit:
if (fsk->tx_bit < 0) if (fsk->tx_bit < 0)
goto done; goto done;
/* correct phase when changing bit */ /* correct phase when changing bit */
if (fsk->coherent) { if (fsk->ffsk) {
/* round phase to nearest zero crossing */ /* round phase to nearest zero crossing */
if (phase > 16384.0 && phase < 49152.0) if (phase > 16384.0 && phase < 49152.0)
phase = 32768.0; phase = 32768.0;

View File

@ -9,7 +9,7 @@ typedef struct fsk_mod {
double cycles_per_bit65536[2]; /* cycles of one bit */ double cycles_per_bit65536[2]; /* cycles of one bit */
double tx_phase65536; /* current transmit phase */ double tx_phase65536; /* current transmit phase */
double level; /* level (amplitude) of signal */ double level; /* level (amplitude) of signal */
int coherent; /* set, if coherent TX mode */ int ffsk; /* set, if FFSK TX mode */
double f0_deviation; /* deviation of frequencies, relative to center */ double f0_deviation; /* deviation of frequencies, relative to center */
double f1_deviation; double f1_deviation;
int low_bit, high_bit; /* a low or high deviation means which bit? */ int low_bit, high_bit; /* a low or high deviation means which bit? */