From 72f990f3d455734cff9c46e47f72be03562c54df Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Mon, 17 Sep 2012 18:39:57 +0200 Subject: [PATCH] also minimize delay in decode.c, added comment in debug.c --- debug.c | 1 + decode.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/debug.c b/debug.c index e0722a6..5671b53 100644 --- a/debug.c +++ b/debug.c @@ -113,6 +113,7 @@ int main(int argc, char **argv) int cnt_delay = (dat_taps - 1) / (2 * factor_L); int dat_delay = (cnt_taps - 1) / (2 * factor_L); + // minimize delay if (cnt_delay > dat_delay) { cnt_delay -= dat_delay; dat_delay = 0; diff --git a/decode.c b/decode.c index 3d0dc40..4b82240 100644 --- a/decode.c +++ b/decode.c @@ -337,6 +337,15 @@ int demodulate(struct pcm *pcm, float *cnt_freq, float *dat_freq, float *drate) cnt_delay = (dat_taps - 1) / (2 * factor_L); dat_delay = (cnt_taps - 1) / (2 * factor_L); + // minimize delay + if (cnt_delay > dat_delay) { + cnt_delay -= dat_delay; + dat_delay = 0; + } else { + dat_delay -= cnt_delay; + cnt_delay = 0; + } + pcm_buff = (short *)malloc(sizeof(short) * channels * factor_M); // 0.1 second history + enough room for delay and taps