Finished soapy module + added file source + added RTL_TCP source (windows only rn)

This commit is contained in:
Ryzerth
2020-10-04 02:56:02 +02:00
parent 47b04ffef4
commit 60342de9c0
21 changed files with 602 additions and 27 deletions

View File

@@ -3,6 +3,8 @@
#include <module.h>
#include <gui/gui.h>
#include <signal_path/signal_path.h>
#include <wavreader.h>
#include <core.h>
#define CONCAT(a, b) ((std::string(a) + b).c_str())
@@ -29,6 +31,11 @@ public:
handler.tuneHandler = tune;
handler.stream = &stream;
sigpath::sourceManager.registerSource("File", &handler);
reader = new WavReader("D:/satpic/raw_recordings/NOAA-18_09-08-2018_21-39-00_baseband_NR.wav");
spdlog::info("Samplerate: {0}, Bit depth: {1}, Channel count: {2}", reader->getSampleRate(), reader->getBitDepth(), reader->getChannelCount());
spdlog::info("FileSourceModule '{0}': Instance created!", name);
}
@@ -39,6 +46,7 @@ public:
private:
static void menuSelected(void* ctx) {
FileSourceModule* _this = (FileSourceModule*)ctx;
core::setInputSampleRate(_this->reader->getSampleRate());
spdlog::info("FileSourceModule '{0}': Menu Select!", _this->name);
}
@@ -49,11 +57,15 @@ private:
static void start(void* ctx) {
FileSourceModule* _this = (FileSourceModule*)ctx;
_this->workerThread = std::thread(worker, _this);
spdlog::info("FileSourceModule '{0}': Start!", _this->name);
}
static void stop(void* ctx) {
FileSourceModule* _this = (FileSourceModule*)ctx;
_this->stream.stopWriter();
_this->workerThread.join();
_this->stream.clearWriteStop();
spdlog::info("FileSourceModule '{0}': Stop!", _this->name);
}
@@ -62,15 +74,39 @@ private:
spdlog::info("FileSourceModule '{0}': Tune: {1}!", _this->name, freq);
}
static void menuHandler(void* ctx) {
FileSourceModule* _this = (FileSourceModule*)ctx;
ImGui::Text("Hi from %s!", _this->name.c_str());
}
static void worker(void* ctx) {
FileSourceModule* _this = (FileSourceModule*)ctx;
double sampleRate = _this->reader->getSampleRate();
int blockSize = sampleRate / 200.0;
int16_t* inBuf = new int16_t[blockSize * 2];
dsp::complex_t* outBuf = new dsp::complex_t[blockSize];
_this->stream.setMaxLatency(blockSize * 2);
while (true) {
_this->reader->readSamples(inBuf, blockSize * 2 * sizeof(int16_t));
for (int i = 0; i < blockSize; i++) {
outBuf[i].q = (float)inBuf[i * 2] / (float)0x7FFF;
outBuf[i].i = (float)inBuf[(i * 2) + 1] / (float)0x7FFF;
}
if (_this->stream.write(outBuf, blockSize) < 0) { break; };
//std::this_thread::sleep_for(std::chrono::milliseconds(5));
}
delete[] inBuf;
delete[] outBuf;
}
std::string name;
dsp::stream<dsp::complex_t> stream;
SourceManager::SourceHandler handler;
WavReader* reader;
std::thread workerThread;
};
MOD_EXPORT void _INIT_() {