From: baobrien Date: Sat, 12 Mar 2016 00:12:14 +0000 (+0000) Subject: Fixed freq. est in fsk.c X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=8be613057507cf1e19abb1499d0a2f992480f565;p=freetel-svn-tracking.git Fixed freq. est in fsk.c git-svn-id: https://svn.code.sf.net/p/freetel/code@2725 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/octave/fsk_horus.m b/codec2-dev/octave/fsk_horus.m index 4dc8f54d..a7f788c0 100644 --- a/codec2-dev/octave/fsk_horus.m +++ b/codec2-dev/octave/fsk_horus.m @@ -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; diff --git a/codec2-dev/octave/hackrf_uc.m b/codec2-dev/octave/hackrf_uc.m index f191bb31..0f55bd1b 100644 --- a/codec2-dev/octave/hackrf_uc.m +++ b/codec2-dev/octave/hackrf_uc.m @@ -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 diff --git a/codec2-dev/src/fsk.c b/codec2-dev/src/fsk.c index 1a72a097..1b419abb 100644 --- a/codec2-dev/src/fsk.c +++ b/codec2-dev/src/fsk.c @@ -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. -*/ - -#include -#include -#include -#include -#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); -} -