mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-01-12 03:07:11 +01:00
Fixed waterfall inaccuracies + started adding stepped VFO
This commit is contained in:
parent
3b6a3ff94d
commit
027054b57e
@ -9,8 +9,8 @@ namespace bandplan {
|
|||||||
struct Band_t {
|
struct Band_t {
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string type;
|
std::string type;
|
||||||
float start;
|
double start;
|
||||||
float end;
|
double end;
|
||||||
};
|
};
|
||||||
|
|
||||||
void to_json(json& j, const Band_t& b);
|
void to_json(json& j, const Band_t& b);
|
||||||
|
@ -52,14 +52,14 @@ void fftHandler(dsp::complex_t* samples) {
|
|||||||
int half = fftSize / 2;
|
int half = fftSize / 2;
|
||||||
|
|
||||||
for (int i = 0; i < half; i++) {
|
for (int i = 0; i < half; i++) {
|
||||||
_data.push_back(log10(std::abs(std::complex<float>(fft_out[half + i][0], fft_out[half + i][1])) / (float)fftSize) * 10.0f);
|
_data.push_back(log10(std::abs(std::complex<float>(fft_out[half + i][0], fft_out[half + i][1])) / (float)fftSize) * 10.0);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < half; i++) {
|
for (int i = 0; i < half; i++) {
|
||||||
_data.push_back(log10(std::abs(std::complex<float>(fft_out[i][0], fft_out[i][1])) / (float)fftSize) * 10.0f);
|
_data.push_back(log10(std::abs(std::complex<float>(fft_out[i][0], fft_out[i][1])) / (float)fftSize) * 10.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 5; i < fftSize; i++) {
|
for (int i = 5; i < fftSize; i++) {
|
||||||
_data[i] = (_data[i - 4] + _data[i - 3] + _data[i - 2] + _data[i - 1] + _data[i]) / 5.0f;
|
_data[i] = (_data[i - 4] + _data[i - 3] + _data[i - 2] + _data[i - 1] + _data[i]) / 5.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
gui::waterfall.pushFFT(_data, fftSize);
|
gui::waterfall.pushFFT(_data, fftSize);
|
||||||
@ -68,13 +68,13 @@ void fftHandler(dsp::complex_t* samples) {
|
|||||||
|
|
||||||
dsp::NullSink sink;
|
dsp::NullSink sink;
|
||||||
watcher<uint64_t> freq((uint64_t)90500000);
|
watcher<uint64_t> freq((uint64_t)90500000);
|
||||||
watcher<float> vfoFreq(92000000.0f);
|
watcher<double> vfoFreq(92000000.0);
|
||||||
float dummyVolume = 1.0f;
|
float dummyVolume = 1.0;
|
||||||
float* volume = &dummyVolume;
|
float* volume = &dummyVolume;
|
||||||
float fftMin = -70.0f;
|
float fftMin = -70.0;
|
||||||
float fftMax = 0.0f;
|
float fftMax = 0.0;
|
||||||
watcher<float> offset(0.0f, true);
|
watcher<double> offset(0.0, true);
|
||||||
watcher<float> bw(8000000.0f, true);
|
watcher<float> bw(8000000.0, true);
|
||||||
bool playing = false;
|
bool playing = false;
|
||||||
watcher<bool> dcbias(false, false);
|
watcher<bool> dcbias(false, false);
|
||||||
bool showCredits = false;
|
bool showCredits = false;
|
||||||
@ -140,7 +140,7 @@ void windowInit() {
|
|||||||
gui::waterfall.setFFTMax(fftMax);
|
gui::waterfall.setFFTMax(fftMax);
|
||||||
gui::waterfall.setWaterfallMax(fftMax);
|
gui::waterfall.setWaterfallMax(fftMax);
|
||||||
|
|
||||||
float frequency = core::configManager.conf["frequency"];
|
double frequency = core::configManager.conf["frequency"];
|
||||||
|
|
||||||
gui::freqSelect.setFrequency(frequency);
|
gui::freqSelect.setFrequency(frequency);
|
||||||
gui::freqSelect.frequencyChanged = false;
|
gui::freqSelect.frequencyChanged = false;
|
||||||
@ -164,27 +164,27 @@ void windowInit() {
|
|||||||
core::configManager.release();
|
core::configManager.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setVFO(float freq) {
|
void setVFO(double freq) {
|
||||||
ImGui::WaterfallVFO* vfo = gui::waterfall.vfos[gui::waterfall.selectedVFO];
|
ImGui::WaterfallVFO* vfo = gui::waterfall.vfos[gui::waterfall.selectedVFO];
|
||||||
|
|
||||||
float currentOff = vfo->centerOffset;
|
double currentOff = vfo->centerOffset;
|
||||||
float currentTune = gui::waterfall.getCenterFrequency() + vfo->generalOffset;
|
double currentTune = gui::waterfall.getCenterFrequency() + vfo->generalOffset;
|
||||||
float delta = freq - currentTune;
|
double delta = freq - currentTune;
|
||||||
|
|
||||||
float newVFO = currentOff + delta;
|
double newVFO = currentOff + delta;
|
||||||
float vfoBW = vfo->bandwidth;
|
double vfoBW = vfo->bandwidth;
|
||||||
float vfoBottom = newVFO - (vfoBW / 2.0f);
|
double vfoBottom = newVFO - (vfoBW / 2.0);
|
||||||
float vfoTop = newVFO + (vfoBW / 2.0f);
|
double vfoTop = newVFO + (vfoBW / 2.0);
|
||||||
|
|
||||||
float view = gui::waterfall.getViewOffset();
|
double view = gui::waterfall.getViewOffset();
|
||||||
float viewBW = gui::waterfall.getViewBandwidth();
|
double viewBW = gui::waterfall.getViewBandwidth();
|
||||||
float viewBottom = view - (viewBW / 2.0f);
|
double viewBottom = view - (viewBW / 2.0);
|
||||||
float viewTop = view + (viewBW / 2.0f);
|
double viewTop = view + (viewBW / 2.0);
|
||||||
|
|
||||||
float wholeFreq = gui::waterfall.getCenterFrequency();
|
double wholeFreq = gui::waterfall.getCenterFrequency();
|
||||||
float BW = gui::waterfall.getBandwidth();
|
double BW = gui::waterfall.getBandwidth();
|
||||||
float bottom = -(BW / 2.0f);
|
double bottom = -(BW / 2.0);
|
||||||
float top = (BW / 2.0f);
|
double top = (BW / 2.0);
|
||||||
|
|
||||||
// VFO still fints in the view
|
// VFO still fints in the view
|
||||||
if (vfoBottom > viewBottom && vfoTop < viewTop) {
|
if (vfoBottom > viewBottom && vfoTop < viewTop) {
|
||||||
@ -194,8 +194,8 @@ void setVFO(float freq) {
|
|||||||
|
|
||||||
// VFO too low for current SDR tuning
|
// VFO too low for current SDR tuning
|
||||||
if (vfoBottom < bottom) {
|
if (vfoBottom < bottom) {
|
||||||
gui::waterfall.setViewOffset((BW / 2.0f) - (viewBW / 2.0f));
|
gui::waterfall.setViewOffset((BW / 2.0) - (viewBW / 2.0));
|
||||||
float newVFOOffset = (BW / 2.0f) - (vfoBW / 2.0f) - (viewBW / 10.0f);
|
double newVFOOffset = (BW / 2.0) - (vfoBW / 2.0) - (viewBW / 10.0);
|
||||||
sigpath::vfoManager.setCenterOffset(gui::waterfall.selectedVFO, newVFOOffset);
|
sigpath::vfoManager.setCenterOffset(gui::waterfall.selectedVFO, newVFOOffset);
|
||||||
gui::waterfall.setCenterFrequency(freq - newVFOOffset);
|
gui::waterfall.setCenterFrequency(freq - newVFOOffset);
|
||||||
sigpath::sourceManager.tune(freq - newVFOOffset);
|
sigpath::sourceManager.tune(freq - newVFOOffset);
|
||||||
@ -204,8 +204,8 @@ void setVFO(float freq) {
|
|||||||
|
|
||||||
// VFO too high for current SDR tuning
|
// VFO too high for current SDR tuning
|
||||||
if (vfoTop > top) {
|
if (vfoTop > top) {
|
||||||
gui::waterfall.setViewOffset((viewBW / 2.0f) - (BW / 2.0f));
|
gui::waterfall.setViewOffset((viewBW / 2.0) - (BW / 2.0));
|
||||||
float newVFOOffset = (vfoBW / 2.0f) - (BW / 2.0f) + (viewBW / 10.0f);
|
double newVFOOffset = (vfoBW / 2.0) - (BW / 2.0) + (viewBW / 10.0);
|
||||||
sigpath::vfoManager.setCenterOffset(gui::waterfall.selectedVFO, newVFOOffset);
|
sigpath::vfoManager.setCenterOffset(gui::waterfall.selectedVFO, newVFOOffset);
|
||||||
gui::waterfall.setCenterFrequency(freq - newVFOOffset);
|
gui::waterfall.setCenterFrequency(freq - newVFOOffset);
|
||||||
sigpath::sourceManager.tune(freq - newVFOOffset);
|
sigpath::sourceManager.tune(freq - newVFOOffset);
|
||||||
@ -214,9 +214,9 @@ void setVFO(float freq) {
|
|||||||
|
|
||||||
// VFO is still without the SDR's bandwidth
|
// VFO is still without the SDR's bandwidth
|
||||||
if (delta < 0) {
|
if (delta < 0) {
|
||||||
float newViewOff = vfoTop - (viewBW / 2.0f) + (viewBW / 10.0f);
|
double newViewOff = vfoTop - (viewBW / 2.0) + (viewBW / 10.0);
|
||||||
float newViewBottom = newViewOff - (viewBW / 2.0f);
|
double newViewBottom = newViewOff - (viewBW / 2.0);
|
||||||
float newViewTop = newViewOff + (viewBW / 2.0f);
|
double newViewTop = newViewOff + (viewBW / 2.0);
|
||||||
|
|
||||||
if (newViewBottom > bottom) {
|
if (newViewBottom > bottom) {
|
||||||
gui::waterfall.setViewOffset(newViewOff);
|
gui::waterfall.setViewOffset(newViewOff);
|
||||||
@ -224,16 +224,16 @@ void setVFO(float freq) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gui::waterfall.setViewOffset((BW / 2.0f) - (viewBW / 2.0f));
|
gui::waterfall.setViewOffset((BW / 2.0) - (viewBW / 2.0));
|
||||||
float newVFOOffset = (BW / 2.0f) - (vfoBW / 2.0f) - (viewBW / 10.0f);
|
double newVFOOffset = (BW / 2.0) - (vfoBW / 2.0) - (viewBW / 10.0);
|
||||||
sigpath::vfoManager.setCenterOffset(gui::waterfall.selectedVFO, newVFOOffset);
|
sigpath::vfoManager.setCenterOffset(gui::waterfall.selectedVFO, newVFOOffset);
|
||||||
gui::waterfall.setCenterFrequency(freq - newVFOOffset);
|
gui::waterfall.setCenterFrequency(freq - newVFOOffset);
|
||||||
sigpath::sourceManager.tune(freq - newVFOOffset);
|
sigpath::sourceManager.tune(freq - newVFOOffset);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
float newViewOff = vfoBottom + (viewBW / 2.0f) - (viewBW / 10.0f);
|
double newViewOff = vfoBottom + (viewBW / 2.0) - (viewBW / 10.0);
|
||||||
float newViewBottom = newViewOff - (viewBW / 2.0f);
|
double newViewBottom = newViewOff - (viewBW / 2.0);
|
||||||
float newViewTop = newViewOff + (viewBW / 2.0f);
|
double newViewTop = newViewOff + (viewBW / 2.0);
|
||||||
|
|
||||||
if (newViewTop < top) {
|
if (newViewTop < top) {
|
||||||
gui::waterfall.setViewOffset(newViewOff);
|
gui::waterfall.setViewOffset(newViewOff);
|
||||||
@ -241,8 +241,8 @@ void setVFO(float freq) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gui::waterfall.setViewOffset((viewBW / 2.0f) - (BW / 2.0f));
|
gui::waterfall.setViewOffset((viewBW / 2.0) - (BW / 2.0));
|
||||||
float newVFOOffset = (vfoBW / 2.0f) - (BW / 2.0f) + (viewBW / 10.0f);
|
double newVFOOffset = (vfoBW / 2.0) - (BW / 2.0) + (viewBW / 10.0);
|
||||||
sigpath::vfoManager.setCenterOffset(gui::waterfall.selectedVFO, newVFOOffset);
|
sigpath::vfoManager.setCenterOffset(gui::waterfall.selectedVFO, newVFOOffset);
|
||||||
gui::waterfall.setCenterFrequency(freq - newVFOOffset);
|
gui::waterfall.setCenterFrequency(freq - newVFOOffset);
|
||||||
sigpath::sourceManager.tune(freq - newVFOOffset);
|
sigpath::sourceManager.tune(freq - newVFOOffset);
|
||||||
@ -341,7 +341,7 @@ void drawWindow() {
|
|||||||
|
|
||||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 8);
|
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 8);
|
||||||
ImGui::SetNextItemWidth(200);
|
ImGui::SetNextItemWidth(200);
|
||||||
if (ImGui::SliderFloat("##_2_", volume, 0.0f, 1.0f, "")) {
|
if (ImGui::SliderFloat("##_2_", volume, 0.0, 1.0, "")) {
|
||||||
if (audioStreamName != "") {
|
if (audioStreamName != "") {
|
||||||
core::configManager.aquire();
|
core::configManager.aquire();
|
||||||
if (!core::configManager.conf["audio"].contains(audioStreamName)) {
|
if (!core::configManager.conf["audio"].contains(audioStreamName)) {
|
||||||
@ -414,9 +414,9 @@ void drawWindow() {
|
|||||||
gui::menu.draw();
|
gui::menu.draw();
|
||||||
|
|
||||||
if(ImGui::CollapsingHeader("Debug")) {
|
if(ImGui::CollapsingHeader("Debug")) {
|
||||||
ImGui::Text("Frame time: %.3f ms/frame", 1000.0f / ImGui::GetIO().Framerate);
|
ImGui::Text("Frame time: %.3f ms/frame", 1000.0 / ImGui::GetIO().Framerate);
|
||||||
ImGui::Text("Framerate: %.1f FPS", ImGui::GetIO().Framerate);
|
ImGui::Text("Framerate: %.1f FPS", ImGui::GetIO().Framerate);
|
||||||
ImGui::Text("Center Frequency: %.0f Hz", gui::waterfall.getCenterFrequency());
|
ImGui::Text("Center Frequency: %.0 Hz", gui::waterfall.getCenterFrequency());
|
||||||
ImGui::Text("Source name: %s", sourceName.c_str());
|
ImGui::Text("Source name: %s", sourceName.c_str());
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
}
|
}
|
||||||
@ -446,17 +446,17 @@ void drawWindow() {
|
|||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
ImGui::BeginChild("WaterfallControls");
|
ImGui::BeginChild("WaterfallControls");
|
||||||
|
|
||||||
ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2.0f) - (ImGui::CalcTextSize("Zoom").x / 2.0f));
|
ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2.0) - (ImGui::CalcTextSize("Zoom").x / 2.0));
|
||||||
ImGui::Text("Zoom");
|
ImGui::Text("Zoom");
|
||||||
ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2.0f) - 10);
|
ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2.0) - 10);
|
||||||
ImGui::VSliderFloat("##_7_", ImVec2(20.0f, 150.0f), &bw.val, gui::waterfall.getBandwidth(), 1000.0f, "");
|
ImGui::VSliderFloat("##_7_", ImVec2(20.0, 150.0), &bw.val, gui::waterfall.getBandwidth(), 1000.0, "");
|
||||||
|
|
||||||
ImGui::NewLine();
|
ImGui::NewLine();
|
||||||
|
|
||||||
ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2.0f) - (ImGui::CalcTextSize("Max").x / 2.0f));
|
ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2.0) - (ImGui::CalcTextSize("Max").x / 2.0));
|
||||||
ImGui::Text("Max");
|
ImGui::Text("Max");
|
||||||
ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2.0f) - 10);
|
ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2.0) - 10);
|
||||||
if (ImGui::VSliderFloat("##_8_", ImVec2(20.0f, 150.0f), &fftMax, 0.0f, -100.0f, "")) {
|
if (ImGui::VSliderFloat("##_8_", ImVec2(20.0, 150.0), &fftMax, 0.0, -100.0, "")) {
|
||||||
fftMax = std::max<float>(fftMax, fftMin + 10);
|
fftMax = std::max<float>(fftMax, fftMin + 10);
|
||||||
core::configManager.aquire();
|
core::configManager.aquire();
|
||||||
core::configManager.conf["max"] = fftMax;
|
core::configManager.conf["max"] = fftMax;
|
||||||
@ -465,10 +465,10 @@ void drawWindow() {
|
|||||||
|
|
||||||
ImGui::NewLine();
|
ImGui::NewLine();
|
||||||
|
|
||||||
ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2.0f) - (ImGui::CalcTextSize("Min").x / 2.0f));
|
ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2.0) - (ImGui::CalcTextSize("Min").x / 2.0));
|
||||||
ImGui::Text("Min");
|
ImGui::Text("Min");
|
||||||
ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2.0f) - 10);
|
ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2.0) - 10);
|
||||||
if (ImGui::VSliderFloat("##_9_", ImVec2(20.0f, 150.0f), &fftMin, 0.0f, -100.0f, "")) {
|
if (ImGui::VSliderFloat("##_9_", ImVec2(20.0, 150.0), &fftMin, 0.0, -100.0, "")) {
|
||||||
fftMin = std::min<float>(fftMax - 10, fftMin);
|
fftMin = std::min<float>(fftMax - 10, fftMin);
|
||||||
core::configManager.aquire();
|
core::configManager.aquire();
|
||||||
core::configManager.conf["min"] = fftMin;
|
core::configManager.conf["min"] = fftMin;
|
||||||
|
@ -36,38 +36,40 @@ void doZoom(int offset, int width, int outWidth, std::vector<float> data, float*
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float freq_ranges[] = {
|
// TODO: Fix this hacky BS
|
||||||
1.0f, 2.0f, 2.5f, 5.0f,
|
|
||||||
10.0f, 20.0f, 25.0f, 50.0f,
|
double freq_ranges[] = {
|
||||||
100.0f, 200.0f, 250.0f, 500.0f,
|
1.0, 2.0, 2.5, 5.0,
|
||||||
1000.0f, 2000.0f, 2500.0f, 5000.0f,
|
10.0, 20.0, 25.0, 50.0,
|
||||||
10000.0f, 20000.0f, 25000.0f, 50000.0f,
|
100.0, 200.0, 250.0, 500.0,
|
||||||
100000.0f, 200000.0f, 250000.0f, 500000.0f,
|
1000.0, 2000.0, 2500.0, 5000.0,
|
||||||
1000000.0f, 2000000.0f, 2500000.0f, 5000000.0f,
|
10000.0, 20000.0, 25000.0, 50000.0,
|
||||||
10000000.0f, 20000000.0f, 25000000.0f, 50000000.0f
|
100000.0, 200000.0, 250000.0, 500000.0,
|
||||||
|
1000000.0, 2000000.0, 2500000.0, 5000000.0,
|
||||||
|
10000000.0, 20000000.0, 25000000.0, 50000000.0
|
||||||
};
|
};
|
||||||
|
|
||||||
float findBestRange(float bandwidth, int maxSteps) {
|
double findBestRange(double bandwidth, int maxSteps) {
|
||||||
for (int i = 0; i < 32; i++) {
|
for (int i = 0; i < 32; i++) {
|
||||||
if (bandwidth / freq_ranges[i] < (float)maxSteps) {
|
if (bandwidth / freq_ranges[i] < (double)maxSteps) {
|
||||||
return freq_ranges[i];
|
return freq_ranges[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 50000000.0f;
|
return 50000000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void printAndScale(float freq, char* buf) {
|
void printAndScale(double freq, char* buf) {
|
||||||
if (freq < 1000) {
|
if (freq < 1000) {
|
||||||
sprintf(buf, "%.3f", freq);
|
sprintf(buf, "%.3lf", freq);
|
||||||
}
|
}
|
||||||
else if (freq < 1000000) {
|
else if (freq < 1000000) {
|
||||||
sprintf(buf, "%.3fK", freq / 1000.0f);
|
sprintf(buf, "%.3lfK", freq / 1000.0);
|
||||||
}
|
}
|
||||||
else if (freq < 1000000000) {
|
else if (freq < 1000000000) {
|
||||||
sprintf(buf, "%.3fM", freq / 1000000.0f);
|
sprintf(buf, "%.3lfM", freq / 1000000.0);
|
||||||
}
|
}
|
||||||
else if (freq < 1000000000000) {
|
else if (freq < 1000000000000) {
|
||||||
sprintf(buf, "%.3fG", freq / 1000000000.0f);
|
sprintf(buf, "%.3lfG", freq / 1000000000.0);
|
||||||
}
|
}
|
||||||
for (int i = strlen(buf) - 2; i >= 0; i--) {
|
for (int i = strlen(buf) - 2; i >= 0; i--) {
|
||||||
if (buf[i] != '0') {
|
if (buf[i] != '0') {
|
||||||
@ -84,10 +86,10 @@ void printAndScale(float freq, char* buf) {
|
|||||||
|
|
||||||
namespace ImGui {
|
namespace ImGui {
|
||||||
WaterFall::WaterFall() {
|
WaterFall::WaterFall() {
|
||||||
fftMin = -70.0f;
|
fftMin = -70.0;
|
||||||
fftMax = 0.0f;
|
fftMax = 0.0;
|
||||||
waterfallMin = -70.0f;
|
waterfallMin = -70.0;
|
||||||
waterfallMax = 0.0f;
|
waterfallMax = 0.0;
|
||||||
FFTAreaHeight = 300;
|
FFTAreaHeight = 300;
|
||||||
newFFTAreaHeight = FFTAreaHeight;
|
newFFTAreaHeight = FFTAreaHeight;
|
||||||
fftHeight = FFTAreaHeight - 50;
|
fftHeight = FFTAreaHeight - 50;
|
||||||
@ -99,8 +101,8 @@ namespace ImGui {
|
|||||||
latestFFT = new float[1];
|
latestFFT = new float[1];
|
||||||
waterfallFb = new uint32_t[1];
|
waterfallFb = new uint32_t[1];
|
||||||
|
|
||||||
viewBandwidth = 1.0f;
|
viewBandwidth = 1.0;
|
||||||
wholeBandwidth = 1.0f;
|
wholeBandwidth = 1.0;
|
||||||
|
|
||||||
glGenTextures(1, &textureId);
|
glGenTextures(1, &textureId);
|
||||||
|
|
||||||
@ -122,51 +124,51 @@ namespace ImGui {
|
|||||||
float yPos = widgetPos.y + fftHeight + 10 - ((line - fftMin) * scaleFactor);
|
float yPos = widgetPos.y + fftHeight + 10 - ((line - fftMin) * scaleFactor);
|
||||||
window->DrawList->AddLine(ImVec2(roundf(widgetPos.x + 50), roundf(yPos)),
|
window->DrawList->AddLine(ImVec2(roundf(widgetPos.x + 50), roundf(yPos)),
|
||||||
ImVec2(roundf(widgetPos.x + dataWidth + 50), roundf(yPos)),
|
ImVec2(roundf(widgetPos.x + dataWidth + 50), roundf(yPos)),
|
||||||
IM_COL32(50, 50, 50, 255), 1.0f);
|
IM_COL32(50, 50, 50, 255), 1.0);
|
||||||
sprintf(buf, "%d", (int)line);
|
sprintf(buf, "%d", (int)line);
|
||||||
ImVec2 txtSz = ImGui::CalcTextSize(buf);
|
ImVec2 txtSz = ImGui::CalcTextSize(buf);
|
||||||
window->DrawList->AddText(ImVec2(widgetPos.x + 40 - txtSz.x, roundf(yPos - (txtSz.y / 2))), IM_COL32( 255, 255, 255, 255 ), buf);
|
window->DrawList->AddText(ImVec2(widgetPos.x + 40 - txtSz.x, roundf(yPos - (txtSz.y / 2.0))), IM_COL32( 255, 255, 255, 255 ), buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Horizontal scale
|
// Horizontal scale
|
||||||
float startFreq = ceilf(lowerFreq / range) * range;
|
double startFreq = ceilf(lowerFreq / range) * range;
|
||||||
float horizScale = (float)dataWidth / viewBandwidth;
|
double horizScale = (double)dataWidth / viewBandwidth;
|
||||||
for (float freq = startFreq; freq < upperFreq; freq += range) {
|
for (double freq = startFreq; freq < upperFreq; freq += range) {
|
||||||
float xPos = widgetPos.x + 50 + ((freq - lowerFreq) * horizScale);
|
double xPos = widgetPos.x + 50 + ((freq - lowerFreq) * horizScale);
|
||||||
window->DrawList->AddLine(ImVec2(roundf(xPos), widgetPos.y + 10),
|
window->DrawList->AddLine(ImVec2(roundf(xPos), widgetPos.y + 10),
|
||||||
ImVec2(roundf(xPos), widgetPos.y + fftHeight + 10),
|
ImVec2(roundf(xPos), widgetPos.y + fftHeight + 10),
|
||||||
IM_COL32(50, 50, 50, 255), 1.0f);
|
IM_COL32(50, 50, 50, 255), 1.0);
|
||||||
window->DrawList->AddLine(ImVec2(roundf(xPos), widgetPos.y + fftHeight + 10),
|
window->DrawList->AddLine(ImVec2(roundf(xPos), widgetPos.y + fftHeight + 10),
|
||||||
ImVec2(roundf(xPos), widgetPos.y + fftHeight + 17),
|
ImVec2(roundf(xPos), widgetPos.y + fftHeight + 17),
|
||||||
IM_COL32(255, 255, 255, 255), 1.0f);
|
IM_COL32(255, 255, 255, 255), 1.0);
|
||||||
printAndScale(freq, buf);
|
printAndScale(freq, buf);
|
||||||
ImVec2 txtSz = ImGui::CalcTextSize(buf);
|
ImVec2 txtSz = ImGui::CalcTextSize(buf);
|
||||||
window->DrawList->AddText(ImVec2(roundf(xPos - (txtSz.x / 2.0f)), widgetPos.y + fftHeight + 10 + txtSz.y), IM_COL32( 255, 255, 255, 255 ), buf);
|
window->DrawList->AddText(ImVec2(roundf(xPos - (txtSz.x / 2.0)), widgetPos.y + fftHeight + 10 + txtSz.y), IM_COL32( 255, 255, 255, 255 ), buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Data
|
// Data
|
||||||
for (int i = 1; i < dataWidth; i++) {
|
for (int i = 1; i < dataWidth; i++) {
|
||||||
float aPos = widgetPos.y + fftHeight + 10 - ((latestFFT[i - 1] - fftMin) * scaleFactor);
|
double aPos = widgetPos.y + fftHeight + 10 - ((latestFFT[i - 1] - fftMin) * scaleFactor);
|
||||||
float bPos = widgetPos.y + fftHeight + 10 - ((latestFFT[i] - fftMin) * scaleFactor);
|
double bPos = widgetPos.y + fftHeight + 10 - ((latestFFT[i] - fftMin) * scaleFactor);
|
||||||
if (aPos < fftMin && bPos < fftMin) {
|
if (aPos < fftMin && bPos < fftMin) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
aPos = std::clamp<float>(aPos, widgetPos.y + 10, widgetPos.y + fftHeight + 10);
|
aPos = std::clamp<double>(aPos, widgetPos.y + 10, widgetPos.y + fftHeight + 10);
|
||||||
bPos = std::clamp<float>(bPos, widgetPos.y + 10, widgetPos.y + fftHeight + 10);
|
bPos = std::clamp<double>(bPos, widgetPos.y + 10, widgetPos.y + fftHeight + 10);
|
||||||
window->DrawList->AddLine(ImVec2(widgetPos.x + 49 + i, roundf(aPos)),
|
window->DrawList->AddLine(ImVec2(widgetPos.x + 49 + i, roundf(aPos)),
|
||||||
ImVec2(widgetPos.x + 50 + i, roundf(bPos)), trace, 1.0f);
|
ImVec2(widgetPos.x + 50 + i, roundf(bPos)), trace, 1.0);
|
||||||
window->DrawList->AddLine(ImVec2(widgetPos.x + 50 + i, roundf(bPos)),
|
window->DrawList->AddLine(ImVec2(widgetPos.x + 50 + i, roundf(bPos)),
|
||||||
ImVec2(widgetPos.x + 50 + i, widgetPos.y + fftHeight + 10), shadow, 1.0f);
|
ImVec2(widgetPos.x + 50 + i, widgetPos.y + fftHeight + 10), shadow, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// X Axis
|
// X Axis
|
||||||
window->DrawList->AddLine(ImVec2(widgetPos.x + 50, widgetPos.y + fftHeight + 10),
|
window->DrawList->AddLine(ImVec2(widgetPos.x + 50, widgetPos.y + fftHeight + 10),
|
||||||
ImVec2(widgetPos.x + dataWidth + 50, widgetPos.y + fftHeight + 10),
|
ImVec2(widgetPos.x + dataWidth + 50, widgetPos.y + fftHeight + 10),
|
||||||
IM_COL32(255, 255, 255, 255), 1.0f);
|
IM_COL32(255, 255, 255, 255), 1.0);
|
||||||
// Y Axis
|
// Y Axis
|
||||||
window->DrawList->AddLine(ImVec2(widgetPos.x + 50, widgetPos.y + 9),
|
window->DrawList->AddLine(ImVec2(widgetPos.x + 50, widgetPos.y + 9),
|
||||||
ImVec2(widgetPos.x + 50, widgetPos.y + fftHeight + 9),
|
ImVec2(widgetPos.x + 50, widgetPos.y + fftHeight + 9),
|
||||||
IM_COL32(255, 255, 255, 255), 1.0f);
|
IM_COL32(255, 255, 255, 255), 1.0);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -227,7 +229,7 @@ namespace ImGui {
|
|||||||
}
|
}
|
||||||
int refCenter = mousePos.x - (widgetPos.x + 50);
|
int refCenter = mousePos.x - (widgetPos.x + 50);
|
||||||
if (refCenter >= 0 && refCenter < dataWidth && mousePos.y > widgetPos.y && mousePos.y < (widgetPos.y + widgetSize.y)) {
|
if (refCenter >= 0 && refCenter < dataWidth && mousePos.y > widgetPos.y && mousePos.y < (widgetPos.y + widgetSize.y)) {
|
||||||
vfo->setOffset(((((float)refCenter / ((float)dataWidth / 2.0f)) - 1.0f) * (viewBandwidth / 2.0f)) + viewOffset);
|
vfo->setOffset(((((double)refCenter / ((double)dataWidth / 2.0)) - 1.0) * (viewBandwidth / 2.0)) + viewOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,33 +237,34 @@ namespace ImGui {
|
|||||||
if (draging && mouseInFFT) {
|
if (draging && mouseInFFT) {
|
||||||
int refCenter = mousePos.x - (widgetPos.x + 50);
|
int refCenter = mousePos.x - (widgetPos.x + 50);
|
||||||
if (refCenter >= 0 && refCenter < dataWidth && mousePos.y > widgetPos.y && mousePos.y < (widgetPos.y + widgetSize.y)) {
|
if (refCenter >= 0 && refCenter < dataWidth && mousePos.y > widgetPos.y && mousePos.y < (widgetPos.y + widgetSize.y)) {
|
||||||
vfo->setOffset(((((float)refCenter / ((float)dataWidth / 2.0f)) - 1.0f) * (viewBandwidth / 2.0f)) + viewOffset);
|
double off = ((((double)refCenter / ((double)dataWidth / 2.0)) - 1.0) * (viewBandwidth / 2.0)) + viewOffset;
|
||||||
|
vfo->setOffset(round(off / vfo->snapInterval) * vfo->snapInterval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dragon frequency scale
|
// Draging frequency scale
|
||||||
if (draging && mouseInFreq) {
|
if (draging && mouseInFreq) {
|
||||||
float deltax = drag.x - lastDrag;
|
double deltax = drag.x - lastDrag;
|
||||||
lastDrag = drag.x;
|
lastDrag = drag.x;
|
||||||
float viewDelta = deltax * (viewBandwidth / (float)dataWidth);
|
double viewDelta = deltax * (viewBandwidth / (double)dataWidth);
|
||||||
|
|
||||||
viewOffset -= viewDelta;
|
viewOffset -= viewDelta;
|
||||||
|
|
||||||
if (viewOffset + (viewBandwidth / 2.0f) > wholeBandwidth / 2.0f) {
|
if (viewOffset + (viewBandwidth / 2.0) > wholeBandwidth / 2.0) {
|
||||||
float freqOffset = (viewOffset + (viewBandwidth / 2.0f)) - (wholeBandwidth / 2.0f);
|
double freqOffset = (viewOffset + (viewBandwidth / 2.0)) - (wholeBandwidth / 2.0);
|
||||||
viewOffset = (wholeBandwidth / 2.0f) - (viewBandwidth / 2.0f);
|
viewOffset = (wholeBandwidth / 2.0) - (viewBandwidth / 2.0);
|
||||||
centerFreq += freqOffset;
|
centerFreq += freqOffset;
|
||||||
centerFreqMoved = true;
|
centerFreqMoved = true;
|
||||||
}
|
}
|
||||||
if (viewOffset - (viewBandwidth / 2.0f) < -(wholeBandwidth / 2.0f)) {
|
if (viewOffset - (viewBandwidth / 2.0) < -(wholeBandwidth / 2.0)) {
|
||||||
float freqOffset = (viewOffset - (viewBandwidth / 2.0f)) + (wholeBandwidth / 2.0f);
|
double freqOffset = (viewOffset - (viewBandwidth / 2.0)) + (wholeBandwidth / 2.0);
|
||||||
viewOffset = (viewBandwidth / 2.0f) - (wholeBandwidth / 2.0f);
|
viewOffset = (viewBandwidth / 2.0) - (wholeBandwidth / 2.0);
|
||||||
centerFreq += freqOffset;
|
centerFreq += freqOffset;
|
||||||
centerFreqMoved = true;
|
centerFreqMoved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
lowerFreq = (centerFreq + viewOffset) - (viewBandwidth / 2.0f);
|
lowerFreq = (centerFreq + viewOffset) - (viewBandwidth / 2.0);
|
||||||
upperFreq = (centerFreq + viewOffset) + (viewBandwidth / 2.0f);
|
upperFreq = (centerFreq + viewOffset) + (viewBandwidth / 2.0);
|
||||||
updateWaterfallFb();
|
updateWaterfallFb();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -273,7 +276,7 @@ namespace ImGui {
|
|||||||
if (!waterfallVisible) {
|
if (!waterfallVisible) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
float offsetRatio = viewOffset / (wholeBandwidth / 2.0f);
|
double offsetRatio = viewOffset / (wholeBandwidth / 2.0);
|
||||||
int drawDataSize;
|
int drawDataSize;
|
||||||
int drawDataStart;
|
int drawDataStart;
|
||||||
int count = std::min<int>(waterfallHeight, rawFFTs.size());
|
int count = std::min<int>(waterfallHeight, rawFFTs.size());
|
||||||
@ -284,7 +287,7 @@ namespace ImGui {
|
|||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
size = rawFFTs[i].size();
|
size = rawFFTs[i].size();
|
||||||
drawDataSize = (viewBandwidth / wholeBandwidth) * size;
|
drawDataSize = (viewBandwidth / wholeBandwidth) * size;
|
||||||
drawDataStart = (((float)size / 2.0f) * (offsetRatio + 1)) - (drawDataSize / 2);
|
drawDataStart = (((double)size / 2.0) * (offsetRatio + 1)) - (drawDataSize / 2);
|
||||||
doZoom(drawDataStart, drawDataSize, dataWidth, rawFFTs[i], tempData);
|
doZoom(drawDataStart, drawDataSize, dataWidth, rawFFTs[i], tempData);
|
||||||
for (int j = 0; j < dataWidth; j++) {
|
for (int j = 0; j < dataWidth; j++) {
|
||||||
pixel = (std::clamp<float>(tempData[j], waterfallMin, waterfallMax) - waterfallMin) / dataRange;
|
pixel = (std::clamp<float>(tempData[j], waterfallMin, waterfallMax) - waterfallMin) / dataRange;
|
||||||
@ -297,8 +300,8 @@ namespace ImGui {
|
|||||||
|
|
||||||
void WaterFall::drawBandPlan() {
|
void WaterFall::drawBandPlan() {
|
||||||
int count = bandplan->bands.size();
|
int count = bandplan->bands.size();
|
||||||
float horizScale = (float)dataWidth / viewBandwidth;
|
double horizScale = (double)dataWidth / viewBandwidth;
|
||||||
float start, end, center, aPos, bPos, cPos, width;
|
double start, end, center, aPos, bPos, cPos, width;
|
||||||
ImVec2 txtSz;
|
ImVec2 txtSz;
|
||||||
bool startVis, endVis;
|
bool startVis, endVis;
|
||||||
uint32_t color, colorTrans;
|
uint32_t color, colorTrans;
|
||||||
@ -313,9 +316,9 @@ namespace ImGui {
|
|||||||
}
|
}
|
||||||
startVis = (start > lowerFreq);
|
startVis = (start > lowerFreq);
|
||||||
endVis = (end < upperFreq);
|
endVis = (end < upperFreq);
|
||||||
start = std::clamp<float>(start, lowerFreq, upperFreq);
|
start = std::clamp<double>(start, lowerFreq, upperFreq);
|
||||||
end = std::clamp<float>(end, lowerFreq, upperFreq);
|
end = std::clamp<double>(end, lowerFreq, upperFreq);
|
||||||
center = (start + end) / 2.0f;
|
center = (start + end) / 2.0;
|
||||||
aPos = widgetPos.x + 50 + ((start - lowerFreq) * horizScale);
|
aPos = widgetPos.x + 50 + ((start - lowerFreq) * horizScale);
|
||||||
bPos = widgetPos.x + 50 + ((end - lowerFreq) * horizScale);
|
bPos = widgetPos.x + 50 + ((end - lowerFreq) * horizScale);
|
||||||
cPos = widgetPos.x + 50 + ((center - lowerFreq) * horizScale);
|
cPos = widgetPos.x + 50 + ((center - lowerFreq) * horizScale);
|
||||||
@ -335,7 +338,7 @@ namespace ImGui {
|
|||||||
if (bPos <= widgetPos.x + 50) {
|
if (bPos <= widgetPos.x + 50) {
|
||||||
bPos = widgetPos.x + 51;
|
bPos = widgetPos.x + 51;
|
||||||
}
|
}
|
||||||
if (width >= 1.0f) {
|
if (width >= 1.0) {
|
||||||
window->DrawList->AddRectFilled(ImVec2(roundf(aPos), widgetPos.y + fftHeight - 25),
|
window->DrawList->AddRectFilled(ImVec2(roundf(aPos), widgetPos.y + fftHeight - 25),
|
||||||
ImVec2(roundf(bPos), widgetPos.y + fftHeight + 10), colorTrans);
|
ImVec2(roundf(bPos), widgetPos.y + fftHeight + 10), colorTrans);
|
||||||
if (startVis) {
|
if (startVis) {
|
||||||
@ -348,7 +351,7 @@ namespace ImGui {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (txtSz.x <= width) {
|
if (txtSz.x <= width) {
|
||||||
window->DrawList->AddText(ImVec2(cPos - (txtSz.x / 2.0f), widgetPos.y + fftHeight - 17),
|
window->DrawList->AddText(ImVec2(cPos - (txtSz.x / 2.0), widgetPos.y + fftHeight - 17),
|
||||||
IM_COL32(255, 255, 255, 255), bandplan->bands[i].name.c_str());
|
IM_COL32(255, 255, 255, 255), bandplan->bands[i].name.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -380,7 +383,7 @@ namespace ImGui {
|
|||||||
else {
|
else {
|
||||||
fftHeight = widgetSize.y - 50;
|
fftHeight = widgetSize.y - 50;
|
||||||
}
|
}
|
||||||
dataWidth = widgetSize.x - 60.0f;
|
dataWidth = widgetSize.x - 60.0;
|
||||||
delete[] latestFFT;
|
delete[] latestFFT;
|
||||||
|
|
||||||
if (waterfallVisible) {
|
if (waterfallVisible) {
|
||||||
@ -393,7 +396,7 @@ namespace ImGui {
|
|||||||
memset(waterfallFb, 0, dataWidth * waterfallHeight * sizeof(uint32_t));
|
memset(waterfallFb, 0, dataWidth * waterfallHeight * sizeof(uint32_t));
|
||||||
}
|
}
|
||||||
for (int i = 0; i < dataWidth; i++) {
|
for (int i = 0; i < dataWidth; i++) {
|
||||||
latestFFT[i] = -1000.0f; // Hide everything
|
latestFFT[i] = -1000.0; // Hide everything
|
||||||
}
|
}
|
||||||
|
|
||||||
fftAreaMin = ImVec2(widgetPos.x + 50, widgetPos.y + 9);
|
fftAreaMin = ImVec2(widgetPos.x + 50, widgetPos.y + 9);
|
||||||
@ -406,7 +409,7 @@ namespace ImGui {
|
|||||||
|
|
||||||
range = findBestRange(viewBandwidth, maxHSteps);
|
range = findBestRange(viewBandwidth, maxHSteps);
|
||||||
vRange = findBestRange(fftMax - fftMin, maxVSteps);
|
vRange = findBestRange(fftMax - fftMin, maxVSteps);
|
||||||
vRange = 10.0f;
|
vRange = 10.0;
|
||||||
|
|
||||||
updateWaterfallFb();
|
updateWaterfallFb();
|
||||||
updateAllVFOs();
|
updateAllVFOs();
|
||||||
@ -437,7 +440,7 @@ namespace ImGui {
|
|||||||
|
|
||||||
window->DrawList->AddRectFilled(widgetPos, widgetEndPos, IM_COL32( 0, 0, 0, 255 ));
|
window->DrawList->AddRectFilled(widgetPos, widgetEndPos, IM_COL32( 0, 0, 0, 255 ));
|
||||||
window->DrawList->AddRect(widgetPos, widgetEndPos, IM_COL32( 50, 50, 50, 255 ));
|
window->DrawList->AddRect(widgetPos, widgetEndPos, IM_COL32( 50, 50, 50, 255 ));
|
||||||
window->DrawList->AddLine(ImVec2(widgetPos.x, widgetPos.y + fftHeight + 50), ImVec2(widgetPos.x + widgetSize.x, widgetPos.y + fftHeight + 50), IM_COL32(50, 50, 50, 255), 1.0f);
|
window->DrawList->AddLine(ImVec2(widgetPos.x, widgetPos.y + fftHeight + 50), ImVec2(widgetPos.x + widgetSize.x, widgetPos.y + fftHeight + 50), IM_COL32(50, 50, 50, 255), 1.0);
|
||||||
|
|
||||||
processInputs();
|
processInputs();
|
||||||
|
|
||||||
@ -485,9 +488,9 @@ namespace ImGui {
|
|||||||
|
|
||||||
void WaterFall::pushFFT(std::vector<float> data, int n) {
|
void WaterFall::pushFFT(std::vector<float> data, int n) {
|
||||||
buf_mtx.lock();
|
buf_mtx.lock();
|
||||||
float offsetRatio = viewOffset / (wholeBandwidth / 2.0f);
|
double offsetRatio = viewOffset / (wholeBandwidth / 2.0);
|
||||||
int drawDataSize = (viewBandwidth / wholeBandwidth) * data.size();
|
int drawDataSize = (viewBandwidth / wholeBandwidth) * data.size();
|
||||||
int drawDataStart = (((float)data.size() / 2.0f) * (offsetRatio + 1)) - (drawDataSize / 2);
|
int drawDataStart = (((double)data.size() / 2.0) * (offsetRatio + 1)) - (drawDataSize / 2);
|
||||||
|
|
||||||
doZoom(drawDataStart, drawDataSize, dataWidth, data, latestFFT);
|
doZoom(drawDataStart, drawDataSize, dataWidth, data, latestFFT);
|
||||||
rawFFTs.insert(rawFFTs.begin(), data);
|
rawFFTs.insert(rawFFTs.begin(), data);
|
||||||
@ -517,9 +520,9 @@ namespace ImGui {
|
|||||||
lowerId = std::clamp<int>(lowerId, 0, colorCount - 1);
|
lowerId = std::clamp<int>(lowerId, 0, colorCount - 1);
|
||||||
upperId = std::clamp<int>(upperId, 0, colorCount - 1);
|
upperId = std::clamp<int>(upperId, 0, colorCount - 1);
|
||||||
float ratio = (((float)i / (float)WATERFALL_RESOLUTION) * colorCount) - lowerId;
|
float ratio = (((float)i / (float)WATERFALL_RESOLUTION) * colorCount) - lowerId;
|
||||||
float r = (colors[lowerId][0] * (1.0f - ratio)) + (colors[upperId][0] * (ratio));
|
float r = (colors[lowerId][0] * (1.0 - ratio)) + (colors[upperId][0] * (ratio));
|
||||||
float g = (colors[lowerId][1] * (1.0f - ratio)) + (colors[upperId][1] * (ratio));
|
float g = (colors[lowerId][1] * (1.0 - ratio)) + (colors[upperId][1] * (ratio));
|
||||||
float b = (colors[lowerId][2] * (1.0f - ratio)) + (colors[upperId][2] * (ratio));
|
float b = (colors[lowerId][2] * (1.0 - ratio)) + (colors[upperId][2] * (ratio));
|
||||||
waterfallPallet[i] = ((uint32_t)255 << 24) | ((uint32_t)b << 16) | ((uint32_t)g << 8) | (uint32_t)r;
|
waterfallPallet[i] = ((uint32_t)255 << 24) | ((uint32_t)b << 16) | ((uint32_t)g << 8) | (uint32_t)r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -539,70 +542,70 @@ namespace ImGui {
|
|||||||
fftMax = max + 5;
|
fftMax = max + 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaterFall::setCenterFrequency(float freq) {
|
void WaterFall::setCenterFrequency(double freq) {
|
||||||
centerFreq = freq;
|
centerFreq = freq;
|
||||||
lowerFreq = (centerFreq + viewOffset) - (viewBandwidth / 2.0f);
|
lowerFreq = (centerFreq + viewOffset) - (viewBandwidth / 2.0);
|
||||||
upperFreq = (centerFreq + viewOffset) + (viewBandwidth / 2.0f);
|
upperFreq = (centerFreq + viewOffset) + (viewBandwidth / 2.0);
|
||||||
updateAllVFOs();
|
updateAllVFOs();
|
||||||
}
|
}
|
||||||
|
|
||||||
float WaterFall::getCenterFrequency() {
|
double WaterFall::getCenterFrequency() {
|
||||||
return centerFreq;
|
return centerFreq;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaterFall::setBandwidth(float bandWidth) {
|
void WaterFall::setBandwidth(double bandWidth) {
|
||||||
float currentRatio = viewBandwidth / wholeBandwidth;
|
double currentRatio = viewBandwidth / wholeBandwidth;
|
||||||
wholeBandwidth = bandWidth;
|
wholeBandwidth = bandWidth;
|
||||||
setViewBandwidth(bandWidth * currentRatio);
|
setViewBandwidth(bandWidth * currentRatio);
|
||||||
updateAllVFOs();
|
updateAllVFOs();
|
||||||
}
|
}
|
||||||
|
|
||||||
float WaterFall::getBandwidth() {
|
double WaterFall::getBandwidth() {
|
||||||
return wholeBandwidth;
|
return wholeBandwidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaterFall::setViewBandwidth(float bandWidth) {
|
void WaterFall::setViewBandwidth(double bandWidth) {
|
||||||
if (bandWidth == viewBandwidth) {
|
if (bandWidth == viewBandwidth) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (abs(viewOffset) + (bandWidth / 2.0f) > wholeBandwidth / 2.0f) {
|
if (abs(viewOffset) + (bandWidth / 2.0) > wholeBandwidth / 2.0) {
|
||||||
if (viewOffset < 0) {
|
if (viewOffset < 0) {
|
||||||
viewOffset = (bandWidth / 2.0f) - (wholeBandwidth / 2.0f);
|
viewOffset = (bandWidth / 2.0) - (wholeBandwidth / 2.0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
viewOffset = (wholeBandwidth / 2.0f) - (bandWidth / 2.0f);
|
viewOffset = (wholeBandwidth / 2.0) - (bandWidth / 2.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
viewBandwidth = bandWidth;
|
viewBandwidth = bandWidth;
|
||||||
lowerFreq = (centerFreq + viewOffset) - (viewBandwidth / 2.0f);
|
lowerFreq = (centerFreq + viewOffset) - (viewBandwidth / 2.0);
|
||||||
upperFreq = (centerFreq + viewOffset) + (viewBandwidth / 2.0f);
|
upperFreq = (centerFreq + viewOffset) + (viewBandwidth / 2.0);
|
||||||
range = findBestRange(bandWidth, maxHSteps);
|
range = findBestRange(bandWidth, maxHSteps);
|
||||||
updateWaterfallFb();
|
updateWaterfallFb();
|
||||||
updateAllVFOs();
|
updateAllVFOs();
|
||||||
}
|
}
|
||||||
|
|
||||||
float WaterFall::getViewBandwidth() {
|
double WaterFall::getViewBandwidth() {
|
||||||
return viewBandwidth;
|
return viewBandwidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaterFall::setViewOffset(float offset) {
|
void WaterFall::setViewOffset(double offset) {
|
||||||
if (offset == viewOffset) {
|
if (offset == viewOffset) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (offset - (viewBandwidth / 2.0f) < -(wholeBandwidth / 2.0f)) {
|
if (offset - (viewBandwidth / 2.0) < -(wholeBandwidth / 2.0)) {
|
||||||
offset = (viewBandwidth / 2.0f) - (wholeBandwidth / 2.0f);
|
offset = (viewBandwidth / 2.0) - (wholeBandwidth / 2.0);
|
||||||
}
|
}
|
||||||
if (offset + (viewBandwidth / 2.0f) > (wholeBandwidth / 2.0f)) {
|
if (offset + (viewBandwidth / 2.0) > (wholeBandwidth / 2.0)) {
|
||||||
offset = (wholeBandwidth / 2.0f) - (viewBandwidth / 2.0f);
|
offset = (wholeBandwidth / 2.0) - (viewBandwidth / 2.0);
|
||||||
}
|
}
|
||||||
viewOffset = offset;
|
viewOffset = offset;
|
||||||
lowerFreq = (centerFreq + viewOffset) - (viewBandwidth / 2.0f);
|
lowerFreq = (centerFreq + viewOffset) - (viewBandwidth / 2.0);
|
||||||
upperFreq = (centerFreq + viewOffset) + (viewBandwidth / 2.0f);
|
upperFreq = (centerFreq + viewOffset) + (viewBandwidth / 2.0);
|
||||||
updateWaterfallFb();
|
updateWaterfallFb();
|
||||||
updateAllVFOs();
|
updateAllVFOs();
|
||||||
}
|
}
|
||||||
|
|
||||||
float WaterFall::getViewOffset() {
|
double WaterFall::getViewOffset() {
|
||||||
return viewOffset;
|
return viewOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -654,21 +657,21 @@ namespace ImGui {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaterfallVFO::setOffset(float offset) {
|
void WaterfallVFO::setOffset(double offset) {
|
||||||
generalOffset = offset;
|
generalOffset = offset;
|
||||||
if (reference == REF_CENTER) {
|
if (reference == REF_CENTER) {
|
||||||
centerOffset = offset;
|
centerOffset = offset;
|
||||||
lowerOffset = offset - (bandwidth / 2.0f);
|
lowerOffset = offset - (bandwidth / 2.0);
|
||||||
upperOffset = offset + (bandwidth / 2.0f);
|
upperOffset = offset + (bandwidth / 2.0);
|
||||||
}
|
}
|
||||||
else if (reference == REF_LOWER) {
|
else if (reference == REF_LOWER) {
|
||||||
lowerOffset = offset;
|
lowerOffset = offset;
|
||||||
centerOffset = offset + (bandwidth / 2.0f);
|
centerOffset = offset + (bandwidth / 2.0);
|
||||||
upperOffset = offset + bandwidth;
|
upperOffset = offset + bandwidth;
|
||||||
}
|
}
|
||||||
else if (reference == REF_UPPER) {
|
else if (reference == REF_UPPER) {
|
||||||
upperOffset = offset;
|
upperOffset = offset;
|
||||||
centerOffset = offset - (bandwidth / 2.0f);
|
centerOffset = offset - (bandwidth / 2.0);
|
||||||
lowerOffset = offset - bandwidth;
|
lowerOffset = offset - bandwidth;
|
||||||
}
|
}
|
||||||
centerOffsetChanged = true;
|
centerOffsetChanged = true;
|
||||||
@ -677,41 +680,41 @@ namespace ImGui {
|
|||||||
redrawRequired = true;
|
redrawRequired = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaterfallVFO::setCenterOffset(float offset) {
|
void WaterfallVFO::setCenterOffset(double offset) {
|
||||||
if (reference == REF_CENTER) {
|
if (reference == REF_CENTER) {
|
||||||
generalOffset = offset;
|
generalOffset = offset;
|
||||||
}
|
}
|
||||||
else if (reference == REF_LOWER) {
|
else if (reference == REF_LOWER) {
|
||||||
generalOffset = offset - (bandwidth / 2.0f);
|
generalOffset = offset - (bandwidth / 2.0);
|
||||||
}
|
}
|
||||||
else if (reference == REF_UPPER) {
|
else if (reference == REF_UPPER) {
|
||||||
generalOffset = offset + (bandwidth / 2.0f);
|
generalOffset = offset + (bandwidth / 2.0);
|
||||||
}
|
}
|
||||||
centerOffset = offset;
|
centerOffset = offset;
|
||||||
lowerOffset = offset - (bandwidth / 2.0f);
|
lowerOffset = offset - (bandwidth / 2.0);
|
||||||
upperOffset = offset + (bandwidth / 2.0f);
|
upperOffset = offset + (bandwidth / 2.0);
|
||||||
centerOffsetChanged = true;
|
centerOffsetChanged = true;
|
||||||
upperOffsetChanged = true;
|
upperOffsetChanged = true;
|
||||||
lowerOffsetChanged = true;
|
lowerOffsetChanged = true;
|
||||||
redrawRequired = true;
|
redrawRequired = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaterfallVFO::setBandwidth(float bw) {
|
void WaterfallVFO::setBandwidth(double bw) {
|
||||||
if (bandwidth == bw || bw < 0) {
|
if (bandwidth == bw || bw < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bandwidth = bw;
|
bandwidth = bw;
|
||||||
if (reference == REF_CENTER) {
|
if (reference == REF_CENTER) {
|
||||||
lowerOffset = centerOffset - (bandwidth / 2.0f);
|
lowerOffset = centerOffset - (bandwidth / 2.0);
|
||||||
upperOffset = centerOffset + (bandwidth / 2.0f);
|
upperOffset = centerOffset + (bandwidth / 2.0);
|
||||||
}
|
}
|
||||||
else if (reference == REF_LOWER) {
|
else if (reference == REF_LOWER) {
|
||||||
centerOffset = lowerOffset + (bandwidth / 2.0f);
|
centerOffset = lowerOffset + (bandwidth / 2.0);
|
||||||
upperOffset = lowerOffset + bandwidth;
|
upperOffset = lowerOffset + bandwidth;
|
||||||
centerOffsetChanged = true;
|
centerOffsetChanged = true;
|
||||||
}
|
}
|
||||||
else if (reference == REF_UPPER) {
|
else if (reference == REF_UPPER) {
|
||||||
centerOffset = upperOffset - (bandwidth / 2.0f);
|
centerOffset = upperOffset - (bandwidth / 2.0);
|
||||||
lowerOffset = upperOffset - bandwidth;
|
lowerOffset = upperOffset - bandwidth;
|
||||||
centerOffsetChanged = true;
|
centerOffsetChanged = true;
|
||||||
}
|
}
|
||||||
@ -727,11 +730,11 @@ namespace ImGui {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaterfallVFO::updateDrawingVars(float viewBandwidth, float dataWidth, float viewOffset, ImVec2 widgetPos, int fftHeight) {
|
void WaterfallVFO::updateDrawingVars(double viewBandwidth, float dataWidth, double viewOffset, ImVec2 widgetPos, int fftHeight) {
|
||||||
float width = (bandwidth / viewBandwidth) * (float)dataWidth;
|
double width = (bandwidth / viewBandwidth) * (double)dataWidth;
|
||||||
int center = roundf((((centerOffset - viewOffset) / (viewBandwidth / 2.0f)) + 1.0f) * ((float)dataWidth / 2.0f));
|
int center = roundf((((centerOffset - viewOffset) / (viewBandwidth / 2.0)) + 1.0) * ((double)dataWidth / 2.0));
|
||||||
int left = roundf((((lowerOffset - viewOffset) / (viewBandwidth / 2.0f)) + 1.0f) * ((float)dataWidth / 2.0f));
|
int left = roundf((((lowerOffset - viewOffset) / (viewBandwidth / 2.0)) + 1.0) * ((double)dataWidth / 2.0));
|
||||||
int right = roundf((((upperOffset - viewOffset) / (viewBandwidth / 2.0f)) + 1.0f) * ((float)dataWidth / 2.0f));
|
int right = roundf((((upperOffset - viewOffset) / (viewBandwidth / 2.0)) + 1.0) * ((double)dataWidth / 2.0));
|
||||||
|
|
||||||
if (left >= 0 && left < dataWidth && reference == REF_LOWER) {
|
if (left >= 0 && left < dataWidth && reference == REF_LOWER) {
|
||||||
lineMin = ImVec2(widgetPos.x + 50 + left, widgetPos.y + 9);
|
lineMin = ImVec2(widgetPos.x + 50 + left, widgetPos.y + 9);
|
||||||
|
@ -12,11 +12,11 @@ namespace ImGui {
|
|||||||
|
|
||||||
class WaterfallVFO {
|
class WaterfallVFO {
|
||||||
public:
|
public:
|
||||||
void setOffset(float offset);
|
void setOffset(double offset);
|
||||||
void setCenterOffset(float offset);
|
void setCenterOffset(double offset);
|
||||||
void setBandwidth(float bw);
|
void setBandwidth(double bw);
|
||||||
void setReference(int ref);
|
void setReference(int ref);
|
||||||
void updateDrawingVars(float viewBandwidth, float dataWidth, float viewOffset, ImVec2 widgetPos, int fftHeight);
|
void updateDrawingVars(double viewBandwidth, float dataWidth, double viewOffset, ImVec2 widgetPos, int fftHeight); // NOTE: Datawidth double???
|
||||||
void draw(ImGuiWindow* window, bool selected);
|
void draw(ImGuiWindow* window, bool selected);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -26,12 +26,12 @@ namespace ImGui {
|
|||||||
_REF_COUNT
|
_REF_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
float generalOffset;
|
double generalOffset;
|
||||||
float centerOffset;
|
double centerOffset;
|
||||||
float lowerOffset;
|
double lowerOffset;
|
||||||
float upperOffset;
|
double upperOffset;
|
||||||
float bandwidth;
|
double bandwidth;
|
||||||
float snapInterval;
|
double snapInterval = 5000;
|
||||||
int reference = REF_CENTER;
|
int reference = REF_CENTER;
|
||||||
|
|
||||||
ImVec2 rectMin;
|
ImVec2 rectMin;
|
||||||
@ -55,17 +55,17 @@ namespace ImGui {
|
|||||||
|
|
||||||
void updatePallette(float colors[][3], int colorCount);
|
void updatePallette(float colors[][3], int colorCount);
|
||||||
|
|
||||||
void setCenterFrequency(float freq);
|
void setCenterFrequency(double freq);
|
||||||
float getCenterFrequency();
|
double getCenterFrequency();
|
||||||
|
|
||||||
void setBandwidth(float bandWidth);
|
void setBandwidth(double bandWidth);
|
||||||
float getBandwidth();
|
double getBandwidth();
|
||||||
|
|
||||||
void setViewBandwidth(float bandWidth);
|
void setViewBandwidth(double bandWidth);
|
||||||
float getViewBandwidth();
|
double getViewBandwidth();
|
||||||
|
|
||||||
void setViewOffset(float offset);
|
void setViewOffset(double offset);
|
||||||
float getViewOffset();
|
double getViewOffset();
|
||||||
|
|
||||||
void setFFTMin(float min);
|
void setFFTMin(float min);
|
||||||
float getFFTMin();
|
float getFFTMin();
|
||||||
@ -79,8 +79,8 @@ namespace ImGui {
|
|||||||
void setWaterfallMax(float max);
|
void setWaterfallMax(float max);
|
||||||
float getWaterfallMax();
|
float getWaterfallMax();
|
||||||
|
|
||||||
void setZoom(float zoomLevel);
|
void setZoom(double zoomLevel);
|
||||||
void setOffset(float zoomOffset);
|
void setOffset(double zoomOffset);
|
||||||
|
|
||||||
void autoRange();
|
void autoRange();
|
||||||
|
|
||||||
@ -157,20 +157,20 @@ namespace ImGui {
|
|||||||
int fftHeight; // Height of the fft graph
|
int fftHeight; // Height of the fft graph
|
||||||
int waterfallHeight; // Height of the waterfall
|
int waterfallHeight; // Height of the waterfall
|
||||||
|
|
||||||
float viewBandwidth;
|
double viewBandwidth;
|
||||||
float viewOffset;
|
double viewOffset;
|
||||||
|
|
||||||
float lowerFreq;
|
double lowerFreq;
|
||||||
float upperFreq;
|
double upperFreq;
|
||||||
float range;
|
double range;
|
||||||
|
|
||||||
float lastDrag;
|
float lastDrag;
|
||||||
|
|
||||||
int vfoRef = REF_CENTER;
|
int vfoRef = REF_CENTER;
|
||||||
|
|
||||||
// Absolute values
|
// Absolute values
|
||||||
float centerFreq;
|
double centerFreq;
|
||||||
float wholeBandwidth;
|
double wholeBandwidth;
|
||||||
|
|
||||||
// Ranges
|
// Ranges
|
||||||
float fftMin;
|
float fftMin;
|
||||||
|
@ -19,7 +19,7 @@ namespace io {
|
|||||||
std::string name;
|
std::string name;
|
||||||
int index;
|
int index;
|
||||||
int channels;
|
int channels;
|
||||||
std::vector<float> sampleRates;
|
std::vector<double> sampleRates;
|
||||||
std::string txtSampleRates;
|
std::string txtSampleRates;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -323,7 +323,7 @@ namespace io {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float POSSIBLE_SAMP_RATE[6] = {
|
double POSSIBLE_SAMP_RATE[6] = {
|
||||||
48000.0f,
|
48000.0f,
|
||||||
44100.0f,
|
44100.0f,
|
||||||
24000.0f,
|
24000.0f,
|
||||||
@ -336,7 +336,7 @@ namespace io {
|
|||||||
int devIndex;
|
int devIndex;
|
||||||
int devListIndex;
|
int devListIndex;
|
||||||
int defaultDev;
|
int defaultDev;
|
||||||
float _sampleRate;
|
double _sampleRate;
|
||||||
int _bufferSize;
|
int _bufferSize;
|
||||||
dsp::stream<float>* _monoInput;
|
dsp::stream<float>* _monoInput;
|
||||||
dsp::stream<dsp::StereoFloat_t>* _stereoInput;
|
dsp::stream<dsp::StereoFloat_t>* _stereoInput;
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
namespace audio {
|
namespace audio {
|
||||||
std::map<std::string, AudioStream_t*> streams;
|
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;
|
AudioStream_t* astr = new AudioStream_t;
|
||||||
astr->type = STREAM_TYPE_MONO;
|
astr->type = STREAM_TYPE_MONO;
|
||||||
astr->ctx = ctx;
|
astr->ctx = ctx;
|
||||||
astr->audio = new io::AudioSink;
|
astr->audio = new io::AudioSink;
|
||||||
astr->audio->init(1);
|
astr->audio->init(1);
|
||||||
astr->deviceId = astr->audio->getDeviceId();
|
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
|
int blockSize = sampleRate / 200; // default block size
|
||||||
astr->monoAudioStream = new dsp::stream<float>(blockSize * 2);
|
astr->monoAudioStream = new dsp::stream<float>(blockSize * 2);
|
||||||
astr->audio->setBlockSize(blockSize);
|
astr->audio->setBlockSize(blockSize);
|
||||||
@ -31,13 +31,13 @@ namespace audio {
|
|||||||
return sampleRate;
|
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;
|
AudioStream_t* astr = new AudioStream_t;
|
||||||
astr->type = STREAM_TYPE_STEREO;
|
astr->type = STREAM_TYPE_STEREO;
|
||||||
astr->ctx = ctx;
|
astr->ctx = ctx;
|
||||||
astr->audio = new io::AudioSink;
|
astr->audio = new io::AudioSink;
|
||||||
astr->audio->init(1);
|
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
|
int blockSize = sampleRate / 200; // default block size
|
||||||
astr->stereoAudioStream = new dsp::stream<dsp::StereoFloat_t>(blockSize * 2);
|
astr->stereoAudioStream = new dsp::stream<dsp::StereoFloat_t>(blockSize * 2);
|
||||||
astr->audio->setBlockSize(blockSize);
|
astr->audio->setBlockSize(blockSize);
|
||||||
@ -95,7 +95,7 @@ namespace audio {
|
|||||||
delete astr->monoDynSplit;
|
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];
|
AudioStream_t* astr = streams[name];
|
||||||
BoundStream_t bstr;
|
BoundStream_t bstr;
|
||||||
bstr.type = STREAM_TYPE_MONO;
|
bstr.type = STREAM_TYPE_MONO;
|
||||||
@ -125,7 +125,7 @@ namespace audio {
|
|||||||
return bstr.monoStream;
|
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];
|
AudioStream_t* astr = streams[name];
|
||||||
BoundStream_t bstr;
|
BoundStream_t bstr;
|
||||||
bstr.type = STREAM_TYPE_STEREO;
|
bstr.type = STREAM_TYPE_STEREO;
|
||||||
@ -250,7 +250,7 @@ namespace audio {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSampleRate(std::string name, float sampleRate) {
|
void setSampleRate(std::string name, double sampleRate) {
|
||||||
AudioStream_t* astr = streams[name];
|
AudioStream_t* astr = streams[name];
|
||||||
if (astr->running) {
|
if (astr->running) {
|
||||||
return;
|
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];
|
AudioStream_t* astr = streams[name];
|
||||||
if (astr->running) {
|
if (astr->running) {
|
||||||
return;
|
return;
|
||||||
|
@ -11,13 +11,15 @@ namespace audio {
|
|||||||
_STREAM_TYPE_COUNT
|
_STREAM_TYPE_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO: Create a manager class and an instance class
|
||||||
|
|
||||||
struct BoundStream_t {
|
struct BoundStream_t {
|
||||||
dsp::stream<float>* monoStream;
|
dsp::stream<float>* monoStream;
|
||||||
dsp::stream<dsp::StereoFloat_t>* stereoStream;
|
dsp::stream<dsp::StereoFloat_t>* stereoStream;
|
||||||
dsp::StereoToMono* s2m;
|
dsp::StereoToMono* s2m;
|
||||||
dsp::MonoToStereo* m2s;
|
dsp::MonoToStereo* m2s;
|
||||||
void (*streamRemovedHandler)(void* ctx);
|
void (*streamRemovedHandler)(void* ctx);
|
||||||
void (*sampleRateChangeHandler)(void* ctx, float sampleRate, int blockSize);
|
void (*sampleRateChangeHandler)(void* ctx, double sampleRate, int blockSize);
|
||||||
void* ctx;
|
void* ctx;
|
||||||
int type;
|
int type;
|
||||||
};
|
};
|
||||||
@ -31,8 +33,8 @@ namespace audio {
|
|||||||
dsp::DynamicSplitter<float>* monoDynSplit;
|
dsp::DynamicSplitter<float>* monoDynSplit;
|
||||||
dsp::stream<dsp::StereoFloat_t>* stereoStream;
|
dsp::stream<dsp::StereoFloat_t>* stereoStream;
|
||||||
dsp::DynamicSplitter<dsp::StereoFloat_t>* stereoDynSplit;
|
dsp::DynamicSplitter<dsp::StereoFloat_t>* stereoDynSplit;
|
||||||
int (*sampleRateChangeHandler)(void* ctx, float sampleRate);
|
int (*sampleRateChangeHandler)(void* ctx, double sampleRate);
|
||||||
float sampleRate;
|
double sampleRate;
|
||||||
int blockSize;
|
int blockSize;
|
||||||
int type;
|
int type;
|
||||||
bool running = false;
|
bool running = false;
|
||||||
@ -45,19 +47,19 @@ namespace audio {
|
|||||||
|
|
||||||
extern std::map<std::string, AudioStream_t*> streams;
|
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);
|
double registerMonoStream(dsp::stream<float>* stream, std::string name, std::string vfoName, int (*sampleRateChangeHandler)(void* ctx, double 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 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 startStream(std::string name);
|
||||||
void stopStream(std::string name);
|
void stopStream(std::string name);
|
||||||
void removeStream(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<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, 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);
|
||||||
void setBlockSize(std::string name, int blockSize);
|
void setBlockSize(std::string name, int blockSize);
|
||||||
void unbindFromStreamMono(std::string name, dsp::stream<float>* stream);
|
void unbindFromStreamMono(std::string name, dsp::stream<float>* stream);
|
||||||
void unbindFromStreamStereo(std::string name, dsp::stream<dsp::StereoFloat_t>* stream);
|
void unbindFromStreamStereo(std::string name, dsp::stream<dsp::StereoFloat_t>* stream);
|
||||||
std::string getNameFromVFO(std::string vfoName);
|
std::string getNameFromVFO(std::string vfoName);
|
||||||
void setSampleRate(std::string name, float sampleRate);
|
void setSampleRate(std::string name, double sampleRate);
|
||||||
void setAudioDevice(std::string name, int deviceId, float sampleRate);
|
void setAudioDevice(std::string name, int deviceId, double sampleRate);
|
||||||
std::vector<std::string> getStreamNameList();
|
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);
|
dynSplit.init(&split.output_b, 32000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SignalPath::setSampleRate(float sampleRate) {
|
void SignalPath::setSampleRate(double sampleRate) {
|
||||||
this->sampleRate = sampleRate;
|
this->sampleRate = sampleRate;
|
||||||
inputBlockSize = sampleRate / 200.0f;
|
inputBlockSize = sampleRate / 200.0f;
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ void SignalPath::setDCBiasCorrection(bool enabled) {
|
|||||||
dcBiasRemover.bypass = !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()) {
|
if (vfos.find(name) != vfos.end()) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,10 @@ public:
|
|||||||
SignalPath();
|
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 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 start();
|
||||||
void setSampleRate(float sampleRate);
|
void setSampleRate(double sampleRate);
|
||||||
void setDCBiasCorrection(bool enabled);
|
void setDCBiasCorrection(bool enabled);
|
||||||
void setFFTRate(float rate);
|
void setFFTRate(double rate);
|
||||||
dsp::VFO* addVFO(std::string name, float outSampleRate, float bandwidth, float offset);
|
dsp::VFO* addVFO(std::string name, double outSampleRate, double bandwidth, double offset);
|
||||||
void removeVFO(std::string name);
|
void removeVFO(std::string name);
|
||||||
void setInput(dsp::stream<dsp::complex_t>* input);
|
void setInput(dsp::stream<dsp::complex_t>* input);
|
||||||
|
|
||||||
@ -40,8 +40,8 @@ private:
|
|||||||
dsp::DynamicSplitter<dsp::complex_t> dynSplit;
|
dsp::DynamicSplitter<dsp::complex_t> dynSplit;
|
||||||
std::map<std::string, VFO_t> vfos;
|
std::map<std::string, VFO_t> vfos;
|
||||||
|
|
||||||
float sampleRate;
|
double sampleRate;
|
||||||
float fftRate;
|
double fftRate;
|
||||||
int fftSize;
|
int fftSize;
|
||||||
int inputBlockSize;
|
int inputBlockSize;
|
||||||
};
|
};
|
@ -1,7 +1,7 @@
|
|||||||
#include <signal_path/vfo_manager.h>
|
#include <signal_path/vfo_manager.h>
|
||||||
#include <signal_path/signal_path.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;
|
this->name = name;
|
||||||
dspVFO = sigpath::signalPath.addVFO(name, sampleRate, bandwidth, offset);
|
dspVFO = sigpath::signalPath.addVFO(name, sampleRate, bandwidth, offset);
|
||||||
wtfVFO = new ImGui::WaterfallVFO;
|
wtfVFO = new ImGui::WaterfallVFO;
|
||||||
@ -18,22 +18,22 @@ VFOManager::VFO::~VFO() {
|
|||||||
delete wtfVFO;
|
delete wtfVFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VFOManager::VFO::setOffset(float offset) {
|
void VFOManager::VFO::setOffset(double offset) {
|
||||||
wtfVFO->setOffset(offset);
|
wtfVFO->setOffset(offset);
|
||||||
dspVFO->setOffset(wtfVFO->centerOffset);
|
dspVFO->setOffset(wtfVFO->centerOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VFOManager::VFO::setCenterOffset(float offset) {
|
void VFOManager::VFO::setCenterOffset(double offset) {
|
||||||
wtfVFO->setCenterOffset(offset);
|
wtfVFO->setCenterOffset(offset);
|
||||||
dspVFO->setOffset(offset);
|
dspVFO->setOffset(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VFOManager::VFO::setBandwidth(float bandwidth) {
|
void VFOManager::VFO::setBandwidth(double bandwidth) {
|
||||||
wtfVFO->setBandwidth(bandwidth);
|
wtfVFO->setBandwidth(bandwidth);
|
||||||
dspVFO->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);
|
dspVFO->setOutputSampleRate(sampleRate, bandwidth);
|
||||||
wtfVFO->setBandwidth(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 == "") {
|
if (vfos.find(name) != vfos.end() || name == "") {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -74,28 +74,28 @@ void VFOManager::deleteVFO(VFOManager::VFO* vfo) {
|
|||||||
vfos.erase(name);
|
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()) {
|
if (vfos.find(name) == vfos.end()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vfos[name]->setOffset(offset);
|
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()) {
|
if (vfos.find(name) == vfos.end()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vfos[name]->setCenterOffset(offset);
|
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()) {
|
if (vfos.find(name) == vfos.end()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vfos[name]->setBandwidth(bandwidth);
|
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()) {
|
if (vfos.find(name) == vfos.end()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -9,13 +9,13 @@ public:
|
|||||||
|
|
||||||
class VFO {
|
class VFO {
|
||||||
public:
|
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();
|
~VFO();
|
||||||
|
|
||||||
void setOffset(float offset);
|
void setOffset(double offset);
|
||||||
void setCenterOffset(float offset);
|
void setCenterOffset(double offset);
|
||||||
void setBandwidth(float bandwidth);
|
void setBandwidth(double bandwidth);
|
||||||
void setSampleRate(float sampleRate, float bandwidth);
|
void setSampleRate(double sampleRate, double bandwidth);
|
||||||
void setReference(int ref);
|
void setReference(int ref);
|
||||||
int getOutputBlockSize();
|
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 deleteVFO(VFOManager::VFO* vfo);
|
||||||
|
|
||||||
void setOffset(std::string name, float offset);
|
void setOffset(std::string name, double offset);
|
||||||
void setCenterOffset(std::string name, float offset);
|
void setCenterOffset(std::string name, double offset);
|
||||||
void setBandwidth(std::string name, float bandwidth);
|
void setBandwidth(std::string name, double bandwidth);
|
||||||
void setSampleRate(std::string name, float sampleRate, float bandwidth);
|
void setSampleRate(std::string name, double sampleRate, double bandwidth);
|
||||||
void setReference(std::string name, int ref);
|
void setReference(std::string name, int ref);
|
||||||
int getOutputBlockSize(std::string name);
|
int getOutputBlockSize(std::string name);
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"bandPlan": "General",
|
"bandPlan": "General",
|
||||||
"bandPlanEnabled": true,
|
"bandPlanEnabled": true,
|
||||||
"fftHeight": 300,
|
"fftHeight": 300,
|
||||||
"frequency": 96035792,
|
"frequency": 94930000,
|
||||||
"max": 0.0,
|
"max": 0.0,
|
||||||
"maximized": false,
|
"maximized": false,
|
||||||
"menuOrder": [
|
"menuOrder": [
|
||||||
|
Loading…
Reference in New Issue
Block a user