@@ -293,9 +293,9 @@ void demod_psk_init (enum modem_t modem_type, int samples_per_sec, int bps, char
293
293
294
294
D -> ms_filter_len_bits = 1.25 ; // Delay line > 13/12 * symbol period
295
295
296
- D -> coffs = (int ) round ( (11. / 12. ) * (float )samples_per_sec / (float )correct_baud );
296
+ D -> coffs = (int ) round ( (11.f / 12.f ) * (float )samples_per_sec / (float )correct_baud );
297
297
D -> boffs = (int ) round ( (float )samples_per_sec / (float )correct_baud );
298
- D -> soffs = (int ) round ( (13. / 12. ) * (float )samples_per_sec / (float )correct_baud );
298
+ D -> soffs = (int ) round ( (13.f / 12.f ) * (float )samples_per_sec / (float )correct_baud );
299
299
}
300
300
else {
301
301
@@ -380,18 +380,18 @@ void demod_psk_init (enum modem_t modem_type, int samples_per_sec, int bps, char
380
380
381
381
D -> ms_filter_len_bits = 1.25 ; // Delay line > 10/9 * symbol period
382
382
383
- D -> coffs = (int ) round ( (8. / 9. ) * (float )samples_per_sec / (float )correct_baud );
383
+ D -> coffs = (int ) round ( (8.f / 9.f ) * (float )samples_per_sec / (float )correct_baud );
384
384
D -> boffs = (int ) round ( (float )samples_per_sec / (float )correct_baud );
385
- D -> soffs = (int ) round ( (10. / 9. ) * (float )samples_per_sec / (float )correct_baud );
385
+ D -> soffs = (int ) round ( (10.f / 9.f ) * (float )samples_per_sec / (float )correct_baud );
386
386
}
387
387
388
388
389
389
if (D -> psk_use_lo ) {
390
- D -> lo_step = (int ) round ( 256. * 256. * 256. * 256. * carrier_freq / (float )samples_per_sec );
390
+ D -> lo_step = (int ) round ( 256. * 256. * 256. * 256. * carrier_freq / (double )samples_per_sec );
391
391
392
392
assert (MAX_FILTER_SIZE >= 256 );
393
393
for (j = 0 ; j < 256 ; j ++ ) {
394
- D -> m_sin_table [j ] = sinf (2. * M_PI * j / 256. );
394
+ D -> m_sin_table [j ] = sinf (2.f * ( float ) M_PI * j / 256.f );
395
395
}
396
396
}
397
397
@@ -491,11 +491,11 @@ void demod_psk_init (enum modem_t modem_type, int samples_per_sec, int bps, char
491
491
f2 = carrier_freq + D -> prefilter_baud * correct_baud ;
492
492
#if 0
493
493
text_color_set (DW_COLOR_DEBUG );
494
- dw_printf ("Generating prefilter %.0f to %.0f Hz.\n" , f1 , f2 );
494
+ dw_printf ("Generating prefilter %.0f to %.0f Hz.\n" , ( double ) f1 , ( double ) f2 );
495
495
#endif
496
496
if (f1 <= 0 ) {
497
497
text_color_set (DW_COLOR_ERROR );
498
- dw_printf ("Prefilter of %.0f to %.0f Hz doesn't make sense.\n" , f1 , f2 );
498
+ dw_printf ("Prefilter of %.0f to %.0f Hz doesn't make sense.\n" , ( double ) f1 , ( double ) f2 );
499
499
f1 = 10 ;
500
500
}
501
501
@@ -642,7 +642,7 @@ void demod_psk_process_sample (int chan, int subchan, int sam, struct demodulato
642
642
/* 256 units/cycle makes modulo processing easier. */
643
643
/* Make sure it is positive before truncating to integer. */
644
644
645
- id = ((int )((delta / (2.f * M_PI ) + 1.f ) * 256.f )) & 0xff ;
645
+ id = ((int )((delta / (2.f * ( float ) M_PI ) + 1.f ) * 256.f )) & 0xff ;
646
646
647
647
if (D -> modem_type == MODEM_QPSK ) {
648
648
demod_phase_shift = ((id + 32 ) >> 6 ) & 0x3 ;
@@ -686,7 +686,7 @@ void demod_psk_process_sample (int chan, int subchan, int sam, struct demodulato
686
686
}
687
687
#else
688
688
a = my_atan2f (I ,Q );
689
- int id = ((int )((a / (2.f * M_PI ) + 1.f ) * 256.f )) & 0xff ;
689
+ int id = ((int )((a / (2.f * ( float ) M_PI ) + 1.f ) * 256.f )) & 0xff ;
690
690
// 128 compensates for 180 degree phase shift due
691
691
// to 1 1/2 carrier cycles per symbol period.
692
692
demod_phase_shift = ((id + 128 ) >> 6 ) & 0x3 ;
@@ -697,7 +697,7 @@ void demod_psk_process_sample (int chan, int subchan, int sam, struct demodulato
697
697
int idelta ;
698
698
699
699
a = my_atan2f (I ,Q );
700
- idelta = ((int )((a / (2.f * M_PI ) + 1.f ) * 256.f )) & 0xff ;
700
+ idelta = ((int )((a / (2.f * ( float ) M_PI ) + 1.f ) * 256.f )) & 0xff ;
701
701
// 32 (90 degrees) compensates for 1800 carrier vs. 1800 baud.
702
702
// 16 is to set threshold between constellation points.
703
703
demod_phase_shift = ((idelta - 32 - 16 ) >> 5 ) & 0x7 ;
@@ -827,16 +827,20 @@ static void inline nudge_pll (int chan, int subchan, int slice, int demod_bits,
827
827
828
828
/*
829
829
* If demodulated data has changed,
830
- * pull the PLL phase closer to zero.
830
+ * Pull the PLL phase closer to zero.
831
+ * Use "floor" instead of simply casting so the sign won't flip.
832
+ * For example if we had -0.7 we want to end up with -1 rather than 0.
831
833
*/
832
834
835
+ // TODO: demod_9600 has an improved technique. Would it help us here?
836
+
833
837
if (demod_bits != D -> slicer [slice ].prev_demod_data ) {
834
838
835
839
if (hdlc_rec_gathering (chan , subchan , slice )) {
836
- D -> slicer [slice ].data_clock_pll = (int )floor (( double )(D -> slicer [slice ].data_clock_pll ) * D -> pll_locked_inertia );
840
+ D -> slicer [slice ].data_clock_pll = (int )floorf (( float )(D -> slicer [slice ].data_clock_pll ) * D -> pll_locked_inertia );
837
841
}
838
842
else {
839
- D -> slicer [slice ].data_clock_pll = (int )floor (( double )(D -> slicer [slice ].data_clock_pll ) * D -> pll_searching_inertia );
843
+ D -> slicer [slice ].data_clock_pll = (int )floorf (( float )(D -> slicer [slice ].data_clock_pll ) * D -> pll_searching_inertia );
840
844
}
841
845
}
842
846
0 commit comments