mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-01-24 00:34:44 +01:00
move zoom waterfall's zoom function in the cpp file to avoid annoying recomps
This commit is contained in:
parent
118e56897c
commit
97c1a132a5
@ -62,6 +62,33 @@ inline void printAndScale(double freq, char* buf) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void doZoom(int offset, int width, int inSize, int outSize, float* in, float* out) {
|
||||||
|
// NOTE: REMOVE THAT SHIT, IT'S JUST A HACKY FIX
|
||||||
|
if (offset < 0) {
|
||||||
|
offset = 0;
|
||||||
|
}
|
||||||
|
if (width > 524288) {
|
||||||
|
width = 524288;
|
||||||
|
}
|
||||||
|
|
||||||
|
float factor = (float)width / (float)outSize;
|
||||||
|
float sFactor = ceilf(factor);
|
||||||
|
float uFactor;
|
||||||
|
float id = offset;
|
||||||
|
float maxVal;
|
||||||
|
int sId;
|
||||||
|
for (int i = 0; i < outSize; i++) {
|
||||||
|
maxVal = -INFINITY;
|
||||||
|
sId = (int)id;
|
||||||
|
uFactor = (sId + sFactor > inSize) ? sFactor - ((sId + sFactor) - inSize) : sFactor;
|
||||||
|
for (int j = 0; j < uFactor; j++) {
|
||||||
|
if (in[sId + j] > maxVal) { maxVal = in[sId + j]; }
|
||||||
|
}
|
||||||
|
out[i] = maxVal;
|
||||||
|
id += factor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace ImGui {
|
namespace ImGui {
|
||||||
WaterFall::WaterFall() {
|
WaterFall::WaterFall() {
|
||||||
fftMin = -70.0;
|
fftMin = -70.0;
|
||||||
@ -586,7 +613,7 @@ namespace ImGui {
|
|||||||
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);
|
||||||
doZoom(drawDataStart, drawDataSize, dataWidth, &rawFFTs[((i + currentFFTLine) % waterfallHeight) * rawFFTSize], tempData);
|
doZoom(drawDataStart, drawDataSize, rawFFTSize, dataWidth, &rawFFTs[((i + currentFFTLine) % waterfallHeight) * rawFFTSize], 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;
|
||||||
waterfallFb[(i * dataWidth) + j] = waterfallPallet[(int)(pixel * (WATERFALL_RESOLUTION - 1))];
|
waterfallFb[(i * dataWidth) + j] = waterfallPallet[(int)(pixel * (WATERFALL_RESOLUTION - 1))];
|
||||||
@ -867,7 +894,7 @@ namespace ImGui {
|
|||||||
int drawDataStart = (((double)rawFFTSize / 2.0) * (offsetRatio + 1)) - (drawDataSize / 2);
|
int drawDataStart = (((double)rawFFTSize / 2.0) * (offsetRatio + 1)) - (drawDataSize / 2);
|
||||||
|
|
||||||
if (waterfallVisible) {
|
if (waterfallVisible) {
|
||||||
doZoom(drawDataStart, drawDataSize, dataWidth, &rawFFTs[currentFFTLine * rawFFTSize], latestFFT);
|
doZoom(drawDataStart, drawDataSize, rawFFTSize, dataWidth, &rawFFTs[currentFFTLine * rawFFTSize], latestFFT);
|
||||||
memmove(&waterfallFb[dataWidth], waterfallFb, dataWidth * (waterfallHeight - 1) * sizeof(uint32_t));
|
memmove(&waterfallFb[dataWidth], waterfallFb, dataWidth * (waterfallHeight - 1) * sizeof(uint32_t));
|
||||||
float pixel;
|
float pixel;
|
||||||
float dataRange = waterfallMax - waterfallMin;
|
float dataRange = waterfallMax - waterfallMin;
|
||||||
@ -879,7 +906,7 @@ namespace ImGui {
|
|||||||
waterfallUpdate = true;
|
waterfallUpdate = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
doZoom(drawDataStart, drawDataSize, dataWidth, rawFFTs, latestFFT);
|
doZoom(drawDataStart, drawDataSize, rawFFTSize, dataWidth, rawFFTs, latestFFT);
|
||||||
fftLines = 1;
|
fftLines = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,33 +90,6 @@ namespace ImGui {
|
|||||||
float* getFFTBuffer();
|
float* getFFTBuffer();
|
||||||
void pushFFT();
|
void pushFFT();
|
||||||
|
|
||||||
inline void doZoom(int offset, int width, int outWidth, float* data, float* out) {
|
|
||||||
// NOTE: REMOVE THAT SHIT, IT'S JUST A HACKY FIX
|
|
||||||
if (offset < 0) {
|
|
||||||
offset = 0;
|
|
||||||
}
|
|
||||||
if (width > 524288) {
|
|
||||||
width = 524288;
|
|
||||||
}
|
|
||||||
|
|
||||||
float factor = (float)width / (float)outWidth;
|
|
||||||
float sFactor = ceilf(factor);
|
|
||||||
float uFactor;
|
|
||||||
float id = offset;
|
|
||||||
float maxVal;
|
|
||||||
int sId;
|
|
||||||
for (int i = 0; i < outWidth; i++) {
|
|
||||||
maxVal = -INFINITY;
|
|
||||||
sId = (int)id;
|
|
||||||
uFactor = (sId + sFactor > rawFFTSize) ? sFactor - ((sId + sFactor) - rawFFTSize) : sFactor;
|
|
||||||
for (int j = 0; j < uFactor; j++) {
|
|
||||||
if (data[sId + j] > maxVal) { maxVal = data[sId + j]; }
|
|
||||||
}
|
|
||||||
out[i] = maxVal;
|
|
||||||
id += factor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void updatePallette(float colors[][3], int colorCount);
|
void updatePallette(float colors[][3], int colorCount);
|
||||||
void updatePalletteFromArray(float* colors, int colorCount);
|
void updatePalletteFromArray(float* colors, int colorCount);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user