1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00
JUCE/examples/audio plugin demo/Source/PluginProcessor.h

114 lines
4.8 KiB
C++

/*
==============================================================================
This file was auto-generated by the Jucer!
It contains the basic startup code for a Juce application.
==============================================================================
*/
#ifndef __PLUGINPROCESSOR_H_526ED7A9__
#define __PLUGINPROCESSOR_H_526ED7A9__
#include "../JuceLibraryCode/JuceHeader.h"
//==============================================================================
/**
As the name suggest, this class does the actual audio processing.
*/
class JuceDemoPluginAudioProcessor : public AudioProcessor
{
public:
//==============================================================================
JuceDemoPluginAudioProcessor();
~JuceDemoPluginAudioProcessor();
//==============================================================================
void prepareToPlay (double sampleRate, int samplesPerBlock) override;
void releaseResources() override;
void reset() override;
//==============================================================================
void processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages) override
{
jassert (! isUsingDoublePrecision());
process (buffer, midiMessages, delayBufferFloat);
}
void processBlock (AudioBuffer<double>& buffer, MidiBuffer& midiMessages) override
{
jassert (isUsingDoublePrecision());
process (buffer, midiMessages, delayBufferDouble);
}
//==============================================================================
bool hasEditor() const override { return true; }
AudioProcessorEditor* createEditor() override;
//==============================================================================
bool supportsDoublePrecisionProcessing() const override { return true; }
//==============================================================================
const String getName() const override { return JucePlugin_Name; }
const String getInputChannelName (int channelIndex) const override;
const String getOutputChannelName (int channelIndex) const override;
bool isInputChannelStereoPair (int index) const override;
bool isOutputChannelStereoPair (int index) const override;
bool acceptsMidi() const override;
bool producesMidi() const override;
bool silenceInProducesSilenceOut() const override;
double getTailLengthSeconds() const override;
//==============================================================================
int getNumPrograms() override { return 1; }
int getCurrentProgram() override { return 0; }
void setCurrentProgram (int /*index*/) override {}
const String getProgramName (int /*index*/) override { return "Default"; }
void changeProgramName (int /*index*/, const String& /*newName*/) override {}
//==============================================================================
void getStateInformation (MemoryBlock& destData) override;
void setStateInformation (const void* data, int sizeInBytes) override;
//==============================================================================
// These properties are public so that our editor component can access them
// A bit of a hacky way to do it, but it's only a demo! Obviously in your own
// code you'll do this much more neatly..
// this is kept up to date with the midi messages that arrive, and the UI component
// registers with it so it can represent the incoming messages
MidiKeyboardState keyboardState;
// this keeps a copy of the last set of time info that was acquired during an audio
// callback - the UI component will read this and display it.
AudioPlayHead::CurrentPositionInfo lastPosInfo;
// these are used to persist the UI's size - the values are stored along with the
// filter's other parameters, and the UI component will update them when it gets
// resized.
int lastUIWidth, lastUIHeight;
// Our parameters
AudioProcessorParameter* gain;
AudioProcessorParameter* delay;
private:
//==============================================================================
template <typename floatType>
void process (AudioBuffer<floatType>& buffer, MidiBuffer& midiMessages, AudioBuffer<floatType>& delayBuffer);
AudioBuffer<float> delayBufferFloat;
AudioBuffer<double> delayBufferDouble;
int delayPosition;
// the synth!
Synthesiser synth;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (JuceDemoPluginAudioProcessor)
};
#endif // __PLUGINPROCESSOR_H_526ED7A9__