Skip to content

Commit

Permalink
Import roth-air plugin
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <[email protected]>
  • Loading branch information
falkTX committed Dec 25, 2023
1 parent 1143c2e commit bc55bda
Show file tree
Hide file tree
Showing 73 changed files with 17,873 additions and 0 deletions.
1 change: 1 addition & 0 deletions libs/juce6.0/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ juce60_devices_srcs = [

juce60_extra_cpp_args = [
'-std=gnu++14',
'-Wno-free-nonheap-object',
'-Wno-non-virtual-dtor',
]
juce60_extra_include_dirs = []
Expand Down
1 change: 1 addition & 0 deletions libs/juce6.1/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ juce61_devices_srcs = [

juce61_extra_cpp_args = [
'-std=gnu++14',
'-Wno-free-nonheap-object',
'-Wno-non-virtual-dtor',
]
juce61_extra_include_dirs = []
Expand Down
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ option('plugins',
# juce6.0
'vitalium',
# juce6.1
'roth-air',
'swankyamp',
# juce7
],
Expand Down
1 change: 1 addition & 0 deletions ports-juce6.1/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ if linux_headless
else
plugins = [
'chow',
'roth-air',
'swankyamp',
]
endif
Expand Down
4,945 changes: 4,945 additions & 0 deletions ports-juce6.1/roth-air/BinaryData.cpp

Large diffs are not rendered by default.

63 changes: 63 additions & 0 deletions ports-juce6.1/roth-air/BinaryData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/* =========================================================================================
This is an auto-generated file: Any edits you make may be overwritten!
*/

#pragma once

namespace BinaryData
{
extern const char* airText_png;
const int airText_pngSize = 22392;

extern const char* bigKnob_light_png;
const int bigKnob_light_pngSize = 60475;

extern const char* bigKnob_red_png;
const int bigKnob_red_pngSize = 38916;

extern const char* bigKnob_png;
const int bigKnob_pngSize = 47504;

extern const char* label_freq_png;
const int label_freq_pngSize = 21456;

extern const char* label_gain_png;
const int label_gain_pngSize = 21661;

extern const char* label_mix_png;
const int label_mix_pngSize = 21577;

extern const char* label_thresh_png;
const int label_thresh_pngSize = 21704;

extern const char* smallKnob_light_png;
const int smallKnob_light_pngSize = 31141;

extern const char* smallKnob_png;
const int smallKnob_pngSize = 31445;

extern const char* title_png;
const int title_pngSize = 24948;

extern const char* website_png;
const int website_pngSize = 23975;

// Number of elements in the namedResourceList and originalFileNames arrays.
const int namedResourceListSize = 12;

// Points to the start of a list of resource names.
extern const char* namedResourceList[];

// Points to the start of a list of resource filenames.
extern const char* originalFilenames[];

// If you provide the name of one of the binary resource variables above, this function will
// return the corresponding data and its size (or a null pointer if the name isn't found).
const char* getNamedResource (const char* resourceNameUTF8, int& dataSizeInBytes);

// If you provide the name of one of the binary resource variables above, this function will
// return the corresponding original, non-mangled filename (or a null pointer if the name isn't found).
const char* getNamedResourceOriginalFilename (const char* resourceNameUTF8);
}
295 changes: 295 additions & 0 deletions ports-juce6.1/roth-air/Compressor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,295 @@
/*---------------------------------------------------
Compressor
==========
A simple feed forward compressor for use in AIR plugin
A simplified implementation of Martin Zuther's "Squeezer" with some modifications
https://github.com/mzuther/Squeezer
-----------------------------------------------------*/

#include <float.h>
#include "Compressor.h"

//====================================================

Compressor::Compressor(int channels, int sample_rate) :
// Set de-normalization params to float and double absolute minimum
fDeNormal(FLT_MIN),
dDeNormal(DBL_MIN),
dBufferLength(0.1),
nChannels(channels),
nSampleRate(sample_rate)
{
jassert((channels == 1) || (channels == 2));

bufInputSamples.clear();
bufSideChainSamples.clear();
bufOutputSamples.clear();

bufInputSamples.setSize(nChannels, 1);
bufSideChainSamples.setSize(nChannels, 1);
bufOutputSamples.setSize(nChannels, 1);

dCrestFactor = 20.0;
dReleaseCoefLinear = 26 * dBufferLength / 3.0;

setMakeupGain(0.0);

// Clear the sidechain array in case of junk
p_arrSideChain.clear();

// Add sidechain objects and add an entry for each channel into the sample buffers
for (int nChannel = 0; nChannel < 2; ++nChannel)
{
// Make a new sidechain element for each channel
p_arrSideChain.add(new SideChain(nSampleRate));
}
}

Compressor::~Compressor() {

}

double Compressor::getDetectorRmsFilter()
/* Get current detector RMS rate.
return value (double): returns current detector RMS rate*/
{
return p_arrSideChain[0]->getDetectorRmsFilter();
}

void Compressor::setDetectorRmsFilter(double dDetectorRateMsNew)
/* Set new detector RMS rate.
dDetectorRateMsNew (double): new detector RMS filter rate
return value: none*/
{
for (int nChannel = 0; nChannel < nChannels; ++nChannel)
{
p_arrSideChain[nChannel]->setDetectorRmsFilter(dDetectorRateMsNew);
}
}

double Compressor::getThreshold()
/* Get current threshold
return value (double): current threshold in dB*/
{
return p_arrSideChain[0]->getThreshold();
}

void Compressor::setThreshold(double dThresholdNew)
/* Set new threshold.
dThresholdNew (double): new threshold in dB
return value: none*/
{
for (int nChannel = 0; nChannel < nChannels; ++nChannel)
{
p_arrSideChain[nChannel]->setThreshold(dThresholdNew);
}
}

double Compressor::getRatio()
/* Get current comp ratio.
return value (double): returns current ratio*/
{
double dRatioNew = p_arrSideChain[0]->getRatio();

return dRatioNew;
}

void Compressor::setRatio(double dRatioNew)
/* Set new ratio.
dRatioNew (double): new ratio
return value: none*/
{
for (int nChannel = 0; nChannel < nChannels; ++nChannel)
{
p_arrSideChain[nChannel]->setRatio(dRatioNew);
}
}

int Compressor::getAttackRate()
/* Get current attack rate.
return value (int): returns the current attack rate in ms*/
{
return p_arrSideChain[0]->getAttackRate();
}

void Compressor::setAttackRate(int nAttackRateNew)
/* Set new attack rate.
nAttackRateNew (int): new attack rate in ms
return value: none*/
{
for (int nChannel = 0; nChannel < nChannels; ++nChannel)
{
p_arrSideChain[nChannel]->setAttackRate(nAttackRateNew);
}
}

int Compressor::getReleaseRate()
/* Get current release rate.
return value (int): returns the current release rate in ms*/
{
return p_arrSideChain[0]->getReleaseRate();
}

void Compressor::setReleaseRate(int nReleaseRateNew)
/* Set new release rate.
nReleaseRateNew (int): new release rate in ms
return value: none*/
{
for (int nChannel = 0; nChannel < nChannels; ++nChannel)
{
p_arrSideChain[nChannel]->setReleaseRate(nReleaseRateNew);
}
}

double Compressor::getMakeupGain()
/* Get current make-up gain.
return value (double): current make-up gain in dB*/
{
return dMakeupGainDb;
}

void Compressor::setMakeupGain(double dMakeupGainNew)
/* Set new make-up gain.
nMakeupGainNew (double): new makeup gain in dB
return value: none*/
{
dMakeupGainDb = dMakeupGainNew;
dMakeupGain = SideChain::dbtolvl(dMakeupGainDb);
}

double Compressor::getGainReduction(int nChannel)
/* Get current gain reduction.
nChannel (int): queried audio channel
return value (double): returns current gain reduction in dB*/
{
jassert(nChannel >= 0);
jassert(nChannel < nChannels);

return arrGainReduction[nChannel];
}

double Compressor::getGainReductionPeak(int nChannel)
/* Get current peak gain reduction
nChannel (int): queried audio channel
return value (double): returns current peak gain reduction in dB*/
{
jassert(nChannel >= 0);
jassert(nChannel < nChannels);

return arrGainReductionPeak[nChannel];
}

double Compressor::getSampleRate()
{
return p_arrSideChain[0]->getSampleRate();
}

void Compressor::setSampleRate(double newSampleRate)
{
if (newSampleRate != p_arrSideChain[0]->getSampleRate())
{
for (int nChannel = 0; nChannel < nChannels; ++nChannel)
{
p_arrSideChain[nChannel]->setSampleRate(newSampleRate);
}

nSampleRate = (int)newSampleRate;
}
}

void Compressor::resetSideChain() {
for (int nChannel = 0; nChannel < 2; ++nChannel)
{
p_arrSideChain[nChannel]->reset();
}
}

double Compressor::getTempGainReduction()
{
return tempGainReduction;
}

void Compressor::processBlock(AudioBuffer<float> &buffer)
{
int nNumSamples = buffer.getNumSamples();

// Loop through samples
for (int nSample = 0; nSample < nNumSamples; ++nSample)
{
// Get input samples, de-normalize and store in buffer
for (int nChannel = 0; nChannel < nChannels; ++nChannel)
{
// Get current input sample (both as float and as double)
float fInputSample = buffer.getSample(nChannel, nSample);
double dInputSample = (double) fInputSample;

// Remove denormal numbers input samples
fInputSample += fDeNormal;
dInputSample += dDeNormal;
fInputSample -= fDeNormal;
dInputSample -= dDeNormal;

// jassert(arrInputSamples.size() == 2 && arrSidechainSamples.size() == 2 && arrOutputSamples.size() == 2);

// Store de-normalized input sample
// arrInputSamples.set(nChannel, dInputSample);
bufInputSamples.setSample(nChannel, 0, dInputSample);

// Process each channel instead of stereo linking (for channel compability)
// arrSidechainSamples.set(nChannel, arrInputSamples[nChannel]);
bufSideChainSamples.setSample(nChannel, 0, bufInputSamples.getSample(nChannel, 0));

// Calculate level of sidechain sample
double dSideChainInputLevel = SideChain::lvltodb(fabs(bufSideChainSamples.getSample(nChannel, 0)));

// Apply crest factor
dSideChainInputLevel += dCrestFactor;

// Send current input sample to gain reduction
p_arrSideChain[nChannel]->processSample(dSideChainInputLevel);

// Store gain reduction (might only be for metering)
// arrGainReduction.set(nChannel, p_arrSideChain[nChannel]->getGainReduction());

// Apply gain reduction to current input sample
double dGainReduction = p_arrSideChain[nChannel]->getGainReduction();
tempGainReduction = dGainReduction;

// arrOutputSamples.set(nChannel, arrInputSamples[nChannel] / SideChain::dbtolvl(dGainReduction));
bufOutputSamples.setSample(nChannel, 0, bufInputSamples.getSample(nChannel, 0) / SideChain::dbtolvl(dGainReduction));

// arrOutputSamples.set(nChannel, arrOutputSamples[nChannel] * dMakeupGain);
bufOutputSamples.setSample(nChannel, 0, bufOutputSamples.getSample(nChannel, 0) * dMakeupGain);

// Set sample to output buffer
// float fOutput = arrOutputSamples[nChannel];
float fOutput = bufOutputSamples.getSample(nChannel, 0);
buffer.setSample(nChannel, nSample, fOutput);
}
}
}
Loading

0 comments on commit bc55bda

Please sign in to comment.