qo100-trx-prototypes/blocks/test.cpp

41 lines
1.1 KiB
C++

#include <cstdio>
#include <iostream>
#include <complex>
#include "costas-beacon-sync.h"
#include "fft-beacon-finder.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(0.03, -0.1, 0.1);
int sample_count = 0;
clock_t start_time = clock();
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);
sample_count++;
};
clock_t end_time = clock();
clock_t result = end_time - start_time;
std::cout << "Processed " << sample_count << " samples ("
<< sample_count / 1000000.0 << "s) "
<< "in " << result / CLOCKS_PER_SEC << " s" << std::endl;
fclose(input);
fclose(output);
return 0;
}