Fixed waterfall inaccuracies + started adding stepped VFO

This commit is contained in:
AlexandreRouma 2020-10-15 16:09:01 +02:00
parent 3b6a3ff94d
commit 027054b57e
12 changed files with 247 additions and 242 deletions

View File

@ -9,8 +9,8 @@ namespace bandplan {
struct Band_t {
std::string name;
std::string type;
float start;
float end;
double start;
double end;
};
void to_json(json& j, const Band_t& b);

View File

@ -52,14 +52,14 @@ void fftHandler(dsp::complex_t* samples) {
int half = fftSize / 2;
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++) {
_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++) {
_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);
@ -68,13 +68,13 @@ void fftHandler(dsp::complex_t* samples) {
dsp::NullSink sink;
watcher<uint64_t> freq((uint64_t)90500000);
watcher<float> vfoFreq(92000000.0f);
float dummyVolume = 1.0f;
watcher<double> vfoFreq(92000000.0);
float dummyVolume = 1.0;
float* volume = &dummyVolume;
float fftMin = -70.0f;
float fftMax = 0.0f;
watcher<float> offset(0.0f, true);
watcher<float> bw(8000000.0f, true);
float fftMin = -70.0;
float fftMax = 0.0;
watcher<double> offset(0.0, true);
watcher<float> bw(8000000.0, true);
bool playing = false;
watcher<bool> dcbias(false, false);
bool showCredits = false;
@ -140,7 +140,7 @@ void windowInit() {
gui::waterfall.setFFTMax(fftMax);
gui::waterfall.setWaterfallMax(fftMax);
float frequency = core::configManager.conf["frequency"];
double frequency = core::configManager.conf["frequency"];
gui::freqSelect.setFrequency(frequency);
gui::freqSelect.frequencyChanged = false;
@ -164,27 +164,27 @@ void windowInit() {
core::configManager.release();
}
void setVFO(float freq) {
void setVFO(double freq) {
ImGui::WaterfallVFO* vfo = gui::waterfall.vfos[gui::waterfall.selectedVFO];
float currentOff = vfo->centerOffset;
float currentTune = gui::waterfall.getCenterFrequency() + vfo->generalOffset;
float delta = freq - currentTune;
double currentOff = vfo->centerOffset;
double currentTune = gui::waterfall.getCenterFrequency() + vfo->generalOffset;
double delta = freq - currentTune;
float newVFO = currentOff + delta;
float vfoBW = vfo->bandwidth;
float vfoBottom = newVFO - (vfoBW / 2.0f);
float vfoTop = newVFO + (vfoBW / 2.0f);
double newVFO = currentOff + delta;
double vfoBW = vfo->bandwidth;
double vfoBottom = newVFO - (vfoBW / 2.0);
double vfoTop = newVFO + (vfoBW / 2.0);
float view = gui::waterfall.getViewOffset();
float viewBW = gui::waterfall.getViewBandwidth();
float viewBottom = view - (viewBW / 2.0f);
float viewTop = view + (viewBW / 2.0f);
double view = gui::waterfall.getViewOffset();
double viewBW = gui::waterfall.getViewBandwidth();
double viewBottom = view - (viewBW / 2.0);
double viewTop = view + (viewBW / 2.0);
float wholeFreq = gui::waterfall.getCenterFrequency();
float BW = gui::waterfall.getBandwidth();
float bottom = -(BW / 2.0f);
float top = (BW / 2.0f);
double wholeFreq = gui::waterfall.getCenterFrequency();
double BW = gui::waterfall.getBandwidth();
double bottom = -(BW / 2.0);
double top = (BW / 2.0);
// VFO still fints in the view
if (vfoBottom > viewBottom && vfoTop < viewTop) {
@ -194,8 +194,8 @@ void setVFO(float freq) {
// VFO too low for current SDR tuning
if (vfoBottom < bottom) {
gui::waterfall.setViewOffset((BW / 2.0f) - (viewBW / 2.0f));
float newVFOOffset = (BW / 2.0f) - (vfoBW / 2.0f) - (viewBW / 10.0f);
gui::waterfall.setViewOffset((BW / 2.0) - (viewBW / 2.0));
double newVFOOffset = (BW / 2.0) - (vfoBW / 2.0) - (viewBW / 10.0);
sigpath::vfoManager.setCenterOffset(gui::waterfall.selectedVFO, newVFOOffset);
gui::waterfall.setCenterFrequency(freq - newVFOOffset);
sigpath::sourceManager.tune(freq - newVFOOffset);
@ -204,8 +204,8 @@ void setVFO(float freq) {
// VFO too high for current SDR tuning
if (vfoTop > top) {
gui::waterfall.setViewOffset((viewBW / 2.0f) - (BW / 2.0f));
float newVFOOffset = (vfoBW / 2.0f) - (BW / 2.0f) + (viewBW / 10.0f);
gui::waterfall.setViewOffset((viewBW / 2.0) - (BW / 2.0));
double newVFOOffset = (vfoBW / 2.0) - (BW / 2.0) + (viewBW / 10.0);
sigpath::vfoManager.setCenterOffset(gui::waterfall.selectedVFO, newVFOOffset);
gui::waterfall.setCenterFrequency(freq - newVFOOffset);
sigpath::sourceManager.tune(freq - newVFOOffset);
@ -214,9 +214,9 @@ void setVFO(float freq) {
// VFO is still without the SDR's bandwidth
if (delta < 0) {
float newViewOff = vfoTop - (viewBW / 2.0f) + (viewBW / 10.0f);
float newViewBottom = newViewOff - (viewBW / 2.0f);
float newViewTop = newViewOff + (viewBW / 2.0f);
double newViewOff = vfoTop - (viewBW / 2.0) + (viewBW / 10.0);
double newViewBottom = newViewOff - (viewBW / 2.0);
double newViewTop = newViewOff + (viewBW / 2.0);
if (newViewBottom > bottom) {
gui::waterfall.setViewOffset(newViewOff);
@ -224,16 +224,16 @@ void setVFO(float freq) {
return;
}
gui::waterfall.setViewOffset((BW / 2.0f) - (viewBW / 2.0f));
float newVFOOffset = (BW / 2.0f) - (vfoBW / 2.0f) - (viewBW / 10.0f);
gui::waterfall.setViewOffset((BW / 2.0) - (viewBW / 2.0));
double newVFOOffset = (BW / 2.0) - (vfoBW / 2.0) - (viewBW / 10.0);
sigpath::vfoManager.setCenterOffset(gui::waterfall.selectedVFO, newVFOOffset);
gui::waterfall.setCenterFrequency(freq - newVFOOffset);
sigpath::sourceManager.tune(freq - newVFOOffset);
}
else {
float newViewOff = vfoBottom + (viewBW / 2.0f) - (viewBW / 10.0f);
float newViewBottom = newViewOff - (viewBW / 2.0f);
float newViewTop = newViewOff + (viewBW / 2.0f);
double newViewOff = vfoBottom + (viewBW / 2.0) - (viewBW / 10.0);
double newViewBottom = newViewOff - (viewBW / 2.0);
double newViewTop = newViewOff + (viewBW / 2.0);
if (newViewTop < top) {
gui::waterfall.setViewOffset(newViewOff);
@ -241,8 +241,8 @@ void setVFO(float freq) {
return;
}
gui::waterfall.setViewOffset((viewBW / 2.0f) - (BW / 2.0f));
float newVFOOffset = (vfoBW / 2.0f) - (BW / 2.0f) + (viewBW / 10.0f);
gui::waterfall.setViewOffset((viewBW / 2.0) - (BW / 2.0));
double newVFOOffset = (vfoBW / 2.0) - (BW / 2.0) + (viewBW / 10.0);
sigpath::vfoManager.setCenterOffset(gui::waterfall.selectedVFO, newVFOOffset);
gui::waterfall.setCenterFrequency(freq - newVFOOffset);
sigpath::sourceManager.tune(freq - newVFOOffset);
@ -341,7 +341,7 @@ void drawWindow() {
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 8);
ImGui::SetNextItemWidth(200);
if (ImGui::SliderFloat("##_2_", volume, 0.0f, 1.0f, "")) {
if (ImGui::SliderFloat("##_2_", volume, 0.0, 1.0, "")) {
if (audioStreamName != "") {
core::configManager.aquire();
if (!core::configManager.conf["audio"].contains(audioStreamName)) {
@ -414,9 +414,9 @@ void drawWindow() {
gui::menu.draw();
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("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::Spacing();
}
@ -446,17 +446,17 @@ void drawWindow() {
ImGui::NextColumn();
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::SetCursorPosX((ImGui::GetWindowSize().x / 2.0f) - 10);
ImGui::VSliderFloat("##_7_", ImVec2(20.0f, 150.0f), &bw.val, gui::waterfall.getBandwidth(), 1000.0f, "");
ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2.0) - 10);
ImGui::VSliderFloat("##_7_", ImVec2(20.0, 150.0), &bw.val, gui::waterfall.getBandwidth(), 1000.0, "");
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::SetCursorPosX((ImGui::GetWindowSize().x / 2.0f) - 10);
if (ImGui::VSliderFloat("##_8_", ImVec2(20.0f, 150.0f), &fftMax, 0.0f, -100.0f, "")) {
ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2.0) - 10);
if (ImGui::VSliderFloat("##_8_", ImVec2(20.0, 150.0), &fftMax, 0.0, -100.0, "")) {
fftMax = std::max<float>(fftMax, fftMin + 10);
core::configManager.aquire();
core::configManager.conf["max"] = fftMax;
@ -465,10 +465,10 @@ void drawWindow() {
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::SetCursorPosX((ImGui::GetWindowSize().x / 2.0f) - 10);
if (ImGui::VSliderFloat("##_9_", ImVec2(20.0f, 150.0f), &fftMin, 0.0f, -100.0f, "")) {
ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2.0) - 10);
if (ImGui::VSliderFloat("##_9_", ImVec2(20.0, 150.0), &fftMin, 0.0, -100.0, "")) {
fftMin = std::min<float>(fftMax - 10, fftMin);
core::configManager.aquire();
core::configManager.conf["min"] = fftMin;

View File

@ -36,38 +36,40 @@ void doZoom(int offset, int width, int outWidth, std::vector<float> data, float*
}
}
float freq_ranges[] = {
1.0f, 2.0f, 2.5f, 5.0f,
10.0f, 20.0f, 25.0f, 50.0f,
100.0f, 200.0f, 250.0f, 500.0f,
1000.0f, 2000.0f, 2500.0f, 5000.0f,
10000.0f, 20000.0f, 25000.0f, 50000.0f,
100000.0f, 200000.0f, 250000.0f, 500000.0f,
1000000.0f, 2000000.0f, 2500000.0f, 5000000.0f,
10000000.0f, 20000000.0f, 25000000.0f, 50000000.0f
// TODO: Fix this hacky BS
double freq_ranges[] = {
1.0, 2.0, 2.5, 5.0,
10.0, 20.0, 25.0, 50.0,
100.0, 200.0, 250.0, 500.0,
1000.0, 2000.0, 2500.0, 5000.0,
10000.0, 20000.0, 25000.0, 50000.0,
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++) {
if (bandwidth / freq_ranges[i] < (float)maxSteps) {
if (bandwidth / freq_ranges[i] < (double)maxSteps) {
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) {
sprintf(buf, "%.3f", freq);
sprintf(buf, "%.3lf", freq);
}
else if (freq < 1000000) {
sprintf(buf, "%.3fK", freq / 1000.0f);
sprintf(buf, "%.3lfK", freq / 1000.0);
}
else if (freq < 1000000000) {
sprintf(buf, "%.3fM", freq / 1000000.0f);
sprintf(buf, "%.3lfM", freq / 1000000.0);
}
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--) {
if (buf[i] != '0') {
@ -84,10 +86,10 @@ void printAndScale(float freq, char* buf) {
namespace ImGui {
WaterFall::WaterFall() {
fftMin = -70.0f;
fftMax = 0.0f;
waterfallMin = -70.0f;
waterfallMax = 0.0f;
fftMin = -70.0;
fftMax = 0.0;
waterfallMin = -70.0;
waterfallMax = 0.0;
FFTAreaHeight = 300;
newFFTAreaHeight = FFTAreaHeight;
fftHeight = FFTAreaHeight - 50;
@ -99,8 +101,8 @@ namespace ImGui {
latestFFT = new float[1];
waterfallFb = new uint32_t[1];
viewBandwidth = 1.0f;
wholeBandwidth = 1.0f;
viewBandwidth = 1.0;
wholeBandwidth = 1.0;
glGenTextures(1, &textureId);
@ -122,51 +124,51 @@ namespace ImGui {
float yPos = widgetPos.y + fftHeight + 10 - ((line - fftMin) * scaleFactor);
window->DrawList->AddLine(ImVec2(roundf(widgetPos.x + 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);
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
float startFreq = ceilf(lowerFreq / range) * range;
float horizScale = (float)dataWidth / viewBandwidth;
for (float freq = startFreq; freq < upperFreq; freq += range) {
float xPos = widgetPos.x + 50 + ((freq - lowerFreq) * horizScale);
double startFreq = ceilf(lowerFreq / range) * range;
double horizScale = (double)dataWidth / viewBandwidth;
for (double freq = startFreq; freq < upperFreq; freq += range) {
double xPos = widgetPos.x + 50 + ((freq - lowerFreq) * horizScale);
window->DrawList->AddLine(ImVec2(roundf(xPos), widgetPos.y + 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),
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);
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
for (int i = 1; i < dataWidth; i++) {
float aPos = widgetPos.y + fftHeight + 10 - ((latestFFT[i - 1] - fftMin) * scaleFactor);
float bPos = widgetPos.y + fftHeight + 10 - ((latestFFT[i] - fftMin) * scaleFactor);
double aPos = widgetPos.y + fftHeight + 10 - ((latestFFT[i - 1] - fftMin) * scaleFactor);
double bPos = widgetPos.y + fftHeight + 10 - ((latestFFT[i] - fftMin) * scaleFactor);
if (aPos < fftMin && bPos < fftMin) {
continue;
}
aPos = std::clamp<float>(aPos, widgetPos.y + 10, widgetPos.y + fftHeight + 10);
bPos = std::clamp<float>(bPos, widgetPos.y + 10, widgetPos.y + fftHeight + 10);
aPos = std::clamp<double>(aPos, 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)),
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)),
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
window->DrawList->AddLine(ImVec2(widgetPos.x + 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
window->DrawList->AddLine(ImVec2(widgetPos.x + 50, widgetPos.y + 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);
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) {
int refCenter = mousePos.x - (widgetPos.x + 50);
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) {
float deltax = drag.x - lastDrag;
double deltax = drag.x - lastDrag;
lastDrag = drag.x;
float viewDelta = deltax * (viewBandwidth / (float)dataWidth);
double viewDelta = deltax * (viewBandwidth / (double)dataWidth);
viewOffset -= viewDelta;
if (viewOffset + (viewBandwidth / 2.0f) > wholeBandwidth / 2.0f) {
float freqOffset = (viewOffset + (viewBandwidth / 2.0f)) - (wholeBandwidth / 2.0f);
viewOffset = (wholeBandwidth / 2.0f) - (viewBandwidth / 2.0f);
if (viewOffset + (viewBandwidth / 2.0) > wholeBandwidth / 2.0) {
double freqOffset = (viewOffset + (viewBandwidth / 2.0)) - (wholeBandwidth / 2.0);
viewOffset = (wholeBandwidth / 2.0) - (viewBandwidth / 2.0);
centerFreq += freqOffset;
centerFreqMoved = true;
}
if (viewOffset - (viewBandwidth / 2.0f) < -(wholeBandwidth / 2.0f)) {
float freqOffset = (viewOffset - (viewBandwidth / 2.0f)) + (wholeBandwidth / 2.0f);
viewOffset = (viewBandwidth / 2.0f) - (wholeBandwidth / 2.0f);
if (viewOffset - (viewBandwidth / 2.0) < -(wholeBandwidth / 2.0)) {
double freqOffset = (viewOffset - (viewBandwidth / 2.0)) + (wholeBandwidth / 2.0);
viewOffset = (viewBandwidth / 2.0) - (wholeBandwidth / 2.0);
centerFreq += freqOffset;
centerFreqMoved = true;
}
lowerFreq = (centerFreq + viewOffset) - (viewBandwidth / 2.0f);
upperFreq = (centerFreq + viewOffset) + (viewBandwidth / 2.0f);
lowerFreq = (centerFreq + viewOffset) - (viewBandwidth / 2.0);
upperFreq = (centerFreq + viewOffset) + (viewBandwidth / 2.0);
updateWaterfallFb();
}
else {
@ -273,7 +276,7 @@ namespace ImGui {
if (!waterfallVisible) {
return;
}
float offsetRatio = viewOffset / (wholeBandwidth / 2.0f);
double offsetRatio = viewOffset / (wholeBandwidth / 2.0);
int drawDataSize;
int drawDataStart;
int count = std::min<int>(waterfallHeight, rawFFTs.size());
@ -284,7 +287,7 @@ namespace ImGui {
for (int i = 0; i < count; i++) {
size = rawFFTs[i].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);
for (int j = 0; j < dataWidth; j++) {
pixel = (std::clamp<float>(tempData[j], waterfallMin, waterfallMax) - waterfallMin) / dataRange;
@ -297,8 +300,8 @@ namespace ImGui {
void WaterFall::drawBandPlan() {
int count = bandplan->bands.size();
float horizScale = (float)dataWidth / viewBandwidth;
float start, end, center, aPos, bPos, cPos, width;
double horizScale = (double)dataWidth / viewBandwidth;
double start, end, center, aPos, bPos, cPos, width;
ImVec2 txtSz;
bool startVis, endVis;
uint32_t color, colorTrans;
@ -313,9 +316,9 @@ namespace ImGui {
}
startVis = (start > lowerFreq);
endVis = (end < upperFreq);
start = std::clamp<float>(start, lowerFreq, upperFreq);
end = std::clamp<float>(end, lowerFreq, upperFreq);
center = (start + end) / 2.0f;
start = std::clamp<double>(start, lowerFreq, upperFreq);
end = std::clamp<double>(end, lowerFreq, upperFreq);
center = (start + end) / 2.0;
aPos = widgetPos.x + 50 + ((start - lowerFreq) * horizScale);
bPos = widgetPos.x + 50 + ((end - lowerFreq) * horizScale);
cPos = widgetPos.x + 50 + ((center - lowerFreq) * horizScale);
@ -335,7 +338,7 @@ namespace ImGui {
if (bPos <= widgetPos.x + 50) {
bPos = widgetPos.x + 51;
}
if (width >= 1.0f) {
if (width >= 1.0) {
window->DrawList->AddRectFilled(ImVec2(roundf(aPos), widgetPos.y + fftHeight - 25),
ImVec2(roundf(bPos), widgetPos.y + fftHeight + 10), colorTrans);
if (startVis) {
@ -348,7 +351,7 @@ namespace ImGui {
}
}
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());
}
}
@ -380,7 +383,7 @@ namespace ImGui {
else {
fftHeight = widgetSize.y - 50;
}
dataWidth = widgetSize.x - 60.0f;
dataWidth = widgetSize.x - 60.0;
delete[] latestFFT;
if (waterfallVisible) {
@ -393,7 +396,7 @@ namespace ImGui {
memset(waterfallFb, 0, dataWidth * waterfallHeight * sizeof(uint32_t));
}
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);
@ -406,7 +409,7 @@ namespace ImGui {
range = findBestRange(viewBandwidth, maxHSteps);
vRange = findBestRange(fftMax - fftMin, maxVSteps);
vRange = 10.0f;
vRange = 10.0;
updateWaterfallFb();
updateAllVFOs();
@ -437,7 +440,7 @@ namespace ImGui {
window->DrawList->AddRectFilled(widgetPos, widgetEndPos, IM_COL32( 0, 0, 0, 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();
@ -485,9 +488,9 @@ namespace ImGui {
void WaterFall::pushFFT(std::vector<float> data, int n) {
buf_mtx.lock();
float offsetRatio = viewOffset / (wholeBandwidth / 2.0f);
double offsetRatio = viewOffset / (wholeBandwidth / 2.0);
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);
rawFFTs.insert(rawFFTs.begin(), data);
@ -517,9 +520,9 @@ namespace ImGui {
lowerId = std::clamp<int>(lowerId, 0, colorCount - 1);
upperId = std::clamp<int>(upperId, 0, colorCount - 1);
float ratio = (((float)i / (float)WATERFALL_RESOLUTION) * colorCount) - lowerId;
float r = (colors[lowerId][0] * (1.0f - ratio)) + (colors[upperId][0] * (ratio));
float g = (colors[lowerId][1] * (1.0f - ratio)) + (colors[upperId][1] * (ratio));
float b = (colors[lowerId][2] * (1.0f - ratio)) + (colors[upperId][2] * (ratio));
float r = (colors[lowerId][0] * (1.0 - ratio)) + (colors[upperId][0] * (ratio));
float g = (colors[lowerId][1] * (1.0 - ratio)) + (colors[upperId][1] * (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;
}
}
@ -539,70 +542,70 @@ namespace ImGui {
fftMax = max + 5;
}
void WaterFall::setCenterFrequency(float freq) {
void WaterFall::setCenterFrequency(double freq) {
centerFreq = freq;
lowerFreq = (centerFreq + viewOffset) - (viewBandwidth / 2.0f);
upperFreq = (centerFreq + viewOffset) + (viewBandwidth / 2.0f);
lowerFreq = (centerFreq + viewOffset) - (viewBandwidth / 2.0);
upperFreq = (centerFreq + viewOffset) + (viewBandwidth / 2.0);
updateAllVFOs();
}
float WaterFall::getCenterFrequency() {
double WaterFall::getCenterFrequency() {
return centerFreq;
}
void WaterFall::setBandwidth(float bandWidth) {
float currentRatio = viewBandwidth / wholeBandwidth;
void WaterFall::setBandwidth(double bandWidth) {
double currentRatio = viewBandwidth / wholeBandwidth;
wholeBandwidth = bandWidth;
setViewBandwidth(bandWidth * currentRatio);
updateAllVFOs();
}
float WaterFall::getBandwidth() {
double WaterFall::getBandwidth() {
return wholeBandwidth;
}
void WaterFall::setViewBandwidth(float bandWidth) {
void WaterFall::setViewBandwidth(double bandWidth) {
if (bandWidth == viewBandwidth) {
return;
}
if (abs(viewOffset) + (bandWidth / 2.0f) > wholeBandwidth / 2.0f) {
if (abs(viewOffset) + (bandWidth / 2.0) > wholeBandwidth / 2.0) {
if (viewOffset < 0) {
viewOffset = (bandWidth / 2.0f) - (wholeBandwidth / 2.0f);
viewOffset = (bandWidth / 2.0) - (wholeBandwidth / 2.0);
}
else {
viewOffset = (wholeBandwidth / 2.0f) - (bandWidth / 2.0f);
viewOffset = (wholeBandwidth / 2.0) - (bandWidth / 2.0);
}
}
viewBandwidth = bandWidth;
lowerFreq = (centerFreq + viewOffset) - (viewBandwidth / 2.0f);
upperFreq = (centerFreq + viewOffset) + (viewBandwidth / 2.0f);
lowerFreq = (centerFreq + viewOffset) - (viewBandwidth / 2.0);
upperFreq = (centerFreq + viewOffset) + (viewBandwidth / 2.0);
range = findBestRange(bandWidth, maxHSteps);
updateWaterfallFb();
updateAllVFOs();
}
float WaterFall::getViewBandwidth() {
double WaterFall::getViewBandwidth() {
return viewBandwidth;
}
void WaterFall::setViewOffset(float offset) {
void WaterFall::setViewOffset(double offset) {
if (offset == viewOffset) {
return;
}
if (offset - (viewBandwidth / 2.0f) < -(wholeBandwidth / 2.0f)) {
offset = (viewBandwidth / 2.0f) - (wholeBandwidth / 2.0f);
if (offset - (viewBandwidth / 2.0) < -(wholeBandwidth / 2.0)) {
offset = (viewBandwidth / 2.0) - (wholeBandwidth / 2.0);
}
if (offset + (viewBandwidth / 2.0f) > (wholeBandwidth / 2.0f)) {
offset = (wholeBandwidth / 2.0f) - (viewBandwidth / 2.0f);
if (offset + (viewBandwidth / 2.0) > (wholeBandwidth / 2.0)) {
offset = (wholeBandwidth / 2.0) - (viewBandwidth / 2.0);
}
viewOffset = offset;
lowerFreq = (centerFreq + viewOffset) - (viewBandwidth / 2.0f);
upperFreq = (centerFreq + viewOffset) + (viewBandwidth / 2.0f);
lowerFreq = (centerFreq + viewOffset) - (viewBandwidth / 2.0);
upperFreq = (centerFreq + viewOffset) + (viewBandwidth / 2.0);
updateWaterfallFb();
updateAllVFOs();
}
float WaterFall::getViewOffset() {
double WaterFall::getViewOffset() {
return viewOffset;
}
@ -654,21 +657,21 @@ namespace ImGui {
}
}
void WaterfallVFO::setOffset(float offset) {
void WaterfallVFO::setOffset(double offset) {
generalOffset = offset;
if (reference == REF_CENTER) {
centerOffset = offset;
lowerOffset = offset - (bandwidth / 2.0f);
upperOffset = offset + (bandwidth / 2.0f);
lowerOffset = offset - (bandwidth / 2.0);
upperOffset = offset + (bandwidth / 2.0);
}
else if (reference == REF_LOWER) {
lowerOffset = offset;
centerOffset = offset + (bandwidth / 2.0f);
centerOffset = offset + (bandwidth / 2.0);
upperOffset = offset + bandwidth;
}
else if (reference == REF_UPPER) {
upperOffset = offset;
centerOffset = offset - (bandwidth / 2.0f);
centerOffset = offset - (bandwidth / 2.0);
lowerOffset = offset - bandwidth;
}
centerOffsetChanged = true;
@ -677,41 +680,41 @@ namespace ImGui {
redrawRequired = true;
}
void WaterfallVFO::setCenterOffset(float offset) {
void WaterfallVFO::setCenterOffset(double offset) {
if (reference == REF_CENTER) {
generalOffset = offset;
}
else if (reference == REF_LOWER) {
generalOffset = offset - (bandwidth / 2.0f);
generalOffset = offset - (bandwidth / 2.0);
}
else if (reference == REF_UPPER) {
generalOffset = offset + (bandwidth / 2.0f);
generalOffset = offset + (bandwidth / 2.0);
}
centerOffset = offset;
lowerOffset = offset - (bandwidth / 2.0f);
upperOffset = offset + (bandwidth / 2.0f);
lowerOffset = offset - (bandwidth / 2.0);
upperOffset = offset + (bandwidth / 2.0);
centerOffsetChanged = true;
upperOffsetChanged = true;
lowerOffsetChanged = true;
redrawRequired = true;
}
void WaterfallVFO::setBandwidth(float bw) {
void WaterfallVFO::setBandwidth(double bw) {
if (bandwidth == bw || bw < 0) {
return;
}
bandwidth = bw;
if (reference == REF_CENTER) {
lowerOffset = centerOffset - (bandwidth / 2.0f);
upperOffset = centerOffset + (bandwidth / 2.0f);
lowerOffset = centerOffset - (bandwidth / 2.0);
upperOffset = centerOffset + (bandwidth / 2.0);
}
else if (reference == REF_LOWER) {
centerOffset = lowerOffset + (bandwidth / 2.0f);
centerOffset = lowerOffset + (bandwidth / 2.0);
upperOffset = lowerOffset + bandwidth;
centerOffsetChanged = true;
}
else if (reference == REF_UPPER) {
centerOffset = upperOffset - (bandwidth / 2.0f);
centerOffset = upperOffset - (bandwidth / 2.0);
lowerOffset = upperOffset - bandwidth;
centerOffsetChanged = true;
}
@ -727,11 +730,11 @@ namespace ImGui {
}
void WaterfallVFO::updateDrawingVars(float viewBandwidth, float dataWidth, float viewOffset, ImVec2 widgetPos, int fftHeight) {
float width = (bandwidth / viewBandwidth) * (float)dataWidth;
int center = roundf((((centerOffset - viewOffset) / (viewBandwidth / 2.0f)) + 1.0f) * ((float)dataWidth / 2.0f));
int left = roundf((((lowerOffset - viewOffset) / (viewBandwidth / 2.0f)) + 1.0f) * ((float)dataWidth / 2.0f));
int right = roundf((((upperOffset - viewOffset) / (viewBandwidth / 2.0f)) + 1.0f) * ((float)dataWidth / 2.0f));
void WaterfallVFO::updateDrawingVars(double viewBandwidth, float dataWidth, double viewOffset, ImVec2 widgetPos, int fftHeight) {
double width = (bandwidth / viewBandwidth) * (double)dataWidth;
int center = roundf((((centerOffset - viewOffset) / (viewBandwidth / 2.0)) + 1.0) * ((double)dataWidth / 2.0));
int left = roundf((((lowerOffset - viewOffset) / (viewBandwidth / 2.0)) + 1.0) * ((double)dataWidth / 2.0));
int right = roundf((((upperOffset - viewOffset) / (viewBandwidth / 2.0)) + 1.0) * ((double)dataWidth / 2.0));
if (left >= 0 && left < dataWidth && reference == REF_LOWER) {
lineMin = ImVec2(widgetPos.x + 50 + left, widgetPos.y + 9);

View File

@ -12,11 +12,11 @@ namespace ImGui {
class WaterfallVFO {
public:
void setOffset(float offset);
void setCenterOffset(float offset);
void setBandwidth(float bw);
void setOffset(double offset);
void setCenterOffset(double offset);
void setBandwidth(double bw);
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);
enum {
@ -26,12 +26,12 @@ namespace ImGui {
_REF_COUNT
};
float generalOffset;
float centerOffset;
float lowerOffset;
float upperOffset;
float bandwidth;
float snapInterval;
double generalOffset;
double centerOffset;
double lowerOffset;
double upperOffset;
double bandwidth;
double snapInterval = 5000;
int reference = REF_CENTER;
ImVec2 rectMin;
@ -55,17 +55,17 @@ namespace ImGui {
void updatePallette(float colors[][3], int colorCount);
void setCenterFrequency(float freq);
float getCenterFrequency();
void setCenterFrequency(double freq);
double getCenterFrequency();
void setBandwidth(float bandWidth);
float getBandwidth();
void setBandwidth(double bandWidth);
double getBandwidth();
void setViewBandwidth(float bandWidth);
float getViewBandwidth();
void setViewBandwidth(double bandWidth);
double getViewBandwidth();
void setViewOffset(float offset);
float getViewOffset();
void setViewOffset(double offset);
double getViewOffset();
void setFFTMin(float min);
float getFFTMin();
@ -79,8 +79,8 @@ namespace ImGui {
void setWaterfallMax(float max);
float getWaterfallMax();
void setZoom(float zoomLevel);
void setOffset(float zoomOffset);
void setZoom(double zoomLevel);
void setOffset(double zoomOffset);
void autoRange();
@ -157,20 +157,20 @@ namespace ImGui {
int fftHeight; // Height of the fft graph
int waterfallHeight; // Height of the waterfall
float viewBandwidth;
float viewOffset;
double viewBandwidth;
double viewOffset;
float lowerFreq;
float upperFreq;
float range;
double lowerFreq;
double upperFreq;
double range;
float lastDrag;
int vfoRef = REF_CENTER;
// Absolute values
float centerFreq;
float wholeBandwidth;
double centerFreq;
double wholeBandwidth;
// Ranges
float fftMin;

View File

@ -19,7 +19,7 @@ namespace io {
std::string name;
int index;
int channels;
std::vector<float> sampleRates;
std::vector<double> sampleRates;
std::string txtSampleRates;
};
@ -323,7 +323,7 @@ namespace io {
return 0;
}
float POSSIBLE_SAMP_RATE[6] = {
double POSSIBLE_SAMP_RATE[6] = {
48000.0f,
44100.0f,
24000.0f,
@ -336,7 +336,7 @@ namespace io {
int devIndex;
int devListIndex;
int defaultDev;
float _sampleRate;
double _sampleRate;
int _bufferSize;
dsp::stream<float>* _monoInput;
dsp::stream<dsp::StereoFloat_t>* _stereoInput;

View File

@ -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;

View File

@ -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();
};

View File

@ -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;
}

View File

@ -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;
};

View File

@ -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;
}

View File

@ -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);

View File

@ -3,7 +3,7 @@
"bandPlan": "General",
"bandPlanEnabled": true,
"fftHeight": 300,
"frequency": 96035792,
"frequency": 94930000,
"max": 0.0,
"maximized": false,
"menuOrder": [