Fixed freq. est in fsk.c
authorbaobrien <baobrien@01035d8c-6547-0410-b346-abe4f91aad63>
Sat, 12 Mar 2016 00:12:14 +0000 (00:12 +0000)
committerbaobrien <baobrien@01035d8c-6547-0410-b346-abe4f91aad63>
Sat, 12 Mar 2016 00:12:14 +0000 (00:12 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@2725 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/octave/fsk_horus.m
codec2-dev/octave/hackrf_uc.m
codec2-dev/src/fsk.c
codec2-dev/src/vhf_deframe_c2.c [deleted file]

index 4dc8f54df43d6d0dba95c31fa95c1527b227684c..a7f788c0a1a15e6d4501d7a06f2b5d8cc4a0bafe 100644 (file)
@@ -90,10 +90,13 @@ endfunction
 %Init 'high-bit-rate horus'
 function states = fsk_horus_init_hbr(Fs,P,Rs,M=2)
   assert((M==2) || (M==4), "Only M=2 and M=4 FSK supported");
+  
+  nsym = 96;
+  
   states.M = M;                    
   states.bitspersymbol = log2(M);
   states.Fs = Fs;
-  N = states.N = Fs;                % processing buffer size, nice big window for timing est
+  N = states.N = Ts*nsym;            % processing buffer size, nice big window for timing est
   states.Ndft = 2.^ceil(log2(N))/2;  % find nearest power of 2 for efficient FFT
   %states.Ndft = 1024;               % find nearest power of 2 for efficient FFT
   states.Rs = Rs;
index f191bb31675414c75361f139f5669b52c8512e3d..0f55bd1b8d75e1efd81120d7df89756f581c0a13 100644 (file)
@@ -9,19 +9,24 @@
 %   $ hackrf_transfer -t ../octave/fsk_10M.iq -f 10000000 -a 1 -x 40
 
 function hackrf_uc(outfilename, infilename)
-  Fs1 = 96E3;  % input sample rate
+  pkg load signal;
+  Fs1 = 48E3;  % input sample rate
   Fs2 = 10E6;  % output sample rate to HackRF
   fc = 700E3-24E3;  % offset to shift to, HackRF doesn't like signals in the centre
   A  = 100;    % amplitude of signal after upc-nversion (max 127)
   N  = Fs1*20;
   
   fin = fopen(infilename,"rb");
-  s1 = fread(fin,Inf,"short");
+  printf("1\n");
+  s1 = fread(fin,"short");
+  printf("1\n");
   fclose(fin);
+  printf("1\n");
   ls1 = length(s1);
-
+  printf("1\n");
+  N = ls1;
   % single sided freq shifts, we don't want DSB
-
+  printf("1\n");
   s1 = hilbert(s1(1:N)); 
 
   % upsample to Fs2
@@ -31,11 +36,12 @@ function hackrf_uc(outfilename, infilename)
   ls2 = length(s2);
   mx = max(abs(s2));
   t = 0:ls2-1;
-
+  printf("2\n");
   % shift up to Fc, note use of rot90 rather than trasnpose operator '
   % as we don't want complex conj, that would shift down in freq
 
   sout = rot90((A/mx)*s2) .* exp(j*2*pi*t*fc/Fs2);
 
   save_hackrf(outfilename,sout);
+  
 end
index 1a72a097542be79b37eacd23c2217b2ac01908fe..1b419abb7ec19dc2edbe0f942cef727311e66bae 100644 (file)
@@ -131,7 +131,7 @@ struct FSK * fsk_create_hbr(int Fs, int Rs,int P,int M, int tx_f1, int tx_fs)
     int i;
     int memold;
     int Ndft = 0;
-    
+    printf(stdout,"hbr_initing\n");
     /* Number of symbols in a processing frame */
     //int nsyms = 96;
     int nsyms = 48;
@@ -178,7 +178,7 @@ struct FSK * fsk_create_hbr(int Fs, int Rs,int P,int M, int tx_f1, int tx_fs)
     
     fsk->est_max = (Fs/2)-Rs;
     
-    fsk->est_space = Rs-(Rs/5);
+    fsk->est_space = Rs-(Rs/10);
     
     /* Set up rx state */
     fsk->phi1_c = comp_exp_j(0);
@@ -235,8 +235,8 @@ struct FSK * fsk_create_hbr(int Fs, int Rs,int P,int M, int tx_f1, int tx_fs)
     return fsk;
 }
 
-#define HORUS_MIN 800
-#define HORUS_MAX 2500
+#define HORUS_MIN 100
+#define HORUS_MAX 4000
 #define HORUS_MIN_SPACING 200
 
 /*---------------------------------------------------------------------------*\
@@ -401,7 +401,7 @@ void fsk_demod_freq_est(struct FSK *fsk, float fsk_in[],float *freqs,int M){
     
     f_min  = (fsk->est_min*Ndft)/Fs;
     f_max  = (fsk->est_max*Ndft)/Fs;
-    f_zero = (fsk->est_space*Ndft)/(2*Fs);
+    f_zero = (fsk->est_space*Ndft)/(Fs);
 
     int fft_loops = nin/Ndft;
     for(j=0; j<fft_loops; j++){
diff --git a/codec2-dev/src/vhf_deframe_c2.c b/codec2-dev/src/vhf_deframe_c2.c
deleted file mode 100644 (file)
index 1477bfb..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-
-/*---------------------------------------------------------------------------*\
-
-  FILE........: vhf_deframe_c2.c
-  AUTHOR......: Brady O'Brien
-  DATE CREATED: 8 March 2016
-
-  C tool to extract codec2 data from freedv VHF 2400A/B/whatever frames
-   
-
-\*---------------------------------------------------------------------------*/
-
-/*
-  Copyright (C) 2016 David Rowe
-
-  All rights reserved.
-
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU Lesser General Public License version 2.1, as
-  published by the Free Software Foundation.  This program is
-  distributed in the hope that it will be useful, but WITHOUT ANY
-  WARRANTY; without even the implied warranty of MERCHANTABILITY or
-  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
-  License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with this program; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include "freedv_vhf_framing.h"
-
-int main(int argc,char *argv[]){
-    struct freedv_vhf_deframer * deframer;
-    FILE *fin,*fout;
-    uint8_t *bitbuf;
-    uint8_t *c2buf;
-    uint8_t zbuf[] = {0,0,0,0,0,0,0};
-    
-    if(argc<3){
-        fprintf(stderr,"usage: %s InputOneBitPerCharFile OutputC2File\n",argv[0]);
-        exit(1);
-    }
-    
-    /* Open files */
-    if(strcmp(argv[1],"-")==0){
-        fin = stdin;
-    }else{
-        fin = fopen(argv[1],"r");
-    }
-       
-    if(strcmp(argv[2],"-")==0){
-        fout = stdout;
-    }else{
-        fout = fopen(argv[2],"w");
-    }
-
-    /* Set up deframer */
-    deframer = fvhff_create_deframer(FREEDV_VHF_FRAME_A,0);
-    
-    if(fin==NULL || fout==NULL || deframer==NULL){
-        fprintf(stderr,"Couldn't open test vector files\n");
-        goto cleanup;
-    }
-    
-    /* allocate buffers for processing */
-    bitbuf = (uint8_t*)malloc(sizeof(uint8_t)*96);
-    c2buf = (uint8_t*)malloc(sizeof(uint8_t)*7);
-    
-    /* Deframe! */
-    while( fread(bitbuf,sizeof(uint8_t),96,fin) == 96 ){
-        if(fvhff_deframe_bits(deframer,c2buf,NULL,NULL,bitbuf))
-            fwrite(c2buf,sizeof(uint8_t),7,fout);
-        else
-            fwrite(zbuf,sizeof(uint8_t),7,fout);
-        
-        if(fin == stdin || fout == stdin){
-            fflush(fin);
-            fflush(fout);
-        }
-    }
-    
-    free(bitbuf);
-    free(c2buf);
-    
-    cleanup:
-    fclose(fin);
-    fclose(fout);
-    fvhff_destroy_deframer(deframer);
-    exit(0);
-}
-