mirror of
https://github.com/vale981/openAV-Luppp
synced 2025-03-05 09:01:39 -05:00
-Ducking based on sidechain amplitude implemented
This commit is contained in:
parent
c7ea67f8b0
commit
ba515fe76d
4 changed files with 47 additions and 27 deletions
|
@ -5,6 +5,11 @@
|
|||
#include <cmath>
|
||||
|
||||
SidechainGain::SidechainGain(int rate) :
|
||||
/// initial control values
|
||||
controlThreshold(0.2),
|
||||
controlReduction(1),
|
||||
controlReleaseTime(0.5),
|
||||
|
||||
/// filter state init
|
||||
w(10.0f / (rate * 0.02)),
|
||||
a(0.07f),
|
||||
|
@ -12,9 +17,9 @@ SidechainGain::SidechainGain(int rate) :
|
|||
g1(0.0f),
|
||||
g2(0.0f),
|
||||
|
||||
|
||||
peakFrameCounter(0),
|
||||
peakCountDuration( rate / 4 ),
|
||||
|
||||
currentTarget(0)
|
||||
{
|
||||
}
|
||||
|
@ -26,7 +31,7 @@ void SidechainGain::process(unsigned int n_samples, float** inputs, float** outp
|
|||
float* inR = inputs[1];
|
||||
float* side = inputs[2];
|
||||
float* outL = outputs[0];
|
||||
float* outR = outputs[0];
|
||||
float* outR = outputs[1];
|
||||
|
||||
/// control inputs
|
||||
float threshold = controlThreshold;
|
||||
|
|
51
src/jack.cxx
51
src/jack.cxx
|
@ -85,7 +85,10 @@ Jack::Jack() :
|
|||
|
||||
/// setup FX
|
||||
reverb = new Reverb( buffers.samplerate );
|
||||
reverb->dryWet( 0.5 );
|
||||
reverb->dryWet( 1 );
|
||||
|
||||
sidechainGain = new SidechainGain( buffers.samplerate );
|
||||
|
||||
|
||||
reverbMeter = new DBMeter( buffers.samplerate );
|
||||
masterMeter = new DBMeter( buffers.samplerate );
|
||||
|
@ -177,16 +180,11 @@ int Jack::process (jack_nframes_t nframes)
|
|||
trackOutputs.at(i)->process( nframes, &buffers );
|
||||
}
|
||||
|
||||
|
||||
metronome->process( nframes, &buffers );
|
||||
|
||||
|
||||
// process fx
|
||||
/// process reverb
|
||||
float* buf[] = {
|
||||
buffers.audio[Buffers::REVERB],
|
||||
buffers.audio[Buffers::REVERB]
|
||||
};
|
||||
|
||||
//if ( reverb->getActive() )
|
||||
{
|
||||
reverbMeter->process(nframes, buffers.audio[Buffers::REVERB], buffers.audio[Buffers::REVERB] );
|
||||
|
@ -194,9 +192,34 @@ int Jack::process (jack_nframes_t nframes)
|
|||
}
|
||||
|
||||
|
||||
/// process sidechain gaining
|
||||
float* sidechainBuf[] = {
|
||||
// input
|
||||
buffers.audio[Buffers::MASTER_OUT_L],
|
||||
buffers.audio[Buffers::MASTER_OUT_R],
|
||||
buffers.audio[Buffers::SIDECHAIN],
|
||||
// output
|
||||
buffers.audio[Buffers::MASTER_OUT_L],
|
||||
buffers.audio[Buffers::MASTER_OUT_R]
|
||||
};
|
||||
|
||||
sidechainGain->process( nframes, &sidechainBuf[0], &sidechainBuf[3] );
|
||||
|
||||
/// metro signal after sidechain-gain, so its loud on the beats
|
||||
metronome->process( nframes, &buffers );
|
||||
|
||||
/// mix reverb & post-sidechain in
|
||||
for(unsigned int i = 0; i < buffers.nframes; i++)
|
||||
{
|
||||
float rev = buffers.audio[Buffers::REVERB][i];
|
||||
float post = buffers.audio[Buffers::POST_SIDECHAIN][i];
|
||||
|
||||
buffers.audio[Buffers::MASTER_OUT_L][i] += rev + post;
|
||||
buffers.audio[Buffers::MASTER_OUT_R][i] += rev + post;
|
||||
}
|
||||
|
||||
|
||||
// db meter on master output, then memcpy to JACK
|
||||
/// db meter on master
|
||||
masterMeter->process(nframes, buffers.audio[Buffers::MASTER_OUT_L], buffers.audio[Buffers::MASTER_OUT_R] );
|
||||
|
||||
if ( uiUpdateCounter > uiUpdateConstant )
|
||||
|
@ -210,16 +233,6 @@ int Jack::process (jack_nframes_t nframes)
|
|||
uiUpdateCounter += nframes;
|
||||
|
||||
|
||||
for(unsigned int i = 0; i < buffers.nframes; i++)
|
||||
{
|
||||
float rev = buffers.audio[Buffers::REVERB][i];
|
||||
|
||||
buffers.audio[Buffers::MASTER_OUT_L][i] += rev;
|
||||
buffers.audio[Buffers::MASTER_OUT_R][i] += rev;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// memcpy the internal MASTER_OUTPUT buffer to the JACK_MASTER_OUTPUT
|
||||
memcpy( buffers.audio[Buffers::JACK_MASTER_OUT_L],
|
||||
buffers.audio[Buffers::MASTER_OUT_L],
|
||||
|
@ -228,7 +241,7 @@ int Jack::process (jack_nframes_t nframes)
|
|||
|
||||
memcpy( buffers.audio[Buffers::JACK_MASTER_OUT_R],
|
||||
buffers.audio[Buffers::MASTER_OUT_R],
|
||||
//buffers.audio[Buffers::TRACK_7],
|
||||
//buffers.audio[Buffers::POST_SIDECHAIN],
|
||||
//buffers.audio[Buffers::REVERB], // uncomment to listen to reverb send only
|
||||
sizeof(float)*nframes);
|
||||
|
||||
|
|
|
@ -77,6 +77,7 @@ class Jack
|
|||
|
||||
// FX
|
||||
Reverb* reverb;
|
||||
SidechainGain* sidechainGain;
|
||||
DBMeter* reverbMeter;
|
||||
DBMeter* masterMeter;
|
||||
|
||||
|
|
|
@ -86,14 +86,15 @@ void TrackOutput::process(unsigned int nframes, Buffers* buffers)
|
|||
for(unsigned int i = 0; i < nframes; i++)
|
||||
{
|
||||
// * master for "post-fader" sends
|
||||
float tmp = trackBuffer[i] * _toMaster;
|
||||
float tmp = trackBuffer[i];
|
||||
|
||||
masterL[i] += tmp;
|
||||
masterR[i] += tmp;
|
||||
// post-sidechain *moves* signal between "before/after" ducking, not add!
|
||||
masterL[i] += tmp * _toMaster * (1-_toPostSidechain);
|
||||
masterR[i] += tmp * _toMaster * (1-_toPostSidechain);
|
||||
|
||||
reverb[i] += tmp * _toReverb;
|
||||
sidechain[i] += tmp * _toSidechain;
|
||||
postSidechain[i] += tmp * _toPostSidechain;
|
||||
reverb[i] += tmp * _toReverb * _toMaster;
|
||||
sidechain[i] += tmp * _toSidechain * _toMaster;
|
||||
postSidechain[i] += tmp * _toPostSidechain * _toMaster;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue