How to create volume meter for input volume and output volume


How do I create a simple volume meter for my distortion plugin, it doesn’t need independent input and out meters displayed on either side of the plugin. If you know how to do this for a vst plugin please explain where all the code goes because I am still getting the hang of c++ and juce.



In your audio processor you’ll want to have two values to hold the current input and output values. Set the value of the currentInput variable before any signal processing in the processBlock method, and set the value of the currentOutput variable after any signal processing in the processBlock method.

In your editor, have a timer that repeatedly queries the processor the the most recent input and output samples and use these values to draw rectangles.


I created a module to do exactly that: have a LevelMeterSource in the processor and a LevelMeter Component in the editor:

Either to use it out of the box or to get inspiration how to do that…

Hope that helps…


okay thanks i think that will work well, how do i include this in my project?


Glad you like it, just add it in the Projucer in the modules section “Module from specific folder”. It will be automatically included in the JuceHeader.h, so you don’t have to add any code for that.

To use it refer to the code in the readme… Let me know, when you need something


hello, sorry for the late reply, it now shows this error when the folder with the files on the right you provided are added to the modules


It should work if you just select the folder rather than the file…
Does that work better?

Oh, and I see you renamed the folder. AFAIK juce assumes the folder to be the same name as the header file, where the definition is in, i.e. ff_meters in this case…


i just left the folder named that as it is what was extracted from the zip. once renamed i could add. from reading the readme im already stuck on this first instruction, how can i “create a LevelMeterSource instance next to the AudioBuffer you want to

Thanks for the help


Just like the example says, add the line:

FFAU::LevelMeterSource meterSource;

in the private section to add a member variable acting as meter source. You can also save the getter and just have it public, depending how strict with OO-principles you are.
If you want to measure input and output, create two meter sources.

Does that help?


okay all the code seems to be fine except those that refers that meter source, i read in the documentation, “On the Component use LevelMeter::setMeterSource to link to the LevelMeterSource instance”. Where does “on the component” refer to? which part of which file does it go. thanks


The FFAU::LevelMeter is a Component, that you place in your editor, like any other component. It will automatically start to show the level, that is measured in the levelMeterSource, once you connected them.
It is done that way, because the GUI elements need to live in the editor, and the code, that does the work, needs to be in the processor.

Hope that helps


okay think i get it, So if i have all the code as shown in the document you provided, i do not need “LevelMeter::setMeterSource”. if so, how can i position the meter?


What do you mean by position? The position of the Component you set in the resized(). The position, if you measure input or output, is determined, if you call meterSource.measureBlock before or after your processing.
You have to call setMeterSource, otherwise the component will not know, what to display…

The meterSource is stateful, so if you want to measure both, you need two separate meterSources. Each measures all channels though…


Okay by position i mean where on the gui it is, meter->resized(100, 100, 50, (getHeight()/8)*6); seems to come up with errors.
and where do I put setMeterSource(); then? in the process block?
is LevelMeterSource::measureBlock(buffer); also in the process block loop? that is where i gathered you put both, however they both come up with red underlines.


In the editor’s resized() callback you call meter-setBounds (100, 100, 50, (getHeight()/8)*6)

It is a method of the Component, the FFAU::LevelMeter, so you cannot call it before the Editors constructor, which is the right place, like you see in the readme file:

TutorialPluginAudioProcessorEditor::TutorialPluginAudioProcessorEditor (TutorialPluginAudioProcessor& p)
    : AudioProcessorEditor (&p), processor (p)
    lnf = new FFAU::LevelMeterLookAndFeel();

    meter = new FFAU::LevelMeter (); // See FFAU::LevelMeter::MeterFlags for options
    meter->setLookAndFeel (lnf);
    meter->setMeterSource (processor.getMeterSource());
    addAndMakeVisible (meter);

    // This is where our plugin’s editor size is set.
    setSize (200, 200);

Sorry, I wrote it with namespace to give context. But it is not a static function, so you call it like shown in the readme:

void processBlock (AudioSampleBuffer& buffer, MidiBuffer&) override
    meterSource.measureBlock (buffer);
    // ...

Hope that helps


okay yeahh that makes sense, only problem when i load the program nothing is displayed. i dont see any errors but i have this code in the editor


my 2 cents but if you don’t call setBounds in resized callback and your editor has no size set yet, then getHeight returns 0.


meter->resized(setBounds(100, 100, 50, ((getHeight() / 8) * 6)-100)); gives me an error, how do i fix this then?


Sorry, I thought you had a little knowledge about the JUCE API already. A look at the tutorials is always something that pays out…

The resized is a callback, that the OS / parent component is calling, when the size is changing. You override this callback with your own implementation to define e.g. how to arrange the sub components (like the meter in your case):

void resized() override
    meter->setBounds (100, 100, 50, ((getHeight() / 8) * 6)-100));

And an extra note: next time please write down the error, we can’t see your screen…