First somewhat working version
This commit is contained in:
parent
477b425043
commit
5fccd98d90
|
@ -1,4 +1,4 @@
|
|||
all: .depends costas-beacon-sync.o fft-beacon-finder.o
|
||||
all: .depends test
|
||||
|
||||
CXX=clang++
|
||||
CXXFLAGS=-Wall
|
||||
|
@ -10,6 +10,9 @@ LDFLAGS=-lliquid
|
|||
%.o : %.cpp
|
||||
$(CXX) $(CFLAGS) -c $< -o $@
|
||||
|
||||
test: test.o costas-beacon-sync.o fft-beacon-finder.o
|
||||
$(CXX) $(LDFLAGS) -o $@ $?
|
||||
|
||||
clean:
|
||||
rm *.o
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ std::complex<float> FFTBeaconFinder::work(std::complex<float> in) {
|
|||
int center_idx = spectral_bin_to_fft_idx(bin);
|
||||
float center_val = std::abs(fft_out[center_idx]) / fft_max;
|
||||
if (center_val > 0.25) {
|
||||
printf("Found peak candidate at %d\n", bin);
|
||||
int left_idx = spectral_bin_to_fft_idx(bin - 127);
|
||||
int right_idx = spectral_bin_to_fft_idx(bin + 127);
|
||||
float left_val = std::abs(fft_out[left_idx]) / fft_max;
|
||||
|
@ -49,7 +48,6 @@ std::complex<float> FFTBeaconFinder::work(std::complex<float> in) {
|
|||
|
||||
if (max_levels > 0.0) {
|
||||
float center_freq = max_center * samplingrate / FFT_LEN;
|
||||
printf("Found center at %f\n", center_freq);
|
||||
nco_crcf_set_frequency(
|
||||
coarse_correction,
|
||||
-(2 * M_PI * center_freq) / samplingrate);
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
#include<cstdio>
|
||||
|
||||
#include<complex>
|
||||
|
||||
#include "fft-beacon-finder.h"
|
||||
#include "costas-beacon-sync.h"
|
||||
|
||||
int main(int argc, char const *argv[]) {
|
||||
|
||||
FILE* output = fopen("output.raw", "w");
|
||||
FILE* input = fopen("input.raw", "r");
|
||||
|
||||
FFTBeaconFinder finder(1000000);
|
||||
CostasBeaconSync sync(1e-3f, 0.3, -1.0, 1.0);
|
||||
|
||||
std::complex<float> in;
|
||||
while(fread(&in, sizeof(std::complex<float>), 1, input) == 1) {
|
||||
std::complex<float> coarse_synced = finder.work(in);
|
||||
std::complex<float> sync_correction = sync.work(coarse_synced);
|
||||
std::complex<float> out = coarse_synced * sync_correction;
|
||||
|
||||
fwrite(&out, sizeof(std::complex<float>), 1, output);
|
||||
};
|
||||
|
||||
fclose(input);
|
||||
fclose(output);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue