Add power control to AM (power on/off per sample)
This commit is contained in:
parent
986e933187
commit
0200b8dc44
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue