# How to fix: Audio Processor &p provides no initializer for:

**URL:** <https://forum.juce.com/t/how-to-fix-audio-processor-p-provides-no-initializer-for/51869>\
**Category:** General JUCE discussion\
**Created:** [June 20, 2022, 5:14pm UTC](https://forum.juce.com/t/how-to-fix-audio-processor-p-provides-no-initializer-for/51869 "2022-06-20T17:14:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![craftono](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/craftono/32/13557_2.png) [@craftono](https://forum.juce.com/u/craftono)\
**Post date:** [June 20, 2022, 5:14pm UTC](https://forum.juce.com/t/how-to-fix-audio-processor-p-provides-no-initializer-for/51869/1 "2022-06-20T17:14:44Z")

</div>

I asked this question in audio plugins but I haven’t received any responses so I am posting it here.  
Hi I am a beginner to JUCE and C++ in general and I am following the Audio Programmers Guide for making a sampler, and I am getting one final error that I can not figure out. It says: Audio Processor &p provides no initializer for:  
Any help would be appreciated!  
Here is the code I have:  
PluginEditor.cpp

```auto
InstrumentLibraryOneAudioProcessorEditor::InstrumentLibraryOneAudioProcessorEditor (InstrumentLibraryOneAudioProcessor& p)
    : AudioProcessorEditor (&p), audioProcessor (p)
{
    // Make sure that before the constructor has finished, you've set the
    // editor's size to whatever you need it to be.
  
    
    addAndMakeVisible(samplerButton);  
    samplerButton.onClick = [&]() {processor.loadFile(); };
    setSize(800, 500);
}

```

pluginEditor.h:

```auto
private:
    InstrumentLibraryOneAudioProcessor& audioProcessor;
    juce::TextButton samplerButton{ "Sampler" };

    InstrumentLibraryOneAudioProcessor& processor;
    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (InstrumentLibraryOneAudioProcessorEditor)

```

pluginprocessor.cpp

```auto
InstrumentLibraryOneAudioProcessor::InstrumentLibraryOneAudioProcessor()
#ifndef JucePlugin_PreferredChannelConfigurations
     : AudioProcessor (BusesProperties()
                     #if ! JucePlugin_IsMidiEffect
                      #if ! JucePlugin_IsSynth
                       .withInput ("Input", juce::AudioChannelSet::stereo(), true)
                      #endif
                       .withOutput ("Output", juce::AudioChannelSet::stereo(), true)
                     #endif
                       )
#endif
{
    for (int i = 0; i < numVoices; i++)
    {
        formatManager.registerBasicFormats();

        mSampler.addVoice(new SamplerVoice());
    }
}

InstrumentLibraryOneAudioProcessor::~InstrumentLibraryOneAudioProcessor()
{
    formatReader = nullptr;
}

void InstrumentLibraryOneAudioProcessor::loadFile()
{
    FileChooser chooser{ "Select Audio File" };

    if (chooser.browseForFileToOpen())
    {
        auto file = chooser.getResult();
        formatReader = formatManager.createReaderFor(file);
    }
    BigInteger range;
    range.setRange(0, 128, true);

    mSampler.addSound(new SamplerSound("Sample", *formatReader, range, 60, 0.1, 0.1, 10));
}

```

pluginprocessor.h

```auto
private:
    Synthesiser mSampler;
    const int numVoices{ 6 };
    AudioFormatManager formatManager;
    AudioFormatReader* formatReader{ nullptr };
    
    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (InstrumentLibraryOneAudioProcessor)

```

I did not include the whole code, only the sections I changed.

---

<div class="post-metadata">

**Author:** ![PeterRoos](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@PeterRoos](https://forum.juce.com/u/PeterRoos)\
**Post date:** [June 20, 2022, 5:17pm UTC](https://forum.juce.com/t/how-to-fix-audio-processor-p-provides-no-initializer-for/51869/2 "2022-06-20T17:17:31Z")

</div>

Why the two InstrumentLibraryOneAudioProcessor references?

```auto
    InstrumentLibraryOneAudioProcessor& audioProcessor;
    InstrumentLibraryOneAudioProcessor& processor;

```

This surely can’t be what you intend?

The second one is not initialized in the initializer list of the constructor, that’s the compiler’s complaint. References must always be initialized.

---

<div class="post-metadata">

**Author:** ![craftono](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/craftono/32/13557_2.png) [@craftono](https://forum.juce.com/u/craftono)\
**Post date:** [June 20, 2022, 8:58pm UTC](https://forum.juce.com/t/how-to-fix-audio-processor-p-provides-no-initializer-for/51869/3 "2022-06-20T20:58:11Z")

</div>

Where and what would I add to in order to initialize the second one? I have never heard of what an initializer list is or how to add to one.

---

<div class="post-metadata">

**Author:** ![PeterRoos](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@PeterRoos](https://forum.juce.com/u/PeterRoos)\
**Post date:** [June 20, 2022, 9:05pm UTC](https://forum.juce.com/t/how-to-fix-audio-processor-p-provides-no-initializer-for/51869/4 "2022-06-20T21:05:08Z")

</div>

Well, you can better drop the second one, “processor” - I bet you are not using it in the rest of your code. If your are, replace it with audioProcessor.

An initializer list is a recommended way to initialize variables / objects that you have declared in your class (in the header file). Simple variables do not need to be initialized there, but at least references must be assigned there; I prefer to initialize objects there as well.

Look at the first line in your code:

```auto
    : AudioProcessorEditor (&p), audioProcessor (p)

```

what follows after the colon “:” is an initializer list.

Anything you haven’t heard of before, be it about C++, JUCE, DSP, Google it! Or ask here 😉  
C++ is a pretty difficult language, you need to have regular doses of new lessons, otherwise you will never improve your skills.

Success!

---

<div class="post-metadata">

**Author:** ![craftono](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/craftono/32/13557_2.png) [@craftono](https://forum.juce.com/u/craftono)\
**Post date:** [June 20, 2022, 9:20pm UTC](https://forum.juce.com/t/how-to-fix-audio-processor-p-provides-no-initializer-for/51869/5 "2022-06-20T21:20:39Z")

</div>

Thank you it is working now!

---

<div class="post-metadata">

**Author:** ![PeterRoos](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@PeterRoos](https://forum.juce.com/u/PeterRoos)\
**Post date:** [June 20, 2022, 9:20pm UTC](https://forum.juce.com/t/how-to-fix-audio-processor-p-provides-no-initializer-for/51869/6 "2022-06-20T21:20:59Z")

</div>

Top!
