Hello,
I have found what I think is a bug in rtl_fm.c : on line 171 there is if (fm->prev_index < (fm->downsample)) { but fm->prev_index start at -1 so to get an undersampling of factor fm->downsample, one should have if (fm->prev_index < (fm->downsample-1)) {
Without this correction, I get underruns, with this one, there is no underrun.
Moreover, I have tried the idea of http://www.embedded.com/design/embedded/4212086/DSP-Tricks--Frequency-demodu... to avoid atan : +int polar_discriminant2(int ar, int aj, int br, int bj) +{ + int cr, cj; + double angle; + angle = (double)(ar * (aj - bj) - aj * (ar - br)) / (double)(ar*ar + aj*aj); + return (int)(angle*(1<<12)); +}
Finally, to get good results, I use these parameters : DEFAULT_BUF_LENGTH (32 * 16384) capture_rate = 2304000 fm->downsample = 12 fm->post_downsample=8 sample_rate = 24000
Best regards,
Alain Prignet