mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-06-27 21:07:50 +02:00
Fixed waterfall inaccuracies + started adding stepped VFO
This commit is contained in:
@ -3,14 +3,14 @@
|
||||
namespace audio {
|
||||
std::map<std::string, AudioStream_t*> streams;
|
||||
|
||||
float registerMonoStream(dsp::stream<float>* stream, std::string name, std::string vfoName, int (*sampleRateChangeHandler)(void* ctx, float sampleRate), void* ctx) {
|
||||
double registerMonoStream(dsp::stream<float>* stream, std::string name, std::string vfoName, int (*sampleRateChangeHandler)(void* ctx, double sampleRate), void* ctx) {
|
||||
AudioStream_t* astr = new AudioStream_t;
|
||||
astr->type = STREAM_TYPE_MONO;
|
||||
astr->ctx = ctx;
|
||||
astr->audio = new io::AudioSink;
|
||||
astr->audio->init(1);
|
||||
astr->deviceId = astr->audio->getDeviceId();
|
||||
float sampleRate = astr->audio->devices[astr->deviceId].sampleRates[0];
|
||||
double sampleRate = astr->audio->devices[astr->deviceId].sampleRates[0];
|
||||
int blockSize = sampleRate / 200; // default block size
|
||||
astr->monoAudioStream = new dsp::stream<float>(blockSize * 2);
|
||||
astr->audio->setBlockSize(blockSize);
|
||||
@ -31,13 +31,13 @@ namespace audio {
|
||||
return sampleRate;
|
||||
}
|
||||
|
||||
float registerStereoStream(dsp::stream<dsp::StereoFloat_t>* stream, std::string name, std::string vfoName, int (*sampleRateChangeHandler)(void* ctx, float sampleRate), void* ctx) {
|
||||
double registerStereoStream(dsp::stream<dsp::StereoFloat_t>* stream, std::string name, std::string vfoName, int (*sampleRateChangeHandler)(void* ctx, double sampleRate), void* ctx) {
|
||||
AudioStream_t* astr = new AudioStream_t;
|
||||
astr->type = STREAM_TYPE_STEREO;
|
||||
astr->ctx = ctx;
|
||||
astr->audio = new io::AudioSink;
|
||||
astr->audio->init(1);
|
||||
float sampleRate = astr->audio->devices[astr->audio->getDeviceId()].sampleRates[0];
|
||||
double sampleRate = astr->audio->devices[astr->audio->getDeviceId()].sampleRates[0];
|
||||
int blockSize = sampleRate / 200; // default block size
|
||||
astr->stereoAudioStream = new dsp::stream<dsp::StereoFloat_t>(blockSize * 2);
|
||||
astr->audio->setBlockSize(blockSize);
|
||||
@ -95,7 +95,7 @@ namespace audio {
|
||||
delete astr->monoDynSplit;
|
||||
}
|
||||
|
||||
dsp::stream<float>* bindToStreamMono(std::string name, void (*streamRemovedHandler)(void* ctx), void (*sampleRateChangeHandler)(void* ctx, float sampleRate, int blockSize), void* ctx) {
|
||||
dsp::stream<float>* bindToStreamMono(std::string name, void (*streamRemovedHandler)(void* ctx), void (*sampleRateChangeHandler)(void* ctx, double sampleRate, int blockSize), void* ctx) {
|
||||
AudioStream_t* astr = streams[name];
|
||||
BoundStream_t bstr;
|
||||
bstr.type = STREAM_TYPE_MONO;
|
||||
@ -125,7 +125,7 @@ namespace audio {
|
||||
return bstr.monoStream;
|
||||
}
|
||||
|
||||
dsp::stream<dsp::StereoFloat_t>* bindToStreamStereo(std::string name, void (*streamRemovedHandler)(void* ctx), void (*sampleRateChangeHandler)(void* ctx, float sampleRate, int blockSize), void* ctx) {
|
||||
dsp::stream<dsp::StereoFloat_t>* bindToStreamStereo(std::string name, void (*streamRemovedHandler)(void* ctx), void (*sampleRateChangeHandler)(void* ctx, double sampleRate, int blockSize), void* ctx) {
|
||||
AudioStream_t* astr = streams[name];
|
||||
BoundStream_t bstr;
|
||||
bstr.type = STREAM_TYPE_STEREO;
|
||||
@ -250,7 +250,7 @@ namespace audio {
|
||||
return "";
|
||||
}
|
||||
|
||||
void setSampleRate(std::string name, float sampleRate) {
|
||||
void setSampleRate(std::string name, double sampleRate) {
|
||||
AudioStream_t* astr = streams[name];
|
||||
if (astr->running) {
|
||||
return;
|
||||
@ -288,7 +288,7 @@ namespace audio {
|
||||
}
|
||||
}
|
||||
|
||||
void setAudioDevice(std::string name, int deviceId, float sampleRate) {
|
||||
void setAudioDevice(std::string name, int deviceId, double sampleRate) {
|
||||
AudioStream_t* astr = streams[name];
|
||||
if (astr->running) {
|
||||
return;
|
||||
|
@ -11,13 +11,15 @@ namespace audio {
|
||||
_STREAM_TYPE_COUNT
|
||||
};
|
||||
|
||||
// TODO: Create a manager class and an instance class
|
||||
|
||||
struct BoundStream_t {
|
||||
dsp::stream<float>* monoStream;
|
||||
dsp::stream<dsp::StereoFloat_t>* stereoStream;
|
||||
dsp::StereoToMono* s2m;
|
||||
dsp::MonoToStereo* m2s;
|
||||
void (*streamRemovedHandler)(void* ctx);
|
||||
void (*sampleRateChangeHandler)(void* ctx, float sampleRate, int blockSize);
|
||||
void (*sampleRateChangeHandler)(void* ctx, double sampleRate, int blockSize);
|
||||
void* ctx;
|
||||
int type;
|
||||
};
|
||||
@ -31,8 +33,8 @@ namespace audio {
|
||||
dsp::DynamicSplitter<float>* monoDynSplit;
|
||||
dsp::stream<dsp::StereoFloat_t>* stereoStream;
|
||||
dsp::DynamicSplitter<dsp::StereoFloat_t>* stereoDynSplit;
|
||||
int (*sampleRateChangeHandler)(void* ctx, float sampleRate);
|
||||
float sampleRate;
|
||||
int (*sampleRateChangeHandler)(void* ctx, double sampleRate);
|
||||
double sampleRate;
|
||||
int blockSize;
|
||||
int type;
|
||||
bool running = false;
|
||||
@ -45,19 +47,19 @@ namespace audio {
|
||||
|
||||
extern std::map<std::string, AudioStream_t*> streams;
|
||||
|
||||
float registerMonoStream(dsp::stream<float>* stream, std::string name, std::string vfoName, int (*sampleRateChangeHandler)(void* ctx, float sampleRate), void* ctx);
|
||||
float registerStereoStream(dsp::stream<dsp::StereoFloat_t>* stream, std::string name, std::string vfoName, int (*sampleRateChangeHandler)(void* ctx, float sampleRate), void* ctx);
|
||||
double registerMonoStream(dsp::stream<float>* stream, std::string name, std::string vfoName, int (*sampleRateChangeHandler)(void* ctx, double sampleRate), void* ctx);
|
||||
double registerStereoStream(dsp::stream<dsp::StereoFloat_t>* stream, std::string name, std::string vfoName, int (*sampleRateChangeHandler)(void* ctx, double sampleRate), void* ctx);
|
||||
void startStream(std::string name);
|
||||
void stopStream(std::string name);
|
||||
void removeStream(std::string name);
|
||||
dsp::stream<float>* bindToStreamMono(std::string name, void (*streamRemovedHandler)(void* ctx), void (*sampleRateChangeHandler)(void* ctx, float sampleRate, int blockSize), void* ctx);
|
||||
dsp::stream<dsp::StereoFloat_t>* bindToStreamStereo(std::string name, void (*streamRemovedHandler)(void* ctx), void (*sampleRateChangeHandler)(void* ctx, float sampleRate, int blockSize), void* ctx);
|
||||
dsp::stream<float>* bindToStreamMono(std::string name, void (*streamRemovedHandler)(void* ctx), void (*sampleRateChangeHandler)(void* ctx, double sampleRate, int blockSize), void* ctx);
|
||||
dsp::stream<dsp::StereoFloat_t>* bindToStreamStereo(std::string name, void (*streamRemovedHandler)(void* ctx), void (*sampleRateChangeHandler)(void* ctx, double sampleRate, int blockSize), void* ctx);
|
||||
void setBlockSize(std::string name, int blockSize);
|
||||
void unbindFromStreamMono(std::string name, dsp::stream<float>* stream);
|
||||
void unbindFromStreamStereo(std::string name, dsp::stream<dsp::StereoFloat_t>* stream);
|
||||
std::string getNameFromVFO(std::string vfoName);
|
||||
void setSampleRate(std::string name, float sampleRate);
|
||||
void setAudioDevice(std::string name, int deviceId, float sampleRate);
|
||||
void setSampleRate(std::string name, double sampleRate);
|
||||
void setAudioDevice(std::string name, int deviceId, double sampleRate);
|
||||
std::vector<std::string> getStreamNameList();
|
||||
};
|
||||
|
||||
|
@ -20,7 +20,7 @@ void SignalPath::init(uint64_t sampleRate, int fftRate, int fftSize, dsp::stream
|
||||
dynSplit.init(&split.output_b, 32000);
|
||||
}
|
||||
|
||||
void SignalPath::setSampleRate(float sampleRate) {
|
||||
void SignalPath::setSampleRate(double sampleRate) {
|
||||
this->sampleRate = sampleRate;
|
||||
inputBlockSize = sampleRate / 200.0f;
|
||||
|
||||
@ -68,7 +68,7 @@ void SignalPath::setDCBiasCorrection(bool enabled) {
|
||||
dcBiasRemover.bypass = !enabled;
|
||||
}
|
||||
|
||||
dsp::VFO* SignalPath::addVFO(std::string name, float outSampleRate, float bandwidth, float offset) {
|
||||
dsp::VFO* SignalPath::addVFO(std::string name, double outSampleRate, double bandwidth, double offset) {
|
||||
if (vfos.find(name) != vfos.end()) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -16,10 +16,10 @@ public:
|
||||
SignalPath();
|
||||
void init(uint64_t sampleRate, int fftRate, int fftSize, dsp::stream<dsp::complex_t>* input, dsp::complex_t* fftBuffer, void fftHandler(dsp::complex_t*));
|
||||
void start();
|
||||
void setSampleRate(float sampleRate);
|
||||
void setSampleRate(double sampleRate);
|
||||
void setDCBiasCorrection(bool enabled);
|
||||
void setFFTRate(float rate);
|
||||
dsp::VFO* addVFO(std::string name, float outSampleRate, float bandwidth, float offset);
|
||||
void setFFTRate(double rate);
|
||||
dsp::VFO* addVFO(std::string name, double outSampleRate, double bandwidth, double offset);
|
||||
void removeVFO(std::string name);
|
||||
void setInput(dsp::stream<dsp::complex_t>* input);
|
||||
|
||||
@ -40,8 +40,8 @@ private:
|
||||
dsp::DynamicSplitter<dsp::complex_t> dynSplit;
|
||||
std::map<std::string, VFO_t> vfos;
|
||||
|
||||
float sampleRate;
|
||||
float fftRate;
|
||||
double sampleRate;
|
||||
double fftRate;
|
||||
int fftSize;
|
||||
int inputBlockSize;
|
||||
};
|
@ -1,7 +1,7 @@
|
||||
#include <signal_path/vfo_manager.h>
|
||||
#include <signal_path/signal_path.h>
|
||||
|
||||
VFOManager::VFO::VFO(std::string name, int reference, float offset, float bandwidth, float sampleRate, int blockSize) {
|
||||
VFOManager::VFO::VFO(std::string name, int reference, double offset, double bandwidth, double sampleRate, int blockSize) {
|
||||
this->name = name;
|
||||
dspVFO = sigpath::signalPath.addVFO(name, sampleRate, bandwidth, offset);
|
||||
wtfVFO = new ImGui::WaterfallVFO;
|
||||
@ -18,22 +18,22 @@ VFOManager::VFO::~VFO() {
|
||||
delete wtfVFO;
|
||||
}
|
||||
|
||||
void VFOManager::VFO::setOffset(float offset) {
|
||||
void VFOManager::VFO::setOffset(double offset) {
|
||||
wtfVFO->setOffset(offset);
|
||||
dspVFO->setOffset(wtfVFO->centerOffset);
|
||||
}
|
||||
|
||||
void VFOManager::VFO::setCenterOffset(float offset) {
|
||||
void VFOManager::VFO::setCenterOffset(double offset) {
|
||||
wtfVFO->setCenterOffset(offset);
|
||||
dspVFO->setOffset(offset);
|
||||
}
|
||||
|
||||
void VFOManager::VFO::setBandwidth(float bandwidth) {
|
||||
void VFOManager::VFO::setBandwidth(double bandwidth) {
|
||||
wtfVFO->setBandwidth(bandwidth);
|
||||
dspVFO->setBandwidth(bandwidth);
|
||||
}
|
||||
|
||||
void VFOManager::VFO::setSampleRate(float sampleRate, float bandwidth) {
|
||||
void VFOManager::VFO::setSampleRate(double sampleRate, double bandwidth) {
|
||||
dspVFO->setOutputSampleRate(sampleRate, bandwidth);
|
||||
wtfVFO->setBandwidth(bandwidth);
|
||||
}
|
||||
@ -51,7 +51,7 @@ VFOManager::VFOManager() {
|
||||
|
||||
}
|
||||
|
||||
VFOManager::VFO* VFOManager::createVFO(std::string name, int reference, float offset, float bandwidth, float sampleRate, int blockSize) {
|
||||
VFOManager::VFO* VFOManager::createVFO(std::string name, int reference, double offset, double bandwidth, double sampleRate, int blockSize) {
|
||||
if (vfos.find(name) != vfos.end() || name == "") {
|
||||
return NULL;
|
||||
}
|
||||
@ -74,28 +74,28 @@ void VFOManager::deleteVFO(VFOManager::VFO* vfo) {
|
||||
vfos.erase(name);
|
||||
}
|
||||
|
||||
void VFOManager::setOffset(std::string name, float offset) {
|
||||
void VFOManager::setOffset(std::string name, double offset) {
|
||||
if (vfos.find(name) == vfos.end()) {
|
||||
return;
|
||||
}
|
||||
vfos[name]->setOffset(offset);
|
||||
}
|
||||
|
||||
void VFOManager::setCenterOffset(std::string name, float offset) {
|
||||
void VFOManager::setCenterOffset(std::string name, double offset) {
|
||||
if (vfos.find(name) == vfos.end()) {
|
||||
return;
|
||||
}
|
||||
vfos[name]->setCenterOffset(offset);
|
||||
}
|
||||
|
||||
void VFOManager::setBandwidth(std::string name, float bandwidth) {
|
||||
void VFOManager::setBandwidth(std::string name, double bandwidth) {
|
||||
if (vfos.find(name) == vfos.end()) {
|
||||
return;
|
||||
}
|
||||
vfos[name]->setBandwidth(bandwidth);
|
||||
}
|
||||
|
||||
void VFOManager::setSampleRate(std::string name, float sampleRate, float bandwidth) {
|
||||
void VFOManager::setSampleRate(std::string name, double sampleRate, double bandwidth) {
|
||||
if (vfos.find(name) == vfos.end()) {
|
||||
return;
|
||||
}
|
||||
|
@ -9,13 +9,13 @@ public:
|
||||
|
||||
class VFO {
|
||||
public:
|
||||
VFO(std::string name, int reference, float offset, float bandwidth, float sampleRate, int blockSize);
|
||||
VFO(std::string name, int reference, double offset, double bandwidth, double sampleRate, int blockSize);
|
||||
~VFO();
|
||||
|
||||
void setOffset(float offset);
|
||||
void setCenterOffset(float offset);
|
||||
void setBandwidth(float bandwidth);
|
||||
void setSampleRate(float sampleRate, float bandwidth);
|
||||
void setOffset(double offset);
|
||||
void setCenterOffset(double offset);
|
||||
void setBandwidth(double bandwidth);
|
||||
void setSampleRate(double sampleRate, double bandwidth);
|
||||
void setReference(int ref);
|
||||
int getOutputBlockSize();
|
||||
|
||||
@ -30,13 +30,13 @@ public:
|
||||
|
||||
};
|
||||
|
||||
VFOManager::VFO* createVFO(std::string name, int reference, float offset, float bandwidth, float sampleRate, int blockSize);
|
||||
VFOManager::VFO* createVFO(std::string name, int reference, double offset, double bandwidth, double sampleRate, int blockSize);
|
||||
void deleteVFO(VFOManager::VFO* vfo);
|
||||
|
||||
void setOffset(std::string name, float offset);
|
||||
void setCenterOffset(std::string name, float offset);
|
||||
void setBandwidth(std::string name, float bandwidth);
|
||||
void setSampleRate(std::string name, float sampleRate, float bandwidth);
|
||||
void setOffset(std::string name, double offset);
|
||||
void setCenterOffset(std::string name, double offset);
|
||||
void setBandwidth(std::string name, double bandwidth);
|
||||
void setSampleRate(std::string name, double sampleRate, double bandwidth);
|
||||
void setReference(std::string name, int ref);
|
||||
int getOutputBlockSize(std::string name);
|
||||
|
||||
|
Reference in New Issue
Block a user