Use of undeclared identifier 'processor' Error

What should I do?

mainWindow.reset (new MainWindow ("ProcessorEditor", new ProcessorEditor(audioProcessor), *this));

This code at line 32 of the Main.cpp file outputs the error Use of undeclared identifier ‘processor’.
And there is also an error “Allocating an object of abstract class type AudioProcessorClass”

I don’t know what to do Because I am new to C++.
How do I do?

I have the following files.

  • KeyboardGUI.h
  • KeyboardGUI.cpp
  • OscComponent.h
  • OscComponent.cpp
  • WavetableOscillator.h
  • Main.cpp
  • PluginEditor.h
  • PluginEditor.cpp
  • PluginProcessor.h
//PluginEditor.h
#pragma once
#include "JuceHeader.h"
#include "OscComponent.h"
#include "KeyboardGUI.h"
#include "PluginProcessor.h"
class ProcessorEditor  : public juce::AudioProcessorEditor
{
public:
    ProcessorEditor (AudioProcessorClass& audioProcessor);
    ~ProcessorEditor() override;
private:
    AudioProcessorClass& audioProcessor;
    OscComponent osc1;
    KeyboardGUI keyboardGUI;
    
};
//PluginEditor.cpp
#include <JuceHeader.h>
#include "PluginProcessor.h"
#include "PluginEditor.h"
#include "OscComponent.h"
ProcessorEditor::ProcessorEditor(AudioProcessorClass& processor):AudioProcessorEditor (&processor),audioProcessor (processor), osc1 (audioProcessor.audioProcessorValueTreeState, "OSC1"),keyboardGUI()
{
    addAndMakeVisible(osc1);
    addAndMakeVisible(keyboardGUI);
}

//PluginProcessor.h
#pragma once
#include <JuceHeader.h>
class AudioProcessorClass  : public juce::AudioProcessor
{
public:
    AudioProcessorClass();
    ~AudioProcessorClass() override;
    juce::AudioProcessorValueTreeState audioProcessorValueTreeState;
    
};

//Main.cpp
#include <JuceHeader.h>
#include "PluginProcessor.h"
#include "PluginEditor.h"

class Application    : public juce::JUCEApplication
{
public:

    Application() = default;

    const juce::String getApplicationName() override       { return "ProcessorEditor"; }
    const juce::String getApplicationVersion() override    { return "1.0.0"; }

    void initialise (const juce::String&) override
    {

        mainWindow.reset (new MainWindow ("ProcessorEditor", new ProcessorEditor(audioProcessor), *this));
 
    }

    void shutdown() override                         { mainWindow = nullptr; }

private:
    class MainWindow    : public juce::DocumentWindow
    {
    public:
        MainWindow (const juce::String& name, juce::Component* c, JUCEApplication& a)
            : DocumentWindow (name, juce::Desktop::getInstance().getDefaultLookAndFeel()
                                                                .findColour (ResizableWindow::backgroundColourId),
                              juce::DocumentWindow::allButtons),
              app (a)
        {
            setUsingNativeTitleBar (true);
            setContentOwned (c, true);
           #if JUCE_ANDROID || JUCE_IOS
            setFullScreen (true);
           #else
            setResizable (true, false);
            setResizeLimits (300, 250, 10000, 10000);
            centreWithSize (getWidth(), getHeight());
           #endif
            setVisible (true);
        }
        void closeButtonPressed() override
        {
            app.systemRequestedQuit();
        }
    private:
        JUCEApplication& app;
        JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindow)
    };

    std::unique_ptr<MainWindow> mainWindow;
};

START_JUCE_APPLICATION (Application)
//OscComponent.h
#pragma once
#include <JuceHeader.h>
#include "WavetableOscillator.h"
#include "KeyboardGUI.h"
class OscComponent   : public juce::AudioAppComponent

{
public:
    OscComponent(juce::AudioProcessorValueTreeState& audioProcessorValueTreeState,juce::String oscId);


    ~OscComponent() override;
    void resized() override;
    void createWavetable()//追加
        {

            audioBuffer.setSize (1, (int) NumSamples);
            audioBuffer.clear();
            auto* samples = audioBuffer.getWritePointer (0);
            samples[NumSamples] = samples[0];
   
            auto angleDelta = juce::MathConstants<double>::twoPi / (double) (NumSamples - 1);
            auto currentAngle = 0.0;
            for (unsigned int i = 0; i < NumSamples; ++i)
            {
                auto sample = std::sin (currentAngle);                                       // [5]
                samples[i] = (float) sample;
                currentAngle += angleDelta;
            }
        };
    void prepareToPlay (int, double sampleRate) override
    {
        auto numberOfOscillators = 2;

        for (auto i = 0; i < numberOfOscillators; ++i)
        {
            auto* oscillator = new WavetableOscillator(audioBuffer);
            auto midiNote = juce::Random::getSystemRandom().nextDouble() * 36.0 + 48.0; // [3]
            auto frequency = 440.0 * pow (2.0, (midiNote - 69.0) / 12.0);               // [4]

            oscillator->setFrequency ((float) frequency, (float) sampleRate);           // [5]
            oscillators.add(oscillator);
        }

        level = 0.25f / (float) numberOfOscillators;                                    // [6]
    };

    void releaseResources() override {};

    void getNextAudioBlock (const juce::AudioSourceChannelInfo& bufferToFill) override
    {
        auto* leftBuffer  = bufferToFill.buffer->getWritePointer (0, bufferToFill.startSample); // [7]
        auto* rightBuffer = bufferToFill.buffer->getWritePointer (1, bufferToFill.startSample);

        bufferToFill.clearActiveBufferRegion();

        for (auto oscillatorIndex = 0; oscillatorIndex < oscillators.size(); ++oscillatorIndex)
        {
            auto* oscillator = oscillators.getUnchecked (oscillatorIndex);                      // [8]

            for (auto sample = 0; sample < bufferToFill.numSamples; ++sample)
            {
                auto levelSample = oscillator->getNextSample() * level;                         // [9]

                leftBuffer[sample]  += levelSample;                                             // [10]
                rightBuffer[sample] += levelSample;
            }
        }
    }
private:
    juce::ComboBox ComboBox;
    juce::Label ComboBoxLabel { "Wave Type", "Wave Type" };
    std::unique_ptr<juce::AudioProcessorValueTreeState::ComboBoxAttachment> ComboBoxAttachment;
    

    const unsigned int NumSamples= 1 << 7;
    float level = 0.0f;
    juce::AudioSampleBuffer audioBuffer;
    juce::OwnedArray<WavetableOscillator> oscillators;
    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OscComponent)
};

//OscComponent.cpp
#include <JuceHeader.h>
#include "OscComponent.h"
OscComponent::OscComponent(juce::AudioProcessorValueTreeState& audioProcessorValueTreeState,juce::String oscId)
{
    juce::StringArray choices { "Sine", "Saw", "Square" ,"triangle"};
    ComboBox.addItemList (choices, 1);
    ComboBox.setSelectedItemIndex (0);
    addAndMakeVisible (ComboBox);
    ComboBoxAttachment = std::make_unique<juce::AudioProcessorValueTreeState::ComboBoxAttachment>(audioProcessorValueTreeState,  ComboBox);
    ComboBoxLabel.setJustificationType (juce::Justification::left);
    addAndMakeVisible (ComboBoxLabel);
    ComboBox.setColour(ComboBox::backgroundColourId, Colours::red);
    ComboBoxLabel.setColour(Label::textColourId, Colours::red);
    setSize (400, 50);
};
OscComponent::~OscComponent()
{
    shutdownAudio();
};
void OscComponent::resized()
{
    const auto labelHeight = 20;
    ComboBoxLabel.setBounds (0, 0, 90, labelHeight);
    ComboBox.setBounds (0, 20, 90, 30);
}
midiKeyboardState(),keyboardComponent(midiKeyboardState, juce::MidiKeyboardComponent::horizontalKeyboard)

void createWavetable()
{
};
//KeyboardGUI.h
#pragma once
#include <JuceHeader.h>
class KeyboardGUI : public juce::Component, juce::MidiKeyboardState::Listener
{
public:
    KeyboardGUI();
    ~KeyboardGUI() override;
    void resized() override;
    void handleNoteOn(juce::MidiKeyboardState*, int midiChannel, int midiNoteNumber, float velocity) override {}
    void handleNoteOff(juce::MidiKeyboardState*, int midiChannel, int midiNoteNumber, float velocity) override {}
private:
    void timerCallback();
    juce::MidiKeyboardState midiKeyboardState;
    juce::MidiKeyboardComponent keyboardComponent;
    
};

//KeyboardGUI.cpp
#include <JuceHeader.h>
#include "KeyboardGUI.h"
#include "OscComponent.h"
KeyboardGUI::KeyboardGUI(): midiKeyboardState(),keyboardComponent(midiKeyboardState, juce::MidiKeyboardComponent::horizontalKeyboard)
{
    midiKeyboardState.addListener(this);
    addAndMakeVisible(keyboardComponent);



};
KeyboardGUI::~KeyboardGUI()
{
};
void KeyboardGUI::resized()
{
    keyboardComponent.setBounds(getLocalBounds());

};


//WavetableOscillator.h
#pragma once
#include <JuceHeader.h>
class WavetableOscillator
{
public:
    WavetableOscillator (const juce::AudioSampleBuffer& wavetableToUse)
        : wavetable (wavetableToUse),
          tableSize (wavetable.getNumSamples() - 1)
          {
              juce::Logger::outputDebugString("WavetableOscillator.h");
              jassert (wavetable.getNumChannels() == 0);
          };
    void setFrequency (float frequency, float sampleRate)
    {
            auto tableSizeOverSampleRate = (float) wavetable.getNumSamples() / sampleRate;
            tableDelta = frequency * tableSizeOverSampleRate;
    }
    
    forcedinline float getNextSample() noexcept
        {
            auto tableSize = (unsigned int) wavetable.getNumSamples();
     
            auto index0 = (unsigned int) currentIndex;              // [6]
            auto index1 = index0 == (tableSize - 1) ? (unsigned int) 0 : index0 + 1;
     
            auto frac = currentIndex - (float) index0;              // [7]
     
            auto* table = wavetable.getReadPointer (0);             // [8]
            auto value0 = table[index0];
            auto value1 = table[index1];
     
            auto currentSample = value0 + frac * (value1 - value0); // [9]
     
            if ((currentIndex += tableDelta) > (float) tableSize)   // [10]
                currentIndex -= (float) tableSize;
     
            return currentSample;
        }
    
private:
    const juce::AudioSampleBuffer& wavetable;
    const int tableSize;
    float currentIndex = 0.0f, tableDelta = 0.0f;
};


It would probably be helpful if you shared the text of the actual error message with us, since it will contain some detail info about what identifier is undeclared which makes helping you a lot easier.

The error message "Use of undeclared identifier ‘processor’.

Well, this is not really helpful as well. I meant the entire error message, including all the surrounding text such as the file and line, maybe the whole include hierarchy and whatever else the compiler emits. Compilers are usually quite good at reporting very detailed error messages these days.

In your code snippet above there is no single reference to processor so it must be some piece of code that you didn’t share with us that generates the error.

I have edited the question.

Do you have enough information to solve the problem?

No… Take a screen shot of the error message which will tell you the exact line of code which has the error

Is it crucial how many lines the error is on?
I have written all the information in the question text about the entire code I wrote, the file in which the error is occurring, and what code in that file is outputting what error.
Which other information is missing?
I’ll upload a screenshot. sIs it difficult to understand with this screenshot image?

New users are only allowed one upload per post, so split the post into two separate posts.

You created a Standalone GUI project… not a plugin as your base in ProJucer (the Main is a giveaway).

Rail

I am sorry, but I do not understand the situation.
Am I correct in understanding that the problem is that I have created an independent GUI project, even though I need to set up the project as a plug-in?
To begin with, what I want to create is a synthesizer.
How do I set up Projucer to create a synthesizer that can function as a stand-alone project and still be usable in a DAW? Can I still solve the problem by changing the Projcuer settings?
Or is there something I can’t do anymore? Is it impossible?

Yes. Create a plugin project. It can be built as a plugin or a standalone.

No, you cannot do this by changing a setting. You need to create a new project, and then just add your existing files to it. And move any code from main to the constructor of your processor class, as that is the common part between the plugin and the standalone.