int main (int argc, char *argv[]) { awgn_state_t noise_source; dc_restore_state_t dc_state; int i; int idum = 1234567; int16_t dirty; int16_t clean; int estimate; int min; int max; int dc_offset; dc_offset = 5000; awgn_init_dbm0(&noise_source, idum, -10.0); dc_restore_init(&dc_state); for (i = 0; i < 100000; i++) { dirty = awgn(&noise_source) + dc_offset; clean = dc_restore(&dc_state, dirty); if ((i % 1000) == 0) { printf("Sample %6d: %d (expect %d)\n", i, dc_restore_estimate(&dc_state), dc_offset); } } /* We should have settled by now. Look at the variation we get */ min = 99999; max = -99999; for (i = 0; i < 100000; i++) { dirty = awgn(&noise_source) + dc_offset; clean = dc_restore(&dc_state, dirty); estimate = dc_restore_estimate(&dc_state); if (estimate < min) min = estimate; if (estimate > max) max = estimate; } printf("Spread of DC estimate for an offset of %d was %d to %d\n", dc_offset, min, max); if (min < dc_offset - 50 || max > dc_offset + 50) { printf("Test failed.\n"); exit(2); } printf("Test passed.\n"); return 0; }
SPAN_DECLARE(int) fax_rx(fax_state_t *s, int16_t *amp, int len) { int i; #if defined(LOG_FAX_AUDIO) if (s->modems.audio_rx_log >= 0) write(s->modems.audio_rx_log, amp, len*sizeof(int16_t)); #endif for (i = 0; i < len; i++) amp[i] = dc_restore(&s->modems.dc_restore, amp[i]); s->modems.rx_handler(s->modems.rx_user_data, amp, len); t30_timer_update(&s->t30, len); return 0; }
int fax_rx(fax_state_t *s, int16_t *amp, int len) { int i; #if defined(LOG_FAX_AUDIO) if (s->fax_audio_rx_log >= 0) write(s->fax_audio_rx_log, amp, len*sizeof(int16_t)); #endif for (i = 0; i < len; i++) amp[i] = dc_restore(&(s->dc_restore), amp[i]); s->rx_handler(s->rx_user_data, amp, len); t30_timer_update(&(s->t30_state), len); return 0; }
// function restore_card static int KSAPI restore_card(ks_reader_dev_t *dev,ks_card_info_t *card,int block_no) { return -1; #if 0 int ret; if(block_no >= 32*4 || block_no <= 0) return KS_BLOCK_OVERFLOW; if(!g_dev_hd) return KS_PORT_NOTOPEN; ret = dc_restore(g_dev_hd,block_no); if(ret) return KS_WRITEPURSE; return 0; #endif }