Browse Source

Implemented AudioProcessor::getParameterDefaultValue() in the plugin demo.

tags/2021-05-28
jules 12 years ago
parent
commit
d8dd77da62
4 changed files with 52 additions and 36 deletions
  1. +2
    -1
      extras/audio plugin demo/Source/PluginEditor.cpp
  2. +5
    -6
      extras/audio plugin demo/Source/PluginEditor.h
  3. +16
    -2
      extras/audio plugin demo/Source/PluginProcessor.cpp
  4. +29
    -27
      extras/audio plugin demo/Source/PluginProcessor.h

+ 2
- 1
extras/audio plugin demo/Source/PluginEditor.cpp View File

@@ -64,7 +64,8 @@ JuceDemoPluginAudioProcessorEditor::~JuceDemoPluginAudioProcessorEditor()
//==============================================================================
void JuceDemoPluginAudioProcessorEditor::paint (Graphics& g)
{
g.setGradientFill (ColourGradient (Colours::white, 0, 0, Colours::grey, 0, (float) getHeight(), false));
g.setGradientFill (ColourGradient (Colours::white, 0, 0,
Colours::grey, 0, (float) getHeight(), false));
g.fillAll();
}


+ 5
- 6
extras/audio plugin demo/Source/PluginEditor.h View File

@@ -27,16 +27,15 @@ public:
~JuceDemoPluginAudioProcessorEditor();
//==============================================================================
void timerCallback();
void paint (Graphics& g);
void resized();
void sliderValueChanged (Slider*);
void timerCallback() override;
void paint (Graphics&) override;
void resized() override;
void sliderValueChanged (Slider*) override;
private:
MidiKeyboardComponent midiKeyboard;
Label infoLabel, gainLabel, delayLabel;
Slider gainSlider;
Slider delaySlider;
Slider gainSlider, delaySlider;
ScopedPointer<ResizableCornerComponent> resizer;
ComponentBoundsConstrainer resizeLimits;


+ 16
- 2
extras/audio plugin demo/Source/PluginProcessor.cpp View File

@@ -131,14 +131,16 @@ private:
double currentAngle, angleDelta, level, tailOff;
};
const float defaultGain = 1.0f;
const float defaultDelay = 0.5f;
//==============================================================================
JuceDemoPluginAudioProcessor::JuceDemoPluginAudioProcessor()
: delayBuffer (2, 12000)
{
// Set up some default values..
gain = 1.0f;
delay = 0.5f;
gain = defaultGain;
delay = defaultDelay;
lastUIWidth = 400;
lastUIHeight = 200;
@@ -189,6 +191,18 @@ void JuceDemoPluginAudioProcessor::setParameter (int index, float newValue)
}
}
float JuceDemoPluginAudioProcessor::getParameterDefaultValue (int index)
{
switch (index)
{
case gainParam: return defaultGain;
case delayParam: return defaultDelay;
default: break;
}
return 0.0f;
}
const String JuceDemoPluginAudioProcessor::getParameterName (int index)
{
switch (index)


+ 29
- 27
extras/audio plugin demo/Source/PluginProcessor.h View File

@@ -16,6 +16,7 @@
//==============================================================================
/**
As the name suggest, this class does the actual audio processing.
*/
class JuceDemoPluginAudioProcessor : public AudioProcessor
{
@@ -25,44 +26,45 @@ public:
~JuceDemoPluginAudioProcessor();
//==============================================================================
void prepareToPlay (double sampleRate, int samplesPerBlock);
void releaseResources();
void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages);
void reset();
void prepareToPlay (double sampleRate, int samplesPerBlock) override;
void releaseResources() override;
void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages) override;
void reset() override;
//==============================================================================
bool hasEditor() const { return true; }
AudioProcessorEditor* createEditor();
bool hasEditor() const override { return true; }
AudioProcessorEditor* createEditor() override;
//==============================================================================
const String getName() const { return JucePlugin_Name; }
const String getName() const override { return JucePlugin_Name; }
int getNumParameters();
float getParameter (int index);
void setParameter (int index, float newValue);
const String getParameterName (int index);
const String getParameterText (int index);
int getNumParameters() override;
float getParameter (int index) override;
float getParameterDefaultValue (int index) override;
void setParameter (int index, float newValue) override;
const String getParameterName (int index) override;
const String getParameterText (int index) override;
const String getInputChannelName (int channelIndex) const;
const String getOutputChannelName (int channelIndex) const;
bool isInputChannelStereoPair (int index) const;
bool isOutputChannelStereoPair (int index) const;
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;
bool producesMidi() const;
bool silenceInProducesSilenceOut() const;
double getTailLengthSeconds() const;
bool acceptsMidi() const override;
bool producesMidi() const override;
bool silenceInProducesSilenceOut() const override;
double getTailLengthSeconds() const override;
//==============================================================================
int getNumPrograms() { return 0; }
int getCurrentProgram() { return 0; }
void setCurrentProgram (int /*index*/) { }
const String getProgramName (int /*index*/) { return String::empty; }
void changeProgramName (int /*index*/, const String& /*newName*/) { }
int getNumPrograms() override { return 0; }
int getCurrentProgram() override { return 0; }
void setCurrentProgram (int /*index*/) override {}
const String getProgramName (int /*index*/) override { return String::empty; }
void changeProgramName (int /*index*/, const String& /*newName*/) override {}
//==============================================================================
void getStateInformation (MemoryBlock& destData);
void setStateInformation (const void* data, int sizeInBytes);
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


Loading…
Cancel
Save