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 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
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.
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.
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
// 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:
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):