C-Netz: Use emphasis with 200 uS time constant

This commit is contained in:
Andreas Eversberg 2016-10-23 08:46:05 +02:00
parent 8864db8269
commit 1ea95de120
6 changed files with 17 additions and 12 deletions

View File

@ -422,7 +422,7 @@ int amps_create(int channel, enum amps_chan_type chan_type, const char *sounddev
amps->pre_emphasis = pre_emphasis;
amps->de_emphasis = de_emphasis;
rc = init_emphasis(&amps->estate, samplerate);
rc = init_emphasis(&amps->estate, samplerate, CUT_OFF_EMPHASIS_DEFAULT);
if (rc < 0)
goto error;

View File

@ -105,6 +105,8 @@
/* uncomment this to do echo debugging (-L) on Speech Channel */
//#define DEBUG_SPK
#define CUT_OFF_EMPHASIS_CNETZ 796 /* 200 uS time constant */
/* Call reference for calls from mobile station to network
This offset of 0x400000000 is required for MNCC interface. */
static int new_callref = 0x40000000;
@ -286,7 +288,7 @@ int cnetz_create(int kanal, enum cnetz_chan_type chan_type, const char *sounddev
cnetz->pre_emphasis = pre_emphasis;
cnetz->de_emphasis = de_emphasis;
rc = init_emphasis(&cnetz->estate, samplerate);
rc = init_emphasis(&cnetz->estate, samplerate, CUT_OFF_EMPHASIS_CNETZ);
if (rc < 0)
goto error;

View File

@ -26,10 +26,9 @@
#define PI M_PI
#define CUT_OFF_E 300.0 /* cut-off frequency for emphasis filters */
#define CUT_OFF_H 300.0 /* cut-off frequency for high-pass filters */
#define CUT_OFF_H 200.0 /* cut-off frequency for high-pass filters */
int init_emphasis(emphasis_t *state, int samplerate)
int init_emphasis(emphasis_t *state, int samplerate, double cut_off)
{
double factor, rc, dt;
@ -40,13 +39,15 @@ int init_emphasis(emphasis_t *state, int samplerate)
}
/* exp (-2 * PI * CUT_OFF * delta_t) */
factor = exp(-2.0 * PI * CUT_OFF_E / samplerate); /* 1/samplerate == delta_t */
factor = exp(-2.0 * PI * cut_off / samplerate); /* 1/samplerate == delta_t */
PDEBUG(DDSP, DEBUG_DEBUG, "Emphasis factor = %.3f\n", factor);
state->p.factor = factor;
state->p.amp = samplerate / 6350.0;
state->p.amp = samplerate / 6400.0;
state->d.d_factor = factor;
state->d.amp = 1.0 / (samplerate / 5550.0);
state->d.amp = 1.0 / (samplerate / 5750.0);
/* high-pass filter prevents low frequency noise and dc level
* from being amplified by de-emphasis */
rc = 1.0 / (CUT_OFF_H * 2.0 *3.14);
dt = 1.0 / samplerate;
state->d.h_factor = rc / (rc + dt);

View File

@ -13,7 +13,9 @@ typedef struct emphasis {
} d;
} emphasis_t;
int init_emphasis(emphasis_t *state, int samplerate);
#define CUT_OFF_EMPHASIS_DEFAULT 300.0
int init_emphasis(emphasis_t *state, int samplerate, double cut_off);
void pre_emphasis(emphasis_t *state, int16_t *samples, int num);
void de_emphasis(emphasis_t *state, int16_t *samples, int num);

View File

@ -130,7 +130,7 @@ int sender_create(sender_t *sender, int kanal, const char *sounddev, int sampler
}
}
rc = init_emphasis(&sender->estate, samplerate);
rc = init_emphasis(&sender->estate, samplerate, CUT_OFF_EMPHASIS_DEFAULT);
if (rc < 0)
goto error;

View File

@ -11,7 +11,7 @@
#define SAMPLERATE 48000
#define DEVIATION 8000.0
static double test_freq[] = { 25, 50, 100, 150, 200, 250, 300, 350, 400, 500, 1000, 2000, 4000, 0 };
static double test_freq[] = { 25, 50, 100, 200, 250, 300, 400, 500, 1000, 2000, 4000, 0 };
static void check_level(int16_t *samples, double freq, const char *desc)
{
@ -55,7 +55,7 @@ int main(void)
printf("1000 Hz shall be close to 0 dB, that is no significant change in volume.\n\n");
init_emphasis(&estate, SAMPLERATE);
init_emphasis(&estate, SAMPLERATE, CUT_OFF_EMPHASIS_DEFAULT);
for (i = 0; test_freq[i]; i++) {
gen_samples(samples, test_freq[i]);