1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
#include "PluginProcessor.h"
#include "UI/PluginEditor.h"
//==============================================================================
SchroederReverbAudioProcessor::SchroederReverbAudioProcessor()
: AudioProcessor(BusesProperties()
.withInput("Input", juce::AudioChannelSet::stereo(), true)
.withOutput("Output", juce::AudioChannelSet::stereo(), true))
{
addParameter(dryWetMix = new juce::AudioParameterFloat("mix", "Mix", 0.0f, 1.0f, 0.5f));
addParameter(decayFactor = new juce::AudioParameterFloat("decay", "Decay", 0.1f, 10.0f, 1.0f));
addParameter(preDelay
= new juce::AudioParameterFloat("predelay", "Pre-Delay", 0.0f, 0.2f, 0.0f));
}
SchroederReverbAudioProcessor::~SchroederReverbAudioProcessor() {}
//==============================================================================
const juce::String
SchroederReverbAudioProcessor::getName() const
{
return JucePlugin_Name;
}
bool
SchroederReverbAudioProcessor::acceptsMidi() const
{
return false;
}
bool
SchroederReverbAudioProcessor::producesMidi() const
{
return false;
}
bool
SchroederReverbAudioProcessor::isMidiEffect() const
{
return false;
}
double
SchroederReverbAudioProcessor::getTailLengthSeconds() const
{
return 10.0;
}
int
SchroederReverbAudioProcessor::getNumPrograms()
{
return 1;
}
int
SchroederReverbAudioProcessor::getCurrentProgram()
{
return 0;
}
void
SchroederReverbAudioProcessor::setCurrentProgram(int index)
{
juce::ignoreUnused(index);
}
const juce::String
SchroederReverbAudioProcessor::getProgramName(int index)
{
juce::ignoreUnused(index);
return {};
}
void
SchroederReverbAudioProcessor::changeProgramName(int index, const juce::String& newName)
{
juce::ignoreUnused(index, newName);
}
//==============================================================================
void
SchroederReverbAudioProcessor::prepareToPlay(double sampleRate, int samplesPerBlock)
{
schroederReverb.prepare(sampleRate, samplesPerBlock);
}
void
SchroederReverbAudioProcessor::releaseResources()
{
}
// The plugin only supports layouts with the same number of input and output channels
bool
SchroederReverbAudioProcessor::isBusesLayoutSupported(const BusesLayout& layouts) const
{
return layouts.getMainOutputChannelSet() == layouts.getMainInputChannelSet();
}
void
SchroederReverbAudioProcessor::processBlock(juce::AudioBuffer<float>& buffer,
juce::MidiBuffer& midiMessages)
{
juce::ignoreUnused(midiMessages);
juce::ScopedNoDenormals noDenormals;
int totalNumInputChannels = getTotalNumInputChannels();
int totalNumOutputChannels = getTotalNumOutputChannels();
float currentPreDelay = preDelay->get();
if (currentPreDelay != lastPreDelay)
{
schroederReverb.setPreDelayMs(currentPreDelay * 1000.0f);
lastPreDelay = currentPreDelay;
}
// Clear extra channels
for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear(i, 0, buffer.getNumSamples());
for (int channel = 0; channel < totalNumInputChannels; ++channel)
{
float* channelData = buffer.getWritePointer(channel);
for (int i = 0; i < buffer.getNumSamples(); ++i)
{
// Apply effect to sample
schroederReverb.process(channelData[i], dryWetMix->get(), decayFactor->get());
}
}
}
//==============================================================================
bool
SchroederReverbAudioProcessor::hasEditor() const
{
return true;
}
juce::AudioProcessorEditor*
SchroederReverbAudioProcessor::createEditor()
{
return new SchroederReverbAudioProcessorEditor(*this);
}
//==============================================================================
void
SchroederReverbAudioProcessor::getStateInformation(juce::MemoryBlock& destData)
{
juce::ignoreUnused(destData);
}
void
SchroederReverbAudioProcessor::setStateInformation(const void* data, int sizeInBytes)
{
juce::ignoreUnused(data, sizeInBytes);
}
//==============================================================================
// This creates new instances of the plugin..
juce::AudioProcessor* JUCE_CALLTYPE
createPluginFilter()
{
return new SchroederReverbAudioProcessor();
}
|