fixed bug in 7500-8000Hz resampler
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 26 Jul 2015 23:21:57 +0000 (23:21 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 26 Jul 2015 23:21:57 +0000 (23:21 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@2244 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/src/fdmdv.c
codec2-dev/src/freedv_api.c
codec2-dev/src/freedv_api.h

index 7ff16c597913ef3377d3c0caf233c7fb2301804c..bab288d51c84f73a007f70d1221bce2ee3cbc775 100644 (file)
@@ -422,7 +422,7 @@ void tx_filter_and_upconvert(COMP tx_fdm[], int Nc, COMP tx_symbols[],
 
     for(c=0; c<Nc+1; c++)
        tx_filter_memory[c][NSYM-1] = cmult(tx_symbols[c], gain);
-    
+
     /* 
        tx filter each symbol, generate M filtered output samples for
        each symbol, which we then freq shift and sum with other
index 6baf8d79cfed1188e7e1571ca8c024c42d7e0f74..4850247e2a83bf9e349ae1c0a6422c8d07c38016 100644 (file)
@@ -74,10 +74,10 @@ struct freedv *freedv_open(int mode) {
     f->test_frames = f->smooth_symbols = 0;
     f->freedv_put_error_pattern = NULL;
     f->error_pattern_callback_state = NULL;
-    f->snr_squelch_thresh = 2.0;
-    f->squelch_en = 1;
    
     if (mode == FREEDV_MODE_1600) {
+        f->snr_squelch_thresh = 2.0;
+        f->squelch_en = 1;
         Nc = 16;
         f->tx_sync_bit = 0;
         codec2_mode = CODEC2_MODE_1300;
@@ -103,6 +103,8 @@ struct freedv *freedv_open(int mode) {
     }
 
     if (mode == FREEDV_MODE_700) {
+        f->snr_squelch_thresh = 0.0;
+        f->squelch_en = 0;
         codec2_mode = CODEC2_MODE_700;
         f->cohpsk = cohpsk_create();
         f->nin = COHPSK_NOM_SAMPLES_PER_FRAME;
@@ -729,18 +731,33 @@ int freedv_comprx(struct freedv *f, short speech_out[], COMP demod_in[]) {
             }
             else {
                 float t,a,b,s;
-                int   t1,t2;
+                int   t1;
 
                 /* if not in sync pass through analog samples */
                 /* this lets us "hear" whats going on, e.g. during tuning */
                 /* need to linearly interp as Fs in and out slightly different */
+                /* this is a bit crude (compared to analog FreeDV mode)
+                   but it's probably OK for a tuning aid off air signals */
 
                 for(i=0, t=0.0; i<f->n_speech_samples; i++, t+=(float)f->modem_sample_rate/FS) {
-                    t1 = floor(t); t2 = ceil(t);
+                    t1 = floor(t);
                     a = t - t1;
-                    b = t2 - t1;
-                    s = b*demod_in[t1].real + a*demod_in[t2].real;               
+                    b = 1.0 - a;
+
+                    /* avoid running past end of input array */
+                    
+                    if (t1 < (f->nin-1)) 
+                        s = b*demod_in[t1].real + a*demod_in[t1+1].real;       
+                    else
+                        s = b*demod_in[t1].real;
+                    
                     speech_out[i] = FDMDV_SCALE*s;
+                    /*
+                    if ((i < 10) || (i > 590)) {
+                        printf("i: %d t: %f t1: %d a: %f b: %f s[t1]: %f s[t2]: %f s: %f\n",
+                               i,t,t1,a,b,demod_in[t1].real, demod_in[t1+1].real, s);
+                    }
+                    */
                 }
                 nout = f->n_speech_samples;
                 //fprintf(stderr, "%d %d %d\n", f->n_speech_samples, speech_out[0], speech_out[nin_prev-1]);
index 556e01cee0f161b2b5511eb3bd7a1395dbe8a367..c6921ed2e80ae979b9c3f9deafa7108d8173b584 100644 (file)
@@ -50,7 +50,7 @@ struct freedv {
     struct COHPSK       *cohpsk;
 
     int                  n_speech_samples;
-    int                  n_nom_modem_samples;    // size of tx and most rx modenm sample buffers
+    int                  n_nom_modem_samples;    // size of tx and most rx modem sample buffers
     int                  n_max_modem_samples;    // make your rx modem sample buffers this big
 
     int                  modem_sample_rate;      // ATM caller is responsible for meeting this (TBC)