linux compile fix

This commit is contained in:
AlexandreRouma
2026-03-10 16:51:21 -04:00
parent 5c7b6997df
commit d42f0ca0bc
17 changed files with 70 additions and 451 deletions

View File

@@ -1,71 +1,31 @@
#include <stdio.h>
#include <exception>
#include "dsp/buffer.h"
#include "dsp/demod/fm.h"
#include "dsp/sink/file.h"
#include <string.h>
#include <atomic>
#include <thread>
#include "dsp/source/wgn.h"
#include "../dsp/buffer.h"
#include "../dsp/source/wgn.h"
#include "../dsp/demod/fm.h"
#include "../dsp/taps/low_pass.h"
#include "../dsp/mrate/fir_decim.h"
#include "../dsp/sink/file.h"
#define BUFFER_SIZE 1250
void sendWorker(dsp::Stream<dsp::Complex>* input) {
// Generate a buffer of random data
dsp::source::WGN<dsp::Complex> wgn(1.0);
dsp::Buffer<dsp::Complex> randShit(BUFFER_SIZE);
wgn.source(randShit.data(), BUFFER_SIZE);
while (true) {
// Get a buffer for sending
auto bset = input->reserve(BUFFER_SIZE);
// Copy over the samples
memcpy(bset.buffer[0], randShit.data(), BUFFER_SIZE * sizeof(dsp::Complex));
// Send the samples
if (!input->send(BUFFER_SIZE)) { break; }
}
}
std::atomic_uint64_t counter;
void receiveWorker(dsp::Stream<float>* output) {
while (true) {
// Receive a buffer
auto bset = output->recv();
if (!bset.samples) { break; }
// Add to the counter
counter += bset.samples;
// Flush the buffer
output->flush();
}
}
int main() {
try {
// Define the DSP
dsp::demod::FMw fmw = dsp::demod::FM(6125, 50e3);
dsp::source::WGN<dsp::Complex> wgn(1.0f);
dsp::demod::FM fmd(6125, 240e3);
dsp::mrate::FIRDecim<float, float> decim(dsp::taps::LowPass(20e3, 4e3, 240e3), 5);
dsp::sink::File<float> file("output.f32");
// Start the send worker
std::thread sendThread(sendWorker, fmw.in());
std::thread receiveThread(receiveWorker, fmw.out());
dsp::Buffer<dsp::Complex> cbuf(BUFFER_SIZE);
dsp::Buffer<float> rbuf(BUFFER_SIZE);
// Start the FM demod
fmw.start();
// Start receiving
while (true) {
// Get the number of samples processed
size_t proc = counter.exchange(0);
// Print
printf("%lf MS/s\n", (double)proc / 1e6);
// Wait
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}
wgn.source(cbuf, BUFFER_SIZE);
fmd.process(cbuf, rbuf, BUFFER_SIZE);
size_t ocount = decim.process(rbuf, rbuf, BUFFER_SIZE);
file.sink(rbuf, ocount);
return 0;
}