Suspecting level meter's bad performances on logic pro

Hello,

I’m currently developing a plugin using level meters from PGM.

Since I wanted it to react differntly (just changing his alpha depending on the signal level) I wrote my own customLevelMeter

#include "custom_foleys_MagicLevelMeter.h"

    CustomLevelMeter::CustomLevelMeter()
{
    setColour (backgroundColourId, juce::Colours::transparentBlack);
    setColour (barBackgroundColourId, juce::Colours::darkgrey);
    setColour (barFillColourId, juce::Colours::darkgreen);
    setColour (outlineColourId, juce::Colours::silver);
    setColour (tickmarkColourId, juce::Colours::silver);
    startTimerHz (20);
}

void CustomLevelMeter::paint(juce::Graphics& g)
{
    if (auto* lnf = dynamic_cast<LookAndFeelMethods*>(&getLookAndFeel()))
    {
        lnf->drawLevelMeter(g, *this, source, getLocalBounds());
        return;
    }

    const auto backgroundColour = findColour(backgroundColourId);
    if (!backgroundColour.isTransparent())
        g.fillAll(backgroundColour);

    if (source == nullptr)
        return;

    const auto numChannels = source->getNumChannels();
    if (numChannels == 0)
        return;

    auto bounds = getLocalBounds().reduced(3).toFloat();

    const auto width = bounds.getWidth() / numChannels;
    const auto barBackgroundColour = findColour(barBackgroundColourId);
    const auto barFillColour = findColour(barFillColourId);
    const auto outlineColour = findColour(outlineColourId);

    const auto infinity = -100.0f;
    for (int i = 0; i < numChannels; ++i)
    {
        auto bar = bounds.removeFromLeft(width).reduced(1);
        float ff = 2.0 * source->getRMSvalue(i);
        if (ff > 1.0)
        {
            ff = 1.0;
        }
        g.setColour(barBackgroundColour.withAlpha(ff));
        g.fillRect(bar);
    }
}

void CustomLevelMeter::setLevelSource (foleys::MagicLevelSource* newSource)
{
    source = newSource;
}

void CustomLevelMeter::timerCallback()
{
    repaint();
}

It works perfeclty on evry DAW excepted logic pro when running on intel CPU, in this case the CPU load become insane as soon as the user press play in the DAW.
(and I think it would happen with the original level meter from PGM too)

From what I read I also wonder if this part can slow down the GUI loading, I’ll investigate:

 if (auto* lnf = dynamic_cast<LookAndFeelMethods*>(&getLookAndFeel()))
    {
        lnf->drawLevelMeter(g, *this, source, getLocalBounds());
        return;
    }

Thank you for your answers :slight_smile:

I’ve write a custom level meter and custom levelSource not using the rms/max calculation and it works like a charm. Maybe it mcomes from that part but it only occurs on intel mac running logic (at least on one of the plugin’s testers machine) and am not sure if it will happens on evry mac OS.