I am going through tutorials and trying to inherit a class from Synthesiser. But this name was not found. Out of sight are also AudioFormatManager, SamplerVoice, File, ScopedPointer and some methods. I do not understand, it seems that all the necessary namespaces and libraries are connected. In Projucer, “Plugin is a Synth” and “Plugin MIDI Input” are selected. What’s the matter?
// SimpleSynth.h
#pragma once
#include "../JuceLibraryCode/JuceHeader.h"
class SimpleSynth : public Synthesiser {
public:
void setup();
private:
AudioFormatManager audioFormatManager;
};
// SimpleSynth.cpp
#include "SimpleSynth.h"
#define MAX_VOICES 16
void SimpleSynth::setup() {
// add voices to our sampler
for (int i = 0; i < MAX_VOICES; i++) {
addVoice(new SamplerVoice());
}
// set up our AudioFormatManager class as detailed in the API docs
// we can now use WAV and AIFF files!
audioFormatManager.registerBasicFormats();
// now that we have our manager, lets read a simple file so we can pass it to our SamplerSound object.
File* file = new File("1.wav");
ScopedPointer<AudioFormatReader> reader = audioFormatManager.createReaderFor(*file);
// allow our sound to be played on all notes
BigInteger allNotes;
allNotes.setRange(0, 128, true);
// finally, add our sound
addSound(new SamplerSound("default", *reader, allNotes, 60, 0, 10, 10.0));
}