Fixed setFFTSize visual bug

This commit is contained in:
Ryzerth 2021-07-28 22:53:38 +02:00
parent 0741f265d7
commit e744520d50

View File

@ -520,7 +520,7 @@ namespace ImGui {
float pixel; float pixel;
float dataRange = waterfallMax - waterfallMin; float dataRange = waterfallMax - waterfallMin;
int count = std::min<float>(waterfallHeight, fftLines); int count = std::min<float>(waterfallHeight, fftLines);
if (rawFFTs != NULL) { if (rawFFTs != NULL && fftLines >= 0) {
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
drawDataSize = (viewBandwidth / wholeBandwidth) * rawFFTSize; drawDataSize = (viewBandwidth / wholeBandwidth) * rawFFTSize;
drawDataStart = (((double)rawFFTSize / 2.0) * (offsetRatio + 1)) - (drawDataSize / 2); drawDataStart = (((double)rawFFTSize / 2.0) * (offsetRatio + 1)) - (drawDataSize / 2);
@ -530,6 +530,12 @@ namespace ImGui {
waterfallFb[(i * dataWidth) + j] = waterfallPallet[(int)(pixel * (WATERFALL_RESOLUTION - 1))]; waterfallFb[(i * dataWidth) + j] = waterfallPallet[(int)(pixel * (WATERFALL_RESOLUTION - 1))];
} }
} }
for (int i = count; i < waterfallHeight; i++) {
for (int j = 0; j < dataWidth; j++) {
waterfallFb[(i * dataWidth) + j] = (uint32_t)255 << 24;
}
}
} }
delete[] tempData; delete[] tempData;
waterfallUpdate = true; waterfallUpdate = true;
@ -1028,15 +1034,16 @@ namespace ImGui {
void WaterFall::setRawFFTSize(int size, bool lock) { void WaterFall::setRawFFTSize(int size, bool lock) {
std::lock_guard<std::mutex> lck(buf_mtx); std::lock_guard<std::mutex> lck(buf_mtx);
rawFFTSize = size; rawFFTSize = size;
if (rawFFTs != NULL) {
int wfSize = std::max<int>(1, waterfallHeight); int wfSize = std::max<int>(1, waterfallHeight);
if (rawFFTs != NULL) {
rawFFTs = (float*)realloc(rawFFTs, rawFFTSize * wfSize * sizeof(float)); rawFFTs = (float*)realloc(rawFFTs, rawFFTSize * wfSize * sizeof(float));
} }
else { else {
int wfSize = std::max<int>(1, waterfallHeight);
rawFFTs = (float*)malloc(rawFFTSize * wfSize * sizeof(float)); rawFFTs = (float*)malloc(rawFFTSize * wfSize * sizeof(float));
} }
fftLines = 0;
memset(rawFFTs, 0, rawFFTSize * waterfallHeight * sizeof(float)); memset(rawFFTs, 0, rawFFTSize * waterfallHeight * sizeof(float));
updateWaterfallFb();
} }
void WaterFall::setBandPlanPos(int pos) { void WaterFall::setBandPlanPos(int pos) {