Rs = states.Rs = 50;
Ts = states.Ts = Fs/Rs;
states.nsym = N/Ts;
- Nmem = states.Nmem = N+2*Ts; % one symbol memory in down converted signals to allow for timing adj
+ Nmem = states.Nmem = N+2*Ts; % two symbol memory in down converted signals to allow for timing adj
states.f1_dc = zeros(1,Nmem);
states.f2_dc = zeros(1,Nmem);
states.P = 8; % oversample rate out of filter
states.uw_thresh = 5*7 - 4; % allow 24bit errors when looking for UW
states.df = 0;
+ states.f1 = 0;
+ states.f2 = 0;
endfunction
%printf("f1: %4.0f Hz f2: %4.0f Hz\n", f1, f2);
end
- % down convert and filter at 4Rs ------------------------------
+ % down convert and filter at rate P ------------------------------
% update filter (integrator) memory by shifting in nin samples
% integrate over symbol period, which is effectively a LPF, removing
% the -2Fc frequency image. Can also be interpreted as an ideal
% integrate and dump, non-coherent demod. We run the integrator at
- % PRs (1/P symbol offsets) to get outputs at a range of different
+ % rate P (1/P symbol offsets) to get outputs at a range of different
% fine timing offsets. We calculate integrator output over nsym+1
% symbols so we have extra samples for the fine timing re-sampler at either
% end of the array.
end
states.nin = next_nin;
- % Re sample integrator outputs using fine timing estimate and linear interpolation
+ % Re-sample integrator outputs using fine timing estimate and linear interpolation
low_sample = floor(rx_timing);
fract = rx_timing - low_sample;
function rx_bits_log = demod_file(filename)
rx = load_raw(filename);
more off;
- rand('state',1);
- randn('state',1);
states = fsk_horus_init();
N = states.N;
P = states.P;
%rx_bits = demod_file("~/Desktop/vk5arg-3.wav");
%rx_bits = demod_file("~/Desktop/fsk_horus_10dB_1000ppm.wav");
%rx_bits = demod_file("~/Desktop/fsk_horus_6dB_0ppm.wav");
-rx_bits = demod_file("fsk_horus_rx.raw");
+%rx_bits = demod_file("fsk_horus_rx.raw");
%rx_bits = demod_file("~/Desktop/fsk_horus_20dB_0ppm_20dBfade.wav");
% streaming version: take a buffer of say 1 sec. demo to bits. Add to buffer
%
% usage:
% $ chmod 777 fsk_horus_stream.m
-% $ rec -t raw -r 8000 -s -2 - | ./fsk_horus_stream.m
+% $ rec -t raw -r 8000 -s -2 -c 1 - -q | ./fsk_horus_stream.m
fsk_horus; % include library (make sure calls to functions at bottom are commented out)
nin = states.nin;
%printf("nin: %d length(rx): %d length(rx_bits_buf): %d \n", nin, length(rx), length(rx_bits_buf));
endwhile
- % printf("nin: %d length(rx): %d length(rx_bits_buf): %d \n", nin, length(rx), length(rx_bits_buf));
+ f = (states.f1+states.f2)/2; shift = states.f2 - states.f1;
+ printf("max: %d f: %d shift %d bits: %d\r", max(s), f, shift, length(rx_bits_buf));
% look for complete Horus frame, delimited by 2 unique words