speech_out[i] = 0;
else if (valid < 0)
for (i = 0; i < nout; i++)
- speech_out[i] = FDMDV_SCALE*demod_in[i].real;
+ speech_out[i] = FDMDV_SCALE*demod_in[i].real;
else {
- int frames = f->n_codec_bits / bits_per_codec_frame;
- for (i = 0; i < frames; i++) {
+ int frames = f->n_codec_bits / bits_per_codec_frame;
+ for (i = 0; i < frames; i++) {
codec2_decode(f->codec2, speech_out, f->packed_codec_bits + i * bytes_per_codec_frame);
speech_out += codec2_samples_per_frame(f->codec2);
- }
+ }
}
//fprintf(stderr,"freedv_nin(f): %d nout: %d\n", freedv_nin(f), nout);
return fsk;
}
-#define HORUS_MIN 100
-#define HORUS_MAX 4800
-#define HORUS_MIN_SPACING 200
+#define HORUS_MIN 800
+#define HORUS_MAX 2500
+#define HORUS_MIN_SPACING 100
/*---------------------------------------------------------------------------*\
int fft_samps;
float hann;
float max;
+ float tc;
int imax;
kiss_fftr_cfg fft_cfg = fsk->fft_cfg;
int freqi[M];
int f_min,f_max,f_zero;
-
/* Array to do complex FFT from using kiss_fft */
/* It'd probably make more sense here to use kiss_fftr */
f_min = (fsk->est_min*Ndft)/Fs;
f_max = (fsk->est_max*Ndft)/Fs;
- f_zero = (fsk->est_space*Ndft)/(Fs);
-
+ f_zero = (fsk->est_space*Ndft)/Fs;
+
+ /* scale averaging time constant based on number of samples */
+ tc = 0.95*Ndft/Fs;
+
int fft_loops = nin/Ndft;
for(j=0; j<fft_loops; j++){
/* Copy FSK buffer into reals of FFT buffer and apply a hann window */
/* Mix back in with the previous fft block */
/* Copy new fft est into imag of fftout for frequency divination below */
for(i=0; i<Ndft/2; i++){
- fsk->fft_est[i] = fsk->fft_est[i]*.95 + sqrtf(fftout[i].r)*.05;
+ fsk->fft_est[i] = (fsk->fft_est[i]*(1-tc)) + (sqrtf(fftout[i].r)*tc);
fftout[i].i = fsk->fft_est[i];
}
}
imax = 0;
max = 0;
for(j=0;j<Ndft/2;j++){
- if(fftout[j].i > max){
+ if(fftout[j].i >= max){
max = fftout[j].i;
imax = j;
}
f_min = f_min < 0 ? 0 : f_min;
f_max = imax + f_zero;
f_max = f_max > Ndft ? Ndft : f_max;
- for(j=f_min; j<f_max; j++)
+ for(j=f_min+1; j<f_max; j++)
fftout[j].i = 0;
/* Stick the freq index on the list */
else
fsk->nin = N;
- modem_probe_samp_f("t_norm_rx_timing",&(norm_rx_timing),1);;
+ modem_probe_samp_f("t_norm_rx_timing",&(norm_rx_timing),1);
+ modem_probe_samp_i("t_nin",&(fsk->nin),1);
/* Re-sample the integrators with linear interpolation magic */
int low_sample = (int)floorf(rx_timing);
else
fsk->nin = N;
- modem_probe_samp_f("t_norm_rx_timing",&(norm_rx_timing),1);;
+ modem_probe_samp_f("t_norm_rx_timing",&(norm_rx_timing),1);
+ modem_probe_samp_i("t_nin",&(fsk->nin),1);
/* Re-sample the integrators with linear interpolation magic */
int low_sample = (int)floorf(rx_timing);