mirror of
https://codeberg.org/armin/pascalcompressor.git
synced 2026-10-11 16:51:56 +02:00
Add compressor plugin source with build files
This commit is contained in:
parent
b0fef386ee
commit
ef5739546f
10 changed files with 925 additions and 0 deletions
109
Source/PluginProcessor.cpp
Normal file
109
Source/PluginProcessor.cpp
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
#include "PluginProcessor.h"
|
||||
#include "PluginEditor.h"
|
||||
|
||||
PascalcompressorAudioProcessor::PascalcompressorAudioProcessor()
|
||||
: AudioProcessor (BusesProperties()
|
||||
.withInput ("Input", juce::AudioChannelSet::stereo(), true)
|
||||
.withOutput ("Output", juce::AudioChannelSet::stereo(), true)),
|
||||
apvts (*this, nullptr, "PARAMS", createParameterLayout())
|
||||
{
|
||||
}
|
||||
|
||||
PascalcompressorAudioProcessor::~PascalcompressorAudioProcessor() = default;
|
||||
|
||||
juce::AudioProcessorValueTreeState::ParameterLayout PascalcompressorAudioProcessor::createParameterLayout()
|
||||
{
|
||||
juce::AudioProcessorValueTreeState::ParameterLayout layout;
|
||||
|
||||
layout.add (std::make_unique<juce::AudioParameterFloat> ("input",
|
||||
"Input", juce::NormalisableRange<float> (-24.0f, 24.0f, 0.1f, 1.0f), 0.0f));
|
||||
|
||||
layout.add (std::make_unique<juce::AudioParameterFloat> ("threshold",
|
||||
"Threshold", juce::NormalisableRange<float> (-60.0f, 0.0f, 0.1f, 1.0f), -18.0f));
|
||||
|
||||
layout.add (std::make_unique<juce::AudioParameterFloat> ("ratio",
|
||||
"Ratio", juce::NormalisableRange<float> (1.0f, 20.0f, 0.05f, 0.4f), 2.0f));
|
||||
|
||||
layout.add (std::make_unique<juce::AudioParameterFloat> ("attack",
|
||||
"Attack", juce::NormalisableRange<float> (0.1f, 200.0f, 0.1f, 0.35f), 10.0f));
|
||||
|
||||
layout.add (std::make_unique<juce::AudioParameterFloat> ("release",
|
||||
"Release", juce::NormalisableRange<float> (10.0f, 3000.0f, 1.0f, 0.35f), 250.0f));
|
||||
|
||||
layout.add (std::make_unique<juce::AudioParameterFloat> ("makeup",
|
||||
"Makeup", juce::NormalisableRange<float> (0.0f, 24.0f, 0.1f, 1.0f), 0.0f));
|
||||
|
||||
layout.add (std::make_unique<juce::AudioParameterFloat> ("drywet",
|
||||
"Dry/Wet", juce::NormalisableRange<float> (0.0f, 100.0f, 1.0f, 1.0f), 100.0f));
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
void PascalcompressorAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
|
||||
{
|
||||
juce::dsp::ProcessSpec spec;
|
||||
spec.sampleRate = sampleRate;
|
||||
spec.maximumBlockSize = static_cast<juce::uint32> (samplesPerBlock);
|
||||
spec.numChannels = static_cast<juce::uint32> (juce::jmax (1, getTotalNumInputChannels()));
|
||||
compressor.prepare (spec);
|
||||
}
|
||||
|
||||
void PascalcompressorAudioProcessor::releaseResources()
|
||||
{
|
||||
}
|
||||
|
||||
void PascalcompressorAudioProcessor::updateParameters()
|
||||
{
|
||||
compressor.setInputDb (*apvts.getRawParameterValue ("input"));
|
||||
compressor.setThresholdDb (*apvts.getRawParameterValue ("threshold"));
|
||||
compressor.setRatio (*apvts.getRawParameterValue ("ratio"));
|
||||
compressor.setAttackMs (*apvts.getRawParameterValue ("attack"));
|
||||
compressor.setReleaseMs (*apvts.getRawParameterValue ("release"));
|
||||
compressor.setMakeupDb (*apvts.getRawParameterValue ("makeup"));
|
||||
compressor.setDryWet (*apvts.getRawParameterValue ("drywet") * 0.01f);
|
||||
}
|
||||
|
||||
void PascalcompressorAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer,
|
||||
juce::MidiBuffer&)
|
||||
{
|
||||
updateParameters();
|
||||
|
||||
if (getTotalNumInputChannels() > 0)
|
||||
compressor.processBlock (buffer);
|
||||
}
|
||||
|
||||
bool PascalcompressorAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const
|
||||
{
|
||||
if (layouts.getMainOutputChannelSet() != juce::AudioChannelSet::mono()
|
||||
&& layouts.getMainOutputChannelSet() != juce::AudioChannelSet::stereo())
|
||||
return false;
|
||||
|
||||
if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
juce::AudioProcessorEditor* PascalcompressorAudioProcessor::createEditor()
|
||||
{
|
||||
return new pascal::PascalcompressorAudioProcessorEditor (*this);
|
||||
}
|
||||
|
||||
void PascalcompressorAudioProcessor::getStateInformation (juce::MemoryBlock& destData)
|
||||
{
|
||||
auto state = apvts.copyState();
|
||||
std::unique_ptr<juce::XmlElement> xml (state.createXml());
|
||||
copyXmlToBinary (*xml, destData);
|
||||
}
|
||||
|
||||
void PascalcompressorAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
|
||||
{
|
||||
std::unique_ptr<juce::XmlElement> xmlState (getXmlFromBinary (data, sizeInBytes));
|
||||
if (xmlState != nullptr && xmlState->hasTagName (apvts.state.getType()))
|
||||
apvts.replaceState (juce::ValueTree::fromXml (*xmlState));
|
||||
}
|
||||
|
||||
juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter()
|
||||
{
|
||||
return new PascalcompressorAudioProcessor();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue