Print float value


I am new to juce and I have a question.
I am building an audio plugin with Juce and I computed a float value in the process block.
What I want now is to print it on the GUI, instead of the ‘Hello World’ message.

I tried to use the variable in the process editor:
g.drawFittedText (String(valueLevelLeft), getLocalBounds(), Justification::centred, 1);

But it doesn’t see my variable ‘valueLevelLeft’, which I defined in the PluginProcessor header and used in the PluginProcessor.cpp. (error message: Use of undeclared identifier ‘valueLevelLeft’)

How can I pass this variable from the processor to the editor?

You can do :

But couple of additional things :

  • The valueLevelLeft should be an atomic variable to avoid wrong behaviors which might happen due to compiler optimizations and the multiple threads involved. (Use std::atomic<float> instead of just float.)
  • The GUI will not repaint itself automatically, you will need to inherit your plugin editor from Timer too and implement the timerCallback method, which should call repaint().

Thank you so much!

I have one more question (sorry if it sounds stupid, I am trying to learn).
I inherited Timer and implemented timerCallback in the Editor.h:

class TrialAudioProcessorEditor : public AudioProcessorEditor, public Timer
public :

TrialAudioProcessorEditor (TrialAudioProcessor&);

void timerCallback() override ;

void paint (Graphics&) override ;

void resized() override ;
… }

Now in the Editor.cpp I did this:

TrialAudioProcessorEditor::TrialAudioProcessorEditor (TrialAudioProcessor& p)
: AudioProcessorEditor (&p), processor §


void timerCallback() override {

void TrialAudioProcessorEditor::paint (Graphics& g) override
{. ….
g.drawFittedText (String(processor.valueLevelLeft), getLocalBounds(), Justification::centred, 1);

void TrialAudioProcessorEditor::resized()

I get the error: Expected function body after function declarator for ‘‘void timerCallback() override’’.

Could you tell me what am I doing wrong?

Thank you and sorry for spamming :slight_smile:

That is, because in the implementation you need to add it to the namespace, and furthermore the override keyword is only allowed in a declaration, not in the cpp file.

Last but not least, please add three backticks before and after your code, otherwise the forum might remove symbols, like e.g. angle brackets

    int main()
        return 0;

P.S., using the pen symbol you can edit your posts, no need to post it again