mirror of
https://git.vladimir.cc/vladimir/wdsp.git
synced 2026-08-25 17:27:33 +00:00
Model the pair on fmd.c / fmmod.c, but with the parts that a 75 kHz
deviation forces:
- the demodulator discriminates with arg(x[n] * conj(x[n-1])) rather
than a PLL; an omegaN in the tens of kHz cannot track 75 kHz.
- emphasis is a one-pole RC (tau 75 us) on both ends, not fmd's 1/f
fc_impulse FIR. A 1/f FIR from f_low = 20 Hz would sit ~+57 dB at
20 Hz, where broadcast FM specifies flat below the corner.
- TXA_WFM leaves the shared preemph block off; wfmmod carries its own.
- wfmmod clamps bp_fc = deviation + f_high to 0.45 * samplerate, since
+/-90 kHz exceeds Nyquist at the rates the narrowband modes use.
Scope is mono: no 19 kHz pilot, no 38 kHz stereo subcarrier, no RDS.
Both mode enums are appended to so the ABI stays stable for clients.
The JNI bindings are deliberately left alone.
Verified against a wfmmod -> wfmd loopback: the discriminator is exact,
the dc-removal one-pole tracks |H_lp(f)| * ain * sdelta to ratio 1.000,
and a 700 + 1900 Hz two-tone comes back with THD+N ~ 3e-5 % at +/-37.5
kHz deviation. Note the demodulator aliases unless samplerate exceeds
2 * deviation * |aud|max, so 192 kHz is the practical floor.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
87 lines
2.3 KiB
C
87 lines
2.3 KiB
C
/* wfmmod.h
|
|
|
|
This file is part of a program that implements a Software-Defined Radio.
|
|
|
|
Copyright (C) 2013, 2016, 2023 Warren Pratt, NR0V
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public License
|
|
as published by the Free Software Foundation; either version 2
|
|
of the License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
The author can be reached by email at
|
|
|
|
warren@wpratt.com
|
|
|
|
*/
|
|
|
|
#ifndef _wfmmod_h
|
|
#define _wfmmod_h
|
|
#include "firmin.h"
|
|
typedef struct _wfmmod
|
|
{
|
|
int run;
|
|
int size;
|
|
double* in;
|
|
double* out;
|
|
double samplerate;
|
|
double deviation;
|
|
double f_low;
|
|
double f_high;
|
|
// pre-emphasis, single-pole RC; inverse of the receiver's de-emphasis
|
|
int pre_run;
|
|
double tau_pre; // 75.0e-6 (Americas) or 50.0e-6 (elsewhere)
|
|
double pmult;
|
|
double pnorm;
|
|
double pre_z;
|
|
// mod
|
|
double sphase;
|
|
double sdelta;
|
|
// bandpass
|
|
int bp_run;
|
|
double bp_fc;
|
|
int nc;
|
|
int mp;
|
|
FIRCORE p;
|
|
}wfmmod, *WFMMOD;
|
|
|
|
extern WFMMOD create_wfmmod (int run, int size, double* in, double* out, int rate, double dev, double f_low, double f_high,
|
|
int pre_run, double tau_pre, int bp_run, int nc, int mp);
|
|
|
|
extern void destroy_wfmmod (WFMMOD a);
|
|
|
|
extern void flush_wfmmod (WFMMOD a);
|
|
|
|
extern void xwfmmod (WFMMOD a);
|
|
|
|
extern void setBuffers_wfmmod (WFMMOD a, double* in, double* out);
|
|
|
|
extern void setSamplerate_wfmmod (WFMMOD a, int rate);
|
|
|
|
extern void setSize_wfmmod (WFMMOD a, int size);
|
|
|
|
// TXA Properties
|
|
|
|
extern __declspec (dllexport) void SetTXAWFMDeviation (int channel, double deviation);
|
|
|
|
extern __declspec (dllexport) void SetTXAWFMNC (int channel, int nc);
|
|
|
|
extern __declspec (dllexport) void SetTXAWFMMP (int channel, int mp);
|
|
|
|
extern __declspec (dllexport) void SetTXAWFMAFFreqs (int channel, double low, double high);
|
|
|
|
extern __declspec (dllexport) void SetTXAWFMPreEmphRun (int channel, int run);
|
|
|
|
extern __declspec (dllexport) void SetTXAWFMPreEmphTau (int channel, double tau);
|
|
|
|
#endif
|