65cb3c386e
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>
199 lines
3.0 KiB
C
199 lines
3.0 KiB
C
/* TXA.h
|
|
|
|
This file is part of a program that implements a Software-Defined Radio.
|
|
|
|
Copyright (C) 2013, 2017 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 _txa_h
|
|
#define _txa_h
|
|
#include "comm.h"
|
|
|
|
enum txaMode
|
|
{
|
|
TXA_LSB,
|
|
TXA_USB,
|
|
TXA_DSB,
|
|
TXA_CWL,
|
|
TXA_CWU,
|
|
TXA_FM,
|
|
TXA_AM,
|
|
TXA_DIGU,
|
|
TXA_SPEC,
|
|
TXA_DIGL,
|
|
TXA_SAM,
|
|
TXA_DRM,
|
|
TXA_AM_LSB,
|
|
TXA_AM_USB,
|
|
TXA_WFM
|
|
};
|
|
|
|
enum txaMeterType
|
|
{
|
|
TXA_MIC_PK,
|
|
TXA_MIC_AV,
|
|
TXA_EQ_PK,
|
|
TXA_EQ_AV,
|
|
TXA_LVLR_PK,
|
|
TXA_LVLR_AV,
|
|
TXA_LVLR_GAIN,
|
|
TXA_CFC_PK,
|
|
TXA_CFC_AV,
|
|
TXA_CFC_GAIN,
|
|
TXA_COMP_PK,
|
|
TXA_COMP_AV,
|
|
TXA_ALC_PK,
|
|
TXA_ALC_AV,
|
|
TXA_ALC_GAIN,
|
|
TXA_OUT_PK,
|
|
TXA_OUT_AV,
|
|
TXA_METERTYPE_LAST
|
|
};
|
|
|
|
struct _txa
|
|
{
|
|
double* inbuff;
|
|
double* outbuff;
|
|
double* midbuff;
|
|
int mode;
|
|
double f_low;
|
|
double f_high;
|
|
double meter[TXA_METERTYPE_LAST];
|
|
CRITICAL_SECTION* pmtupdate[TXA_METERTYPE_LAST];
|
|
struct
|
|
{
|
|
METER p;
|
|
} micmeter, eqmeter, lvlrmeter, cfcmeter, compmeter, alcmeter, outmeter;
|
|
struct
|
|
{
|
|
RESAMPLE p;
|
|
} rsmpin, rsmpout;
|
|
struct
|
|
{
|
|
PANEL p;
|
|
} panel;
|
|
struct
|
|
{
|
|
AMSQ p;
|
|
} amsq;
|
|
struct
|
|
{
|
|
EQP p;
|
|
} eqp;
|
|
struct
|
|
{
|
|
PHROT p;
|
|
} phrot;
|
|
struct
|
|
{
|
|
CFCOMP p;
|
|
} cfcomp;
|
|
struct
|
|
{
|
|
COMPRESSOR p;
|
|
} compressor;
|
|
struct
|
|
{
|
|
BANDPASS p;
|
|
} bp0, bp1, bp2;
|
|
struct
|
|
{
|
|
OSCTRL p;
|
|
} osctrl;
|
|
struct
|
|
{
|
|
WCPAGC p;
|
|
} leveler, alc;
|
|
struct
|
|
{
|
|
AMMOD p;
|
|
} ammod;
|
|
struct
|
|
{
|
|
EMPHP p;
|
|
} preemph;
|
|
struct
|
|
{
|
|
FMMOD p;
|
|
} fmmod;
|
|
struct
|
|
{
|
|
WFMMOD p;
|
|
} wfmmod;
|
|
struct
|
|
{
|
|
SIPHON p;
|
|
} sip1;
|
|
struct
|
|
{
|
|
GEN p;
|
|
} gen0, gen1;
|
|
struct
|
|
{
|
|
USLEW p;
|
|
} uslew;
|
|
struct
|
|
{
|
|
CALCC p;
|
|
CRITICAL_SECTION cs_update;
|
|
} calcc;
|
|
struct
|
|
{
|
|
IQC p0, p1;
|
|
// p0 for dsp-synchronized reference, p1 for other
|
|
} iqc;
|
|
struct
|
|
{
|
|
CFIR p;
|
|
} cfir;
|
|
};
|
|
|
|
extern struct _txa txa[];
|
|
|
|
extern void create_txa (int channel);
|
|
|
|
extern void destroy_txa (int channel);
|
|
|
|
extern void flush_txa (int channel);
|
|
|
|
extern void xtxa (int channel);
|
|
|
|
extern int TXAUslewCheck (int channel);
|
|
|
|
extern void setInputSamplerate_txa (int channel);
|
|
|
|
extern void setOutputSamplerate_txa (int channel);
|
|
|
|
extern void setDSPSamplerate_txa (int channel);
|
|
|
|
extern void setDSPBuffsize_txa (int channel);
|
|
|
|
// TXA Properties
|
|
|
|
extern __declspec (dllexport) void SetTXAMode (int channel, int mode);
|
|
|
|
extern void TXAResCheck (int channel);
|
|
|
|
extern void TXASetupBPFilters (int channel);
|
|
|
|
#endif
|