This commit is contained in:
Ryzerth 2020-11-02 16:16:21 +01:00
parent 75f8a45119
commit fc9bc496cb
6 changed files with 89 additions and 21 deletions

View File

@ -1,7 +1,7 @@
#pragma once
#include <dsp/block.h>
#include <dsp/window.h>
#include <spdlog/
#include <spdlog/spdlog.h>
namespace dsp {
@ -127,8 +127,11 @@ namespace dsp {
}
int run() {
spdlog::warn("+++++++++++++ DEEMP READING");
count = _in->read();
if (count < 0) { return -1; }
if (count < 0) { spdlog::warn("++++++++++ DEEMP EXIT"); return -1; }
spdlog::warn("+++++++++++++ DEEMP PROC");
if (bypass) {
if (out.aquire() < 0) { return -1; }
@ -146,6 +149,8 @@ namespace dsp {
}
lastOut = out.data[count - 1];
spdlog::warn("+++++++++++++ DEEMP DONE");
_in->flush();
out.write(count);
return count;

View File

@ -96,16 +96,23 @@ namespace dsp {
}
int run() {
if constexpr (std::is_same_v<T, float>) { spdlog::warn("======= RESAMP WAITING ========"); }
count = _in->read();
if (count < 0) { return -1; }
if (count < 0) {
return -1;
}
int outCount = calcOutSize(count);
memcpy(bufStart, _in->data, count * sizeof(T));
_in->flush();
if constexpr (std::is_same_v<T, float>) { spdlog::warn("======= RESAMP GOT DATA ========"); }
// Write to output
if (out.aquire() < 0) { return -1; }
if (out.aquire() < 0) {
return -1;
}
int outIndex = 0;
if constexpr (std::is_same_v<T, float>) {
for (int i = 0; outIndex < outCount; i += _decim) {
@ -129,6 +136,8 @@ namespace dsp {
}
out.write(count);
if constexpr (std::is_same_v<T, float>) { spdlog::warn("======= RESAMP WRITTEN ========"); }
memmove(buffer, &buffer[count], tapCount * sizeof(T));
return count;

View File

@ -96,4 +96,38 @@ namespace dsp {
stream<T>* _in;
};
template <class T>
class NullSink : public generic_block<NullSink<T>> {
public:
NullSink() {}
NullSink(stream<T>* in) { init(in); }
~NullSink() { generic_block<NullSink<T>>::stop(); }
void init(stream<T>* in) {
_in = in;
generic_block<NullSink<T>>::registerInput(_in);
}
void setInput(stream<T>* in) {
std::lock_guard<std::mutex> lck(generic_block<NullSink<T>>::ctrlMtx);
generic_block<NullSink<T>>::tempStop();
_in = in;
generic_block<NullSink<T>>::tempStart();
}
int run() {
count = _in->read();
if (count < 0) { return -1; }
_in->flush();
return count;
}
private:
int count;
stream<T>* _in;
};
}

View File

@ -35,10 +35,13 @@ namespace dsp {
}
void write(int size) {
std::lock_guard<std::mutex> lck(sigMtx);
contentSize = size;
dataReady = true;
cv.notify_all();
{
std::lock_guard<std::mutex> lck(sigMtx);
contentSize = size;
dataReady = true;
lck.~lock_guard();
}
cv.notify_one();
}
int read() {
@ -50,15 +53,21 @@ namespace dsp {
}
void flush() {
std::lock_guard<std::mutex> lck(sigMtx);
dataReady = false;
cv.notify_all();
{
std::lock_guard<std::mutex> lck(sigMtx);
dataReady = false;
lck.~lock_guard();
}
cv.notify_one();
}
void stopReader() {
std::lock_guard<std::mutex> lck(sigMtx);
readerStop = true;
cv.notify_all();
{
std::lock_guard<std::mutex> lck(sigMtx);
readerStop = true;
lck.~lock_guard();
}
cv.notify_one();
}
void clearReadStop() {
@ -66,9 +75,12 @@ namespace dsp {
}
void stopWriter() {
std::lock_guard<std::mutex> lck(sigMtx);
writerStop = true;
cv.notify_all();
{
std::lock_guard<std::mutex> lck(sigMtx);
writerStop = true;
lck.~lock_guard();
}
cv.notify_one();
}
void clearWriteStop() {
@ -80,12 +92,12 @@ namespace dsp {
private:
void waitReady() {
std::unique_lock<std::mutex> lck(sigMtx);
cv.wait(lck, [this]{ return !dataReady || writerStop; });
cv.wait(lck, [this]{ return (!dataReady || writerStop); });
}
void waitData() {
std::unique_lock<std::mutex> lck(sigMtx);
cv.wait(lck, [this]{ return dataReady || readerStop; });
cv.wait(lck, [this]{ return (dataReady || readerStop); });
}
std::mutex sigMtx;

View File

@ -1,5 +1,6 @@
#include <path.h>
#include <signal_path/audio.h>
#include <spdlog/spdlog.h>
SigPath::SigPath() {
@ -45,11 +46,13 @@ void SigPath::init(std::string vfoName, uint64_t sampleRate, int blockSize) {
ssbDemod.init(vfo->output, 6000, 3000, dsp::SSBDemod::MODE_USB);
audioWin.init(24000, 24000, 200000);
audioResamp.init(&demod.out, &audioWin, 200000, 48000);
audioResamp.init(&DUMMY_STREAM, &audioWin, 200000, 48000);
audioWin.setSampleRate(audioResamp.getInterpolation() * 200000);
audioResamp.updateWindow(&audioWin);
deemp.init(&audioResamp.out, 48000, 50e-6);
ns.init(&demod.out);
outputSampleRate = audio::registerMonoStream(&deemp.out, vfoName, vfoName, sampleRateChangeHandler, this);
@ -284,6 +287,7 @@ void SigPath::setBandwidth(float bandWidth) {
void SigPath::start() {
demod.start();
audioResamp.start();
deemp.start();
//deemp.start();
ns.start();
audio::startStream(vfoName);
}

View File

@ -63,6 +63,10 @@ private:
dsp::filter_window::BlackmanWindow audioWin;
dsp::PolyphaseResampler<float> audioResamp;
// Debug
dsp::NullSink<float> ns;
dsp::stream<float> DUMMY_STREAM;
std::string vfoName;
float sampleRate;