|
|
@ -23,14 +23,16 @@ ReverbAudioProcessor::ReverbAudioProcessor()
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
addParameter(roomSize = new juce::AudioParameterFloat("roomSize", "Room Size", 0.0, 1.0, 0.5));
|
|
|
|
addParameter(roomSize = new juce::AudioParameterFloat(juce::ParameterID("roomSize", 1), "Room Size", 0.0, 1.0, 0.5));
|
|
|
|
addParameter(damping = new juce::AudioParameterFloat("damping", "Damping", 0.0, 1.0, 0.5));
|
|
|
|
addParameter(damping = new juce::AudioParameterFloat(juce::ParameterID("damping", 2), "Damping", 0.0, 1.0, 0.5));
|
|
|
|
addParameter(wetLevel = new juce::AudioParameterFloat("wetLevel", "Wet Level", 0.0, 1.0, 0.5));
|
|
|
|
addParameter(wet_dry = new juce::AudioParameterFloat(juce::ParameterID("wet_dry", 3), "Mix", 0.0, 1.0, 0.5));
|
|
|
|
addParameter(dryLevel = new juce::AudioParameterFloat("dryLevel", "Dry Level", 0.0, 1.0, 0.5));
|
|
|
|
addParameter(width = new juce::AudioParameterFloat(juce::ParameterID("width", 4), "Width", 0.0, 1.0, 0.5));
|
|
|
|
addParameter(width = new juce::AudioParameterFloat("width", "Width", 0.0, 1.0, 0.5));
|
|
|
|
addParameter(freezeMode = new juce::AudioParameterFloat(juce::ParameterID("freezeMode", 5), "Freeze", 0.0, 1.0, 0.0));
|
|
|
|
addParameter(freezeMode = new juce::AudioParameterFloat("freezeMode", "Freeze", 0.0, 1.0, 0.5));
|
|
|
|
addParameter(lofi = new juce::AudioParameterBool(juce::ParameterID("lofi", 6), "Tone or lofi", false));
|
|
|
|
|
|
|
|
addParameter(tone_val = new juce::AudioParameterFloat(juce::ParameterID("tone_val", 7), "Tone", 0.0, 1.0, 0.5));
|
|
|
|
|
|
|
|
addParameter(out = new juce::AudioParameterFloat(juce::ParameterID("out", 8), "Output", 0.0, 2.0, 1.0));
|
|
|
|
|
|
|
|
|
|
|
|
verb.setSampleRate(48000);
|
|
|
|
verb.setSampleRate(sample_rate);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ReverbAudioProcessor::~ReverbAudioProcessor()
|
|
|
|
ReverbAudioProcessor::~ReverbAudioProcessor()
|
|
|
@ -93,6 +95,22 @@ void ReverbAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock
|
|
|
|
// Use this method as the place to do any pre-playback
|
|
|
|
// Use this method as the place to do any pre-playback
|
|
|
|
// initialisation that you need..
|
|
|
|
// initialisation that you need..
|
|
|
|
verb.reset();
|
|
|
|
verb.reset();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
juce::IIRFilter* one_l = new juce::IIRFilter();
|
|
|
|
|
|
|
|
juce::IIRFilter* one_r = new juce::IIRFilter();
|
|
|
|
|
|
|
|
juce::IIRFilter* two_l = new juce::IIRFilter();
|
|
|
|
|
|
|
|
juce::IIRFilter* two_r = new juce::IIRFilter();
|
|
|
|
|
|
|
|
juce::IIRFilter* three_l = new juce::IIRFilter();
|
|
|
|
|
|
|
|
juce::IIRFilter* three_r = new juce::IIRFilter();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
filters_l.push_back(one_l);
|
|
|
|
|
|
|
|
filters_l.push_back(two_l);
|
|
|
|
|
|
|
|
filters_l.push_back(three_l);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
filters_r.push_back(one_r);
|
|
|
|
|
|
|
|
filters_r.push_back(two_r);
|
|
|
|
|
|
|
|
filters_r.push_back(three_r);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ReverbAudioProcessor::releaseResources()
|
|
|
|
void ReverbAudioProcessor::releaseResources()
|
|
|
@ -131,6 +149,8 @@ void ReverbAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer, juce:
|
|
|
|
juce::ScopedNoDenormals noDenormals;
|
|
|
|
juce::ScopedNoDenormals noDenormals;
|
|
|
|
auto totalNumInputChannels = getTotalNumInputChannels();
|
|
|
|
auto totalNumInputChannels = getTotalNumInputChannels();
|
|
|
|
auto totalNumOutputChannels = getTotalNumOutputChannels();
|
|
|
|
auto totalNumOutputChannels = getTotalNumOutputChannels();
|
|
|
|
|
|
|
|
if (totalNumInputChannels != 2) // Logic will fail AU tests if this isn't here
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// In case we have more outputs than inputs, this code clears any output
|
|
|
|
// In case we have more outputs than inputs, this code clears any output
|
|
|
@ -149,18 +169,77 @@ void ReverbAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer, juce:
|
|
|
|
// Alternatively, you can process the samples with the channels
|
|
|
|
// Alternatively, you can process the samples with the channels
|
|
|
|
// interleaved by keeping the same state.
|
|
|
|
// interleaved by keeping the same state.
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
for (int channel = 0; channel < totalNumInputChannels; ++channel)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
auto* channelData = buffer.getWritePointer (channel);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ..do something to the data...
|
|
|
|
|
|
|
|
}
|
|
|
|
auto* channel_one = buffer.getWritePointer(0);
|
|
|
|
*/
|
|
|
|
auto* channel_two = buffer.getWritePointer(1);
|
|
|
|
|
|
|
|
auto num_samples = buffer.getNumSamples();
|
|
|
|
|
|
|
|
|
|
|
|
update_verb();
|
|
|
|
update_verb();
|
|
|
|
verb.processStereo(buffer.getWritePointer(0), buffer.getWritePointer(1),
|
|
|
|
verb.processStereo(channel_one, channel_two,
|
|
|
|
buffer.getNumSamples());
|
|
|
|
num_samples);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setup_filter();
|
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
|
|
|
|
filters_l[i]->processSamples(channel_one, num_samples);
|
|
|
|
|
|
|
|
filters_r[i]->processSamples(channel_two, num_samples);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//filter_l->processSamples(channel_one, num_samples);
|
|
|
|
|
|
|
|
//filter_r->processSamples(channel_two, num_samples);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (auto i = 0; i < num_samples; i++) {
|
|
|
|
|
|
|
|
*buffer.getWritePointer(0, i) = (*buffer.getReadPointer(0, i)) * out->get();
|
|
|
|
|
|
|
|
*buffer.getWritePointer(1, i) = (*buffer.getReadPointer(1, i)) * out->get();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ReverbAudioProcessor::setup_filter()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
juce::IIRCoefficients coef = juce::IIRCoefficients();
|
|
|
|
|
|
|
|
if (lofi->get()) {
|
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
|
|
|
|
//filters_l[i]->reset();
|
|
|
|
|
|
|
|
//filters_r[i]->reset();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
filters_l[0]->setCoefficients(coef.makeBandPass(sample_rate, tone_val->get() * 24000));
|
|
|
|
|
|
|
|
filters_r[0]->setCoefficients(coef.makeBandPass(sample_rate, tone_val->get() * 24000));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i < 3; i++) {
|
|
|
|
|
|
|
|
filters_r[i]->makeInactive();
|
|
|
|
|
|
|
|
filters_l[i]->makeInactive();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
|
|
|
|
//filters_l[i]->reset();
|
|
|
|
|
|
|
|
//filters_r[i]->reset();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
filters_l[0]->setCoefficients(coef.makeHighPass(sample_rate, 85.0));
|
|
|
|
|
|
|
|
filters_r[0]->setCoefficients(coef.makeHighPass(sample_rate, 85.0));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float expanded_freq = 0;
|
|
|
|
|
|
|
|
if (tone_val->get() == 0.5) {
|
|
|
|
|
|
|
|
expanded_freq = 12000.0;
|
|
|
|
|
|
|
|
} else if (tone_val->get() < 0.5) {
|
|
|
|
|
|
|
|
expanded_freq = (tone_val->get() * 2) * (12000 - 5000) + 5000; // need to expand the normalized range
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
expanded_freq = ((tone_val->get() - 0.5) * 2) * (20000 - 12000) + 12000; // need to expand the normalized range
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
filters_l[1]->setCoefficients(coef.makeLowPass(sample_rate, expanded_freq));
|
|
|
|
|
|
|
|
filters_r[1]->setCoefficients(coef.makeLowPass(sample_rate, expanded_freq));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//filters_l[2]->setCoefficients(coef.makePeakFilter(sample_rate, 6000, 0.4, 1));
|
|
|
|
|
|
|
|
//filters_r[2]->setCoefficients(coef.makePeakFilter(sample_rate, 6000, 0.4, 1));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
filters_l[2]->makeInactive(); // band boost for later?
|
|
|
|
|
|
|
|
filters_r[2]->makeInactive();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
//==============================================================================
|
|
|
@ -178,8 +257,8 @@ void ReverbAudioProcessor::update_verb()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
params.roomSize = roomSize->get();
|
|
|
|
params.roomSize = roomSize->get();
|
|
|
|
params.damping = damping->get();
|
|
|
|
params.damping = damping->get();
|
|
|
|
params.wetLevel = wetLevel->get();
|
|
|
|
params.wetLevel = wet_dry->get();
|
|
|
|
params.dryLevel = dryLevel->get();
|
|
|
|
params.dryLevel = 1.0 - wet_dry->get();
|
|
|
|
params.width = width->get();
|
|
|
|
params.width = width->get();
|
|
|
|
params.freezeMode = freezeMode->get();
|
|
|
|
params.freezeMode = freezeMode->get();
|
|
|
|
|
|
|
|
|
|
|
@ -193,10 +272,12 @@ void ReverbAudioProcessor::getStateInformation (juce::MemoryBlock& destData)
|
|
|
|
|
|
|
|
|
|
|
|
stream.writeFloat(*roomSize);
|
|
|
|
stream.writeFloat(*roomSize);
|
|
|
|
stream.writeFloat(*damping);
|
|
|
|
stream.writeFloat(*damping);
|
|
|
|
stream.writeFloat(*wetLevel);
|
|
|
|
stream.writeFloat(*wet_dry);
|
|
|
|
stream.writeFloat(*dryLevel);
|
|
|
|
|
|
|
|
stream.writeFloat(*width);
|
|
|
|
stream.writeFloat(*width);
|
|
|
|
stream.writeFloat(*freezeMode);
|
|
|
|
stream.writeFloat(*freezeMode);
|
|
|
|
|
|
|
|
stream.writeBool(*lofi);
|
|
|
|
|
|
|
|
stream.writeFloat(*tone_val);
|
|
|
|
|
|
|
|
stream.writeFloat(*out);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ReverbAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
|
|
|
|
void ReverbAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
|
|
|
@ -204,10 +285,12 @@ void ReverbAudioProcessor::setStateInformation (const void* data, int sizeInByte
|
|
|
|
juce::MemoryInputStream stream(data, static_cast<size_t> (sizeInBytes), false);
|
|
|
|
juce::MemoryInputStream stream(data, static_cast<size_t> (sizeInBytes), false);
|
|
|
|
roomSize->setValueNotifyingHost(stream.readFloat());
|
|
|
|
roomSize->setValueNotifyingHost(stream.readFloat());
|
|
|
|
damping->setValueNotifyingHost(stream.readFloat());
|
|
|
|
damping->setValueNotifyingHost(stream.readFloat());
|
|
|
|
wetLevel->setValueNotifyingHost(stream.readFloat());
|
|
|
|
wet_dry->setValueNotifyingHost(stream.readFloat());
|
|
|
|
dryLevel->setValueNotifyingHost(stream.readFloat());
|
|
|
|
|
|
|
|
width->setValueNotifyingHost(stream.readFloat());
|
|
|
|
width->setValueNotifyingHost(stream.readFloat());
|
|
|
|
freezeMode->setValueNotifyingHost(stream.readFloat());
|
|
|
|
freezeMode->setValueNotifyingHost(stream.readFloat());
|
|
|
|
|
|
|
|
lofi->setValueNotifyingHost(stream.readBool());
|
|
|
|
|
|
|
|
tone_val->setValueNotifyingHost(stream.readFloat());
|
|
|
|
|
|
|
|
out->setValueNotifyingHost(stream.readFloat());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
//==============================================================================
|
|
|
|