fix various AudioFileProcessor bugs (#7533)

* fix out-of-bounds crash in AudioFileProcessor

by correctly setting m_from and m_to without them interfering with each other

* fixed flattened wave caused by inaccurate math

see PR for before/after

* simply stop drawing AFP waveform when there's no more data

this fixes the single point at the end of waveforms that sometimes shows up

* fixed seemingly insignificant type confusion (?)

execution seemed fine but my debugger started freaking out,
and if gdb is telling me I got a negative-sized vector,
I'd rather fix this issue than speculate "it's probably fine"

* fixed data offset for AFP waveform vis

the data itself isn't reversed, so we have to account for that
This commit is contained in:
Lisa Magdalena Riedler
2024-10-06 11:26:57 +02:00
committed by GitHub
parent e0ae8a1cec
commit 0363ee6d16
2 changed files with 10 additions and 9 deletions

View File

@@ -44,12 +44,12 @@ void SampleWaveform::visualize(Parameters parameters, QPainter& painter, const Q
const float resolution = std::max(1.0f, framesPerPixel / maxFramesPerPixel);
const float framesPerResolution = framesPerPixel / resolution;
const size_t numPixels = std::min<size_t>(parameters.size, width);
size_t numPixels = std::min(parameters.size, static_cast<size_t>(width));
auto min = std::vector<float>(numPixels, 1);
auto max = std::vector<float>(numPixels, -1);
auto squared = std::vector<float>(numPixels, 0);
const size_t maxFrames = numPixels * static_cast<size_t>(framesPerPixel);
const size_t maxFrames = static_cast<size_t>(numPixels * framesPerPixel);
auto pixelIndex = std::size_t{0};
@@ -67,12 +67,9 @@ void SampleWaveform::visualize(Parameters parameters, QPainter& painter, const Q
squared[pixelIndex] += value * value;
}
while (pixelIndex < numPixels)
if (pixelIndex < numPixels)
{
max[pixelIndex] = 0.0;
min[pixelIndex] = 0.0;
pixelIndex++;
numPixels = pixelIndex;
}
for (auto i = std::size_t{0}; i < numPixels; i++)