"AudioAppComponent" is "not a class or struct name"? (Resolved)


#1

I have my basic GUI system for a synth starting to come together so I want to start adding sound from some tutorials I’m following.

However, it doesn’t seem to work and I can’t understand why. For example, the basic code from the Sine Synth Tutorial is:

class MainContentComponent   : public AudioAppComponent
{
public:
    MainContentComponent()
    {
        addAndMakeVisible (frequencySlider);
        frequencySlider.setRange (50.0, 5000.0);
        frequencySlider.setSkewFactorFromMidPoint (500.0); // [4]
        frequencySlider.onValueChange = [this]
        {
            if (currentSampleRate > 0.0)
                updateAngleDelta();
        };

        setSize (600, 100);
        setAudioChannels (0, 2); // no inputs, two outputs

But I can’t even get this to work in my design. My otherwise “working” GUI demo has a MainContentComponent that inherits from Component. But this does not seem to let me do things like setAudioChannels(0, 2);

If I try to make it or a new class that inherits from AudioAppComponent it tells me that doesn’t exist. I don’t get it.


If I started this project by selecting “GUI Application” would that cause problems? What am I supposed to do to fix this so I can get the basic audio functions working?

Also is there a difference in concept between “MainComponent” and “MainContentComponent”? I see some demos use one or the other.

Thanks.

Edit: I presume this has to do with what you select when you start a project and there’s no turning back after that. Started an “Audio Application” instead and copied my GUI code into it to integrate and now I can do all those commands.


#3

The AudioAppComponent is in the module juce_audio_utils, which is not selected by default in some project templates. But you can always add it at later stage in the modules section of Projucer.


#4

Isn’t the problem with the code in the post the setAudioChannels (0, 2); line? Its been put in the body of the class definition rather than in the constructor where it should be, so its basically a syntax error and confusing the compiler.


#5

Well spotted, that’s the next error, which XCode calls:
C++ requires a type specifier for all declarations. That needs fixing as well.