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
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:
private:
InstrumentLibraryOneAudioProcessor& audioProcessor;
juce::TextButton samplerButton{ "Sampler" };
InstrumentLibraryOneAudioProcessor& processor;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (InstrumentLibraryOneAudioProcessorEditor)
pluginprocessor.cpp
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
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.