mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
SimpleFFTDemo: Use BitmapData to improve performance when modifying pixel colours
This commit is contained in:
parent
1e5c88899e
commit
f78841e0d9
1 changed files with 3 additions and 1 deletions
|
|
@ -164,13 +164,15 @@ public:
|
|||
// show up the detail clearly
|
||||
auto maxLevel = FloatVectorOperations::findMinAndMax (fftData, fftSize / 2);
|
||||
|
||||
Image::BitmapData bitmap { spectrogramImage, rightHandEdge, 0, 1, imageHeight, Image::BitmapData::writeOnly };
|
||||
|
||||
for (auto y = 1; y < imageHeight; ++y)
|
||||
{
|
||||
auto skewedProportionY = 1.0f - std::exp (std::log ((float) y / (float) imageHeight) * 0.2f);
|
||||
auto fftDataIndex = jlimit (0, fftSize / 2, (int) (skewedProportionY * (int) fftSize / 2));
|
||||
auto level = jmap (fftData[fftDataIndex], 0.0f, jmax (maxLevel.getEnd(), 1e-5f), 0.0f, 1.0f);
|
||||
|
||||
spectrogramImage.setPixelAt (rightHandEdge, y, Colour::fromHSV (level, 1.0f, level, 1.0f));
|
||||
bitmap.setPixelColour (0, y, Colour::fromHSV (level, 1.0f, level, 1.0f));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue