How to create volume meter for input volume and output volume

You are using the ff_meters?

There are three steps necessary:

  • connect the meters to the source:
    meterComponent.setMeterSource (meterSource);
  • Set the appropriate size in prepareToPlay
    meterSource->resize (numChannels, 0.05 * sampleRate / blockSize);
  • feed the meterSource
// in processBlock:
meterSource->measureAudio (buffer);

// or in getNextAudioBlock:
juce::AudioBuffer<float> proxy (bufferToFill.buffer->getArrayOfReadPointers(),
                                bufferToFill.buffer->getNumChannels(),
                                bufferToFill.startSample,
                                bufferToFill.numSamples);
meterSource->measureAudio (proxy);

My hunch is that the resize() call in prepareToPlay is missing, but I cannot know.
Hope that helps

@daniel

First, thanks for ff_meters! I added the module in the Projucer but I am having an odd problem compiling.

When I build the VST it works just fine. However if I try to build the standalone .exe I’m getting these errors:

ff_meters\levelmeter\levelmeter.h(54): error C2039: 'juce': is not a member of 'juce'
2>c:\juce\modules\juce_audio_formats\codecs\juce_windowsmediaaudioformat.h(26): note: see declaration of 'juce'
ff_meters\levelmeter\levelmeter.h(54): error C3083: 'juce': the symbol to the left of a '::' must be a type
ff_meters\visualisers\stereofieldcomponent.h(53): error C2039: 'juce': is not a member of 'juce'
2>c:\juce\modules\juce_audio_formats\codecs\juce_windowsmediaaudioformat.h(26): note: see declaration of 'juce'
\ff_meters\visualisers\stereofieldcomponent.h(53): error C3083: 'juce': the symbol to the left of a '::' must be a type

Any idea how to solve this?

Hi @daniel

I have tried to use this meter code for a compressor Plug-In that I’m starting. I have set everything as the description on Github says but I have so many errors on the LevelMeter.h and .cpp files when I run my code, which I think are related to missing namespaces.

For example in this line:

 onMaxLevelClicked = [](FFAU::LevelMeter& meter, [[maybe_unused]] int channel, [[maybe_unused]] juce::ModifierKeys mods)
    {

My compiler doesn’t know what FFAU is, but I don’t know what I need to add to this code.

Also in LevelMeter.cpp the next line throws an error:

        lmLookAndFeel = fallbackLookAndFeel.get();

The error says that “=” cannot convert from LevelMeterLookAndFeel to LookAndFeelMethods.

Please, someone who has used this module can tell me what needs to be added to the
type or paste code here

Hi @RaulPulsar,

Sorry for the hickup. At some point in the last 7 years I made my namespaces consistent, so I use now namespace foleys instead of namespace FFAU.

Check out the readme on the original address:

Let me know if that helps.