GPT-chat and JUCE

Just an FYI for people who were thinking of posting a JUCE question here: you might get a quicker (and maybe even better) answer by asking instead.

For example, I asked it:

How do I create an animated level meter in JUCE?

and got:

To create an animated level meter in JUCE, you can use the juce::MeterComponent class, which provides a customizable level meter that can be animated. To use it, you’ll need to include the appropriate headers and create an instance of the MeterComponent class. Then, you can use the setMeterLevel method to set the level of the meter and the setPeakHoldEnabled method to enable peak hold, which will show the highest level reached by the meter.

Here’s an example of how you might use the MeterComponent class to create an animated level meter:

#include <JuceHeader.h>

class MyLevelMeter : public juce::MeterComponent
        // Enable peak hold and set the meter level to 0.5.
        setPeakHoldEnabled (true);
        setMeterLevel (0.5);

        // Set the number of LED lights to 10 and the width of the meter to 300 pixels.
        setNumLights (10);
        setSize (300, 20);

You can then add your MyLevelMeter component to your JUCE application and use it like any other component. To animate the level meter, you can update the meter level in regular intervals, for example by using a juce::Timer object to call the setMeterLevel method at regular intervals.

I hope this helps! Let me know if you have any other questions.

Not bad.

Then I asked:

Explain how a juce::Component works, in the style of a 1940s mobster

and it replied:

Sure, here’s how I might explain a juce::Component in the style of a 1940s mobster:

"See, kid, a juce::Component is like the boss of a user interface. It’s got all the power and control over what’s displayed on the screen.

You wanna create a button or a text box or some other fancy widget? You gotta go through the juce::Component to make it happen. It’s the one in charge of positioning and sizing those widgets, and it’s the one that tells 'em what to do when a mouse clicks on 'em or a keyboard key gets pressed.

Now, you might be thinking, “Hey, this juce::Component sounds like a real tough guy.” And you’re right, kid, it is. But it’s also a fair boss. It lets other juce::Component objects join its crew and work together to create a user interface that’s smooth and stylish.

So, bottom line, if you wanna make a user interface that’s the bees knees, you gotta pay your respects to the juce::Component. It’s the boss, kid, and you don’t want to mess with the boss."


Guess the juce team has to make that MeterComponent now


And don’t forget:

“You gotta pay your respects to the juce::Component. It’s the boss!” :laughing:


We’re far beyond the uncanny valley already. At some point in the future all content written in English will be discredited as basically untrustworthy, as more than 50% of it will have been fabricated by A.I. Professional copywriters already use it en masse to generate first drafts.

I guess around 2050 or so, humans will have to invent new forms of communication that A.I. is unable to deal with, or else …


I asked ChatGPT to write that juce::MeterComponent class, thats what I got:

Please write the juce::MeterComponent class for the JUCE C++ framework, which is an animated level meter.

#include <JuceHeader.h>

class MeterComponent : public juce::Component

    void paint(juce::Graphics& g) override
        const auto width = getWidth();
        const auto height = getHeight();


        const auto level = getLevel();

        const auto barWidth = width / 10.0f;
        const auto barHeight = height * level;

        for (int i = 0; i < 10; ++i)
            const auto x = i * barWidth;
            const auto y = height - barHeight;

            g.setColour(juce::Colour::fromHSV(i / 10.0f, 1.0f, 1.0f, 1.0f));
            g.fillRect(x, y, barWidth, barHeight);

    void setLevel(float newLevel)
        if (newLevel != level)
            level = newLevel;

    float getLevel() const noexcept
        return level;

    float level = 0.0f;


This MeterComponent class displays a horizontal level meter with 10 bars. The level is set with the setLevel() method and the current level is returned by the getLevel() method. The meter is animated by calling repaint() whenever the level changes.

I compiled the code and set the level to 0.5, this is the result

Screenshot 2022-12-03 at 12.59.46


Really wondering what the consequences of this technology will be in the future.


Somewhat relevant to this, considering that ChatGPT invented a somewhat plausible juce::MeterComponent class.


yesterday i asked GPT-chat what kinda plugin it would make if it was a VST developer and it told me it would create an analyzer for the sentiment of a vocal input. That would be incredible :o just wanna pass this info on to everyone here, because i’m not into machine learning myself, so i can’t do it


Forget about Grid and FlexBox just give ChatGPT the set of Component pointers and a link to your social media account and let it select the optimal layout for you as a person. lol


ChatGPT is very impressive, but i’m wondering how it knows about the existence of JUCE. Did it get fed some extra data for this or did it just pick it up from the interwebs?

1 Like

The JUCE team recruited 5 support engineers to train the AI, in order to lower the entry barrier :wink:

I guess it’s simply web crawlers, like any search engine…

IMHO the same concerns like with Copilot and OpenSource licenses apply…


The Github Copilot product page more or less leads with “GitHub Copilot uses the OpenAI Codex”, so I presume given ChatGPT’s ability to suggest all manner of code that essentially what Copilot is “as a product” is some “prompt engineering” so that you get useful results.

It would be interesting to try “prompting” Copilot to do some more “creative” writing that GPT-3 is able to do, perhaps:

std::string getBackStory() {
// return a string that gives the back story for the main character in our game

and let the robot do its magic.

1 Like

Speaking of stories, my son runs D&D games, and after I pointed him to GPT-Chat he msged me,

"Ok this is out of control. I just got it to create a dnd adventure, a 4 person party, and roleplay the party accepting the quest"




The trick is to type the prompt in the syntax that the Large Language Model (LLM) expects.

My first prompts were like:

May you indicate me a working example of juce::FileListComponent

The output was a non-working code. But then I improved the prompt:

As a C++ JUCE programmer, may you indicate me how to use juce::DirectoryContentsList as a broadcaster and a derived class from juce::FileListComponent as a listener? juce::DirectoryContentsList instance is passed as an argument of the juce::FileListComponent instance, for example

fileListComponent.reset (new DerivedFileListComponent (*directoryContentsList, *this));

Leading to a very useful code sample.

On the other hand, GPT-3.5 and GPT-4 are on a Sep 2021 snapshot, hence, the answers are not up-to-date with JUCE 7.

I tried Bard and Bing, but it felt their results were less usable even when they are connected to the Internet.