mirror of https://github.com/wb2osz/direwolf.git
Accumulate DC average for audio signal.
This commit is contained in:
parent
22c810e442
commit
5b00875549
|
@ -292,6 +292,14 @@ unsigned char is_crc_in_queue(unsigned int chan, unsigned int crc) {
|
||||||
*
|
*
|
||||||
*------------------------------------------------------------------------------*/
|
*------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
static float dc_average[MAX_CHANS];
|
||||||
|
|
||||||
|
int multi_modem_get_dc_average (int chan)
|
||||||
|
{
|
||||||
|
// Scale to +- 200 so it will like the deviation measurement.
|
||||||
|
|
||||||
|
return ( (int) ((float)(dc_average[chan]) * (200.0f / 32767.0f) ) );
|
||||||
|
}
|
||||||
|
|
||||||
__attribute__((hot))
|
__attribute__((hot))
|
||||||
void multi_modem_process_sample (int chan, int audio_sample)
|
void multi_modem_process_sample (int chan, int audio_sample)
|
||||||
|
@ -300,6 +308,12 @@ void multi_modem_process_sample (int chan, int audio_sample)
|
||||||
int subchan;
|
int subchan;
|
||||||
static int i = 0; /* for interleaving among multiple demodulators. */
|
static int i = 0; /* for interleaving among multiple demodulators. */
|
||||||
|
|
||||||
|
// Accumulate an average DC bias level.
|
||||||
|
// Shouldn't happen with a soundcard but could with mistuned SDR.
|
||||||
|
|
||||||
|
dc_average[chan] = dc_average[chan] * 0.999f + (float)audio_sample * 0.001f;
|
||||||
|
|
||||||
|
|
||||||
// TODO: temp debug, remove this.
|
// TODO: temp debug, remove this.
|
||||||
|
|
||||||
assert (save_audio_config_p->achan[chan].num_subchan > 0 && save_audio_config_p->achan[chan].num_subchan <= MAX_SUBCHANS);
|
assert (save_audio_config_p->achan[chan].num_subchan > 0 && save_audio_config_p->achan[chan].num_subchan <= MAX_SUBCHANS);
|
||||||
|
|
|
@ -14,6 +14,8 @@ void multi_modem_init (struct audio_s *pmodem);
|
||||||
|
|
||||||
void multi_modem_process_sample (int c, int audio_sample);
|
void multi_modem_process_sample (int c, int audio_sample);
|
||||||
|
|
||||||
|
int multi_modem_get_dc_average (int chan);
|
||||||
|
|
||||||
void multi_modem_process_rec_frame (int chan, int subchan, int slice, unsigned char *fbuf, int flen, alevel_t alevel, retry_t retries);
|
void multi_modem_process_rec_frame (int chan, int subchan, int slice, unsigned char *fbuf, int flen, alevel_t alevel, retry_t retries);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue