How to create volume meter for input volume and output volume

I’m afraid you have some basic C++ struggles, that I cannot fix without having more context. If you comment that lines out, does it compile?
If so, please share the snippet, how and where you added the the code.

yes, when it is made a comment the code builds.

So in this snippet alone you defined void resized() override; twice. It should be legit, since the first would only act as a forward declaration, but it is still useless.
And most likely, there is another implementation in your cpp as well, from there it is no longer legit.
Can you show, how meter is defined? And where?

Also you can just copy the code and have a single line with ``` before and after, so you don’t need to make a screenshot each time (and people can copy/paste your code as well)…

You haven’t balanced your brackets on line 63…
I think you need an extra ( before getHeight():

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

@DigitalTek: and that as well… thanks @Im_Jimmi, that error was in my snippet as well…

1 Like

alright so i removed that first resized overrite, and now meter is underlined red.
private: ScopedPointer<FFAU::LevelMeterLookAndFeel> lnf; ScopedPointer<FFAU::LevelMeter> meter;
(in the editor.h)

NewProjectAudioProcessorEditor::NewProjectAudioProcessorEditor (NewProjectAudioProcessor& p)
    : AudioProcessorEditor (&p), processor (p)
{
lnf = new FFAU::LevelMeterLookAndFeel();
	// adjust the colours to how you like them
	lnf->setColour(FFAU::LevelMeter::lmMeterGradientLowColour, juce::Colours::green);
	meter = new FFAU::LevelMeter(); // See FFAU::LevelMeter::MeterFlags for options
	meter->setLookAndFeel(lnf);
	meter->setMeterSource(processor.getMeterSource());
	meter->resized();
	
	addAndMakeVisible(meter);

(in the editor.cpp)

public:
FFAU::LevelMeterSource* getMeterSource()
	{
		return &meterSource;
	}

	FFAU::LevelMeterSource meterSource;

(in processor.h)

meterSource.measureBlock(buffer);
in process block

it builds now, i found out what the issue with another resized overrite elsewhere. and the bracket thing helped show where this issue was. ill get back to you later to see if it all works. thanks for the help

I’m not following the whole post in detail, but this line

shows that you should have a look at some basic JUCE GUI coding principles before trying to get this meter working. I would suggest to just put this project aside for a moment, then start with a fresh project and follow this tutorial to get an idea how all of this stuff like resize is intended to work. If you really understood every line of code in the tutorial you are likely to be ready to solve most of your current struggles yourself I think :wink:

2 Likes

No build errors but i get a critical error in the program now and the debugger gives me this error. tried removing the resized statement and that but it still happens

Your this pointer doesn’t look right. Try to step one level up and inspect the values there.


it seems to trigger these lines of code up to “wasResized”
is this off help?

another image of the errors
not sure what i changed, the program now loads but the meter and the rest of the program doesnt function correctly. the meter is the correct size but also doesnt look correct

everything except the meter seems to work now (havent changed anything so im not sure why)
this is what the program looks like with the meter on the left
image

Are you using Git? If not, start using it - going back in the history of commits and comparing file changes can often help you find the origin for issues like this.

2 Likes

ive had a look with it before but arent really sure what im doing so ill have annother look

sorted it out, i think the meter was too thin

1 Like

Hi,

First of all, thank you for your sources, they are very helpful.
I wanted to know if there are any examples, other than the one you posted on github, for further use: like getting a text for meter value, adding scales bars etc…

scale bars are automaticly shown and can be changed in settings with the meter flags

Hi
daniel, thanks a lot for that piece of code.
I did use it and looks pretty nice
BUT
I get the indication earlier than I hear it. I suppose that this is caused because we first process our buffer and get the rms level and then, later, DAW gets it and plays it.
Does anyone else has the same problem ??
How would it be possible to find the latency of this procedure ??

Thanks for using it, I’m glad you like it.

That sounds, like there is really a long latency going on. Normally this shouldn’t be noticeable. Can you tell us, which host you are using? Is this in a plugin or in an App?

I did experience on Android (especially my Galaxy Note3) hilariously long buffer sizes, but apart from that, I never saw anything like that.