Add power control to AM (power on/off per sample)

This commit is contained in:
Andreas Eversberg 2019-12-05 21:57:23 +01:00
parent 986e933187
commit 0200b8dc44
3 changed files with 7 additions and 5 deletions

View File

@ -91,7 +91,7 @@ void am_mod_exit(am_mod_t __attribute__((unused)) *mod)
{
}
void am_modulate_complex(am_mod_t *mod, sample_t *amplitude, int num, float *baseband)
void am_modulate_complex(am_mod_t *mod, sample_t *amplitude, uint8_t *power, int num, float *baseband)
{
int s;
double vector;
@ -101,7 +101,10 @@ void am_modulate_complex(am_mod_t *mod, sample_t *amplitude, int num, float *bas
double bias = mod->bias;
for (s = 0; s < num; s++) {
vector = *amplitude++ * gain + bias;
if (*power++)
vector = *amplitude++ * gain + bias;
else
vector = 0.0;
if (fast_math) {
*baseband++ += cos_tab[(uint16_t)phase] * vector;
*baseband++ += sin_tab[(uint16_t)phase] * vector;

View File

@ -12,7 +12,7 @@ typedef struct am_mod {
int am_mod_init(am_mod_t *mod, double samplerate, double offset, double gain, double bias);
void am_mod_exit(am_mod_t *mod);
void am_modulate_complex(am_mod_t *mod, sample_t *amplitude, int num, float *baseband);
void am_modulate_complex(am_mod_t *mod, sample_t *amplitude, uint8_t *power, int num, float *baseband);
typedef struct am_demod {
double rot; /* angle to rotate vector per sample */

View File

@ -775,8 +775,7 @@ int sdr_write(void *inst, sample_t **samples, uint8_t **power, int num, enum pag
if (on[c] && sdr->paging_channel)
fm_modulate_complex(&sdr->chan[sdr->paging_channel].fm_mod, samples[c], power[c], num, buff);
else if (sdr->chan[c].am) {
if (power[c][0])
am_modulate_complex(&sdr->chan[c].am_mod, samples[c], num, buff);
am_modulate_complex(&sdr->chan[c].am_mod, samples[c], power[c], num, buff);
} else
fm_modulate_complex(&sdr->chan[c].fm_mod, samples[c], power[c], num, buff);
}