Tutorial: Two Fatal Errors


#1

Hi Everyone,

I’m excited about learning Juce and am following the tutorial at:

https://www.juce.com/doc/tutorial_code_basic_plugin

I’ve gone through the tutorial three times and am still getting fatal errors when building it with VS2010:


Error 1 error C2614: ‘TutorialPluginAudioProcessorEditor’ : illegal member initialization: ‘processor’ is not a base or member c:\vstdev\tutorialplugin\source\plugineditor.cpp 18 1 TutorialPlugin

Error 2 error C2039: ‘noteOnVel’ : is not a member of ‘juce::AudioProcessor’ c:\vstdev\tutorialplugin\source\plugineditor.cpp 69 1 TutorialPlugin


Does anyone have any leads on this? It happened specifically after editing the following into PluginEditor.h:

class TutorialPluginAudioProcessorEditor  : public AudioProcessorEditor,
                                       private Slider::Listener
{
public:
    TutorialPluginAudioProcessorEditor (TutorialPluginAudioProcessor&);
    ~TutorialPluginAudioProcessorEditor();

//==================================================================
// This is just a standard Juce paint method...
void paint (Graphics& g) override;

void resized() override;

private:
    void sliderValueChanged (Slider* slider) override;

    Slider midiVolume;
};

And the following in PluginEditor.cpp:

void TutorialPluginAudioProcessorEditor::sliderValueChanged (Slider* slider)
{
    processor.noteOnVel = midiVolume.getValue();
}

And I did complete the process with the following:

void TutorialPluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
    buffer.clear();
 
    MidiBuffer processedMidi;
    int time;
    MidiMessage m;

    for (MidiBuffer::Iterator i (midiMessages); i.getNextEvent (m, time);)
    {
        if (m.isNoteOn())
        {
            uint8 newVel = (uint8)noteOnVel;
            m = MidiMessage::noteOn(m.getChannel(), m.getNoteNumber(), newVel);
        }
        else if (m.isNoteOff())
        {
        }
        else if (m.isAftertouch())
        {
        }
        else if (m.isPitchWheel())
        {
        }

        processedMidi.addEvent (m, time);
    }

    midiMessages.swapWith (processedMidi);
}

I should mention that the plugin compiled fine before the part of the tutorial titled:

“Pass control information to the processor class”


#2

There appears to be an error in the basic tutorial. Under the header of “Create a simple GUI control” the code is:

class TutorialPluginAudioProcessorEditor : public AudioProcessorEditor
{
public:
    TutorialPluginAudioProcessorEditor (TutorialPluginAudioProcessor&);
    ~TutorialPluginAudioProcessorEditor();

    //===================================================================
    void paint (Graphics&) override;
    void resized() override;

private:
    // This reference is provided as a quick way for your editor to
    // access the processor object that created it.
    TutorialPluginAudioProcessor& processor;

    Slider midiVolume;

    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TutorialPluginAudioProcessorEditor)
};

However further down on the page under the heading “Pass control information to the processor class” it tells us to “Add the inheritance and the default callback function so the editor class looks like this”…

class TutorialPluginAudioProcessorEditor : public AudioProcessorEditor,
                                           private Slider::Listener
{
public:
    TutorialPluginAudioProcessorEditor (TutorialPluginAudioProcessor&);
    ~TutorialPluginAudioProcessorEditor();

    //==================================================================
    // This is just a standard Juce paint method...
    void paint (Graphics& g) override;

    void resized() override;

private:
    void sliderValueChanged (Slider* slider) override;

    Slider midiVolume;
};

If you make it “look like that” you remove the following two lines from the first way it was articulated:

    TutorialPluginAudioProcessor& processor;

    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TutorialPluginAudioProcessorEditor)

…and you will generate the errors I generated.

This is the documentation for an introductory tutorial for a complete beginner and already I am debugging and finding a lack of clarity in how it’s being communicated - is this what I have to look forward to as I proceed? Is there any other resource that has a reliable and well-articulated documentation for a beginner so I can spend my time learning Juce and not debugging and deliberating about the author’s intentions?


#3

Hey aethyraa!

I am sorry to hear that you run into this and I can understand how frustrating it can be. Experienced users usually notice right away that a member variable was missing here but that’s not the case if you’re just starting. I was in the same boat not so long ago.

We’ll get this fixed by the end of the week.

There are plenty more tutorials on the site, as well as a book to help you get started with JUCE. I hope that the rest of your journey with JUCE is exciting and delightful!

All the best


#4

Hi Luigi,

Thank you for the reply, and thank you for updating the documentation - I checked it out today and I see it’s now been corrected. I’ll also be checking out that book you mentioned.

Kind Regards,
A.A


#5

Hi all,

I’m in a very similar situation. I’m also new to JUCE, and still getting 2 fatal errors after trying this tutorial twice from scratch. I see here in the thread that a problem was fixed a while ago, but I wonder if there might still be something weird going on. Is everyone else able to get this to work?

My errors are different, and point to this part:

TutorialPluginAudioProcessorEditor::TutorialPluginAudioProcessorEditor (TutorialPluginAudioProcessor& p)
: AudioProcessorEditor (&p), processor §
{
// …

// add the listener to the slider
midiVolume.addListener (this);

}

This is copied from the tutorial, but not exactly what I’m typing in of course. I’m just adding midiVolume.addListener (this); to the bottom of what’s already in the… is this the constructor?

Also, does it matter where in PluginEditor.cpp I drop this other chunk? Because it’s giving me the other error:

void TutorialPluginAudioProcessorEditor::sliderValueChanged (Slider* slider)
{
processor.noteOnVel = midiVolume.getValue();
}

The tutorial is vague about this. It actually doesn’t even say which file it should go in.

Any help is greatly appreciated!


#6

The errors I’m getting:

cannot initialize a parameter of type ‘juce::Slider::Listener *’ with an rvalue of type ‘TutorialPluginAudioProcessorEditor *’

and

out-of-line definition of ‘sliderValueChanged’ does not match any declaration in ‘TutorialPluginAudioProcessorEditor’


#7

Have you followed the tutorial through to the “Add the inheritance and the default callback function so the editor class looks like this:” section? It looks like you haven’t inherited from Slider::Listener or declared the sliderValueChanged() method in your TutorialPluginAudioProcessor class header.