diff --git a/currentGitHash.txt b/currentGitHash.txt index cb5c114729..efaa1380ac 100644 --- a/currentGitHash.txt +++ b/currentGitHash.txt @@ -1 +1 @@ -30ce85b09b2317bee09226450daf778890865c2e +17b70d15a0da32ce1c6ce7c61dcf8b9c73fcaca4 diff --git a/hi_backend/backend/currentGit.h b/hi_backend/backend/currentGit.h index e7f8681543..83528bf19e 100644 --- a/hi_backend/backend/currentGit.h +++ b/hi_backend/backend/currentGit.h @@ -1 +1 @@ -#define PREVIOUS_HISE_COMMIT "30ce85b09b2317bee09226450daf778890865c2e" +#define PREVIOUS_HISE_COMMIT "17b70d15a0da32ce1c6ce7c61dcf8b9c73fcaca4" diff --git a/hi_scripting/scripting/api/ScriptingApiObjects.cpp b/hi_scripting/scripting/api/ScriptingApiObjects.cpp index 25db992b9f..c2a4211624 100644 --- a/hi_scripting/scripting/api/ScriptingApiObjects.cpp +++ b/hi_scripting/scripting/api/ScriptingApiObjects.cpp @@ -7489,6 +7489,7 @@ var ScriptingObjects::ScriptFFT::process(var dataToProcess) Spectrum2D fb(this, fullBuffer); fb.parameters = spectrumParameters; + fb.useAlphaChannel = false; auto b = fb.createSpectrumBuffer(); if (b.getNumSamples() > 0) diff --git a/hi_tools/hi_tools/MiscToolClasses.cpp b/hi_tools/hi_tools/MiscToolClasses.cpp index 5735b32d98..539bf07e9a 100644 --- a/hi_tools/hi_tools/MiscToolClasses.cpp +++ b/hi_tools/hi_tools/MiscToolClasses.cpp @@ -2445,7 +2445,7 @@ float FFTHelpers::getPixelValueForLogXAxis(float freq, float width) return (width - 5) * (log(freq / lowFreq) / log(highFreq / lowFreq)) + 2.5f; } -juce::PixelRGB Spectrum2D::LookupTable::getColouredPixel(float normalisedInput) +juce::PixelARGB Spectrum2D::LookupTable::getColouredPixel(float normalisedInput, bool useAlphaValue) { auto lutValue = data[jlimit(0, LookupTableSize - 1, roundToInt(normalisedInput * (float)LookupTableSize))]; float a = JUCE_LIVE_CONSTANT_OFF(0.3f); @@ -2453,10 +2453,8 @@ juce::PixelRGB Spectrum2D::LookupTable::getColouredPixel(float normalisedInput) auto r = (float)lutValue.getRed() * v; auto g = (float)lutValue.getGreen() * v; auto b = (float)lutValue.getBlue() * v; - - PixelRGB returnValue; - returnValue.setARGB(255, (uint8)r, (uint8)g, (uint8)b); - return returnValue; + + return PixelARGB(useAlphaValue ? jmax(r, g, b) : 255, (uint8)r, (uint8)g, (uint8)b); } void Spectrum2D::LookupTable::setColourScheme(ColourScheme cs) @@ -2520,7 +2518,7 @@ Image Spectrum2D::createSpectrumImage(AudioSampleBuffer& lastBuffer) { TRACE_EVENT("scripting", "create spectrum image"); - auto newImage = Image(useAlphaChannel ? Image::ARGB : Image::RGB, lastBuffer.getNumSamples(), lastBuffer.getNumChannels(), true); + auto newImage = Image(Image::ARGB, lastBuffer.getNumSamples(), lastBuffer.getNumChannels(), true); Image::BitmapData bd(newImage, Image::BitmapData::writeOnly); @@ -2530,49 +2528,12 @@ Image Spectrum2D::createSpectrumImage(AudioSampleBuffer& lastBuffer) for(int x = 0; x < lastBuffer.getNumSamples(); x++) { - auto lutValue = parameters->lut->getColouredPixel(src[x]); - - if(useAlphaChannel) - { - auto r = lutValue.getRed(); - auto g = lutValue.getGreen(); - auto b = lutValue.getBlue(); - auto a = jmax(r, g, b); - - auto pp = (PixelARGB*)(bd.getPixelPointer(x, y)); - pp->set(PixelARGB(a, r, g, b)); - } - else - { - auto pp = (PixelRGB*)(bd.getPixelPointer(x, y)); - pp->set(lutValue); - } - + auto lutValue = parameters->lut->getColouredPixel(src[x], useAlphaChannel); + auto pp = (PixelARGB*)(bd.getPixelPointer(x, y)); + pp->set(lutValue); } } -#if 0 - for (int x = 0; x < s2dHalf; x++) - { - auto skewedProportionY = holder->getYPosition((float)x / (float)s2dHalf); - auto fftDataIndex = jlimit(0, s2dHalf-1, (int)(skewedProportionY * (int)s2dHalf)); - - for (int i = 0; i < lastBuffer.getNumSamples(); i++) - { - auto s = lastBuffer.getSample(fftDataIndex, i); - s *= (1.0f / gf); - - auto alpha = jlimit(0.0f, 1.0f, s); - - alpha = holder->getXPosition(alpha); - alpha = std::pow(alpha, parameters->gamma); - - auto lutValue = parameters->lut->getColouredPixel(alpha); - newImage.setPixelAt(x, i, lutValue); - } - } -#endif - return newImage; } @@ -2944,7 +2905,7 @@ void Spectrum2D::Parameters::Editor::paint(Graphics& g) for (int i = 0; i < specArea.getWidth(); i+= 2) { auto ninput = (float)i / (float)specArea.getWidth(); - auto p = param->lut->getColouredPixel(ninput); + auto p = param->lut->getColouredPixel(ninput, true); Colour c(p.getNativeARGB()); g.setColour(c); diff --git a/hi_tools/hi_tools/MiscToolClasses.h b/hi_tools/hi_tools/MiscToolClasses.h index b028731e94..3410bca4ca 100644 --- a/hi_tools/hi_tools/MiscToolClasses.h +++ b/hi_tools/hi_tools/MiscToolClasses.h @@ -2229,7 +2229,7 @@ struct Spectrum2D static constexpr int LookupTableSize = 512; - PixelRGB getColouredPixel(float normalisedInput); + PixelARGB getColouredPixel(float normalisedInput, bool useAlphaValue); LookupTable();