From d1d06b6607da73d28d75a9dfe487f90f53cd48a8 Mon Sep 17 00:00:00 2001 From: Georg Krause Date: Thu, 5 Jul 2018 21:01:50 +0200 Subject: [PATCH 01/16] apply internal default naming of private vars --- src/jacksendreturn.cxx | 40 ++++++++++++++++++++-------------------- src/jacksendreturn.hxx | 20 ++++++++++---------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/jacksendreturn.cxx b/src/jacksendreturn.cxx index 2135ccb..f3f752c 100644 --- a/src/jacksendreturn.cxx +++ b/src/jacksendreturn.cxx @@ -4,28 +4,28 @@ #include extern Jack* jack; JackSendReturn::JackSendReturn(int trackid, AudioProcessor *prev, jack_client_t *client) - :m_trackid(trackid), m_previousProcessor(prev), m_sendvol(1.0f) + :_trackId(trackid), _previousProcessor(prev), _sendVol(1.0f) { char name[50]; int trackid_human = trackid + 1; sprintf(name, "Send_track_%d_l\n",trackid_human); - m_sendport_l=jack_port_register(client,name,JACK_DEFAULT_AUDIO_TYPE,JackPortIsOutput,0); + _sendPortL=jack_port_register(client,name,JACK_DEFAULT_AUDIO_TYPE,JackPortIsOutput,0); sprintf(name, "Send_track_%d_r\n",trackid_human); - m_sendport_r=jack_port_register(client,name,JACK_DEFAULT_AUDIO_TYPE,JackPortIsOutput,0); + _sendPortR=jack_port_register(client,name,JACK_DEFAULT_AUDIO_TYPE,JackPortIsOutput,0); sprintf(name, "Return_track_%d_l\n",trackid_human); - m_returnport_l=jack_port_register(client,name,JACK_DEFAULT_AUDIO_TYPE,JackPortIsInput,0); + _returnPortL=jack_port_register(client,name,JACK_DEFAULT_AUDIO_TYPE,JackPortIsInput,0); sprintf(name, "Return_track_%d_r\n",trackid_human); - m_returnport_r=jack_port_register(client,name,JACK_DEFAULT_AUDIO_TYPE,JackPortIsInput,0); - m_active=false; - m_counter=0; + _returnPortR=jack_port_register(client,name,JACK_DEFAULT_AUDIO_TYPE,JackPortIsInput,0); + _active=false; + _counter=0; } void JackSendReturn::process(unsigned int nframes, Buffers *buffers) { // index = first-track + (track * channels) - int trackoffset = m_trackid * NCHANNELS; + int trackoffset = _trackId * NCHANNELS; //Reset send buffer - int offset=m_counter%(buffers->nframes); + int offset=_counter%(buffers->nframes); float* sendtrackL=&(buffers->audio[Buffers::SEND_TRACK_0_L + trackoffset][0]); float* sendtrackR=&(buffers->audio[Buffers::SEND_TRACK_0_R + trackoffset][0]); @@ -37,12 +37,12 @@ void JackSendReturn::process(unsigned int nframes, Buffers *buffers) memset(sendtrackR,0,nframes*sizeof(float)); //Process previous AudioProcessor - m_previousProcessor->process(nframes,buffers); + _previousProcessor->process(nframes,buffers); - float* sendL=(float*)jack_port_get_buffer(m_sendport_l, (jack_nframes_t)(buffers->nframes)); - float* sendR=(float*)jack_port_get_buffer(m_sendport_r, (jack_nframes_t)(buffers->nframes)); - float* retL =(float*)jack_port_get_buffer(m_returnport_l,(jack_nframes_t)(buffers->nframes)); - float* retR =(float*)jack_port_get_buffer(m_returnport_r,(jack_nframes_t)(buffers->nframes)); + float* sendL=(float*)jack_port_get_buffer(_sendPortL, (jack_nframes_t)(buffers->nframes)); + float* sendR=(float*)jack_port_get_buffer(_sendPortR, (jack_nframes_t)(buffers->nframes)); + float* retL =(float*)jack_port_get_buffer(_returnPortL,(jack_nframes_t)(buffers->nframes)); + float* retR =(float*)jack_port_get_buffer(_returnPortR,(jack_nframes_t)(buffers->nframes)); if(offset) { sendL+=offset; @@ -52,14 +52,14 @@ void JackSendReturn::process(unsigned int nframes, Buffers *buffers) } for(int i=0; inframes); - if(m_active) { + if(_active) { memcpy(rettrackL,retL,nframes*sizeof(float)); memcpy(rettrackR,retR,nframes*sizeof(float)); } @@ -67,16 +67,16 @@ void JackSendReturn::process(unsigned int nframes, Buffers *buffers) memcpy(rettrackL, sendtrackL,nframes*sizeof(float)); memcpy(rettrackR, sendtrackR,nframes*sizeof(float)); } - m_counter+=nframes; + _counter+=nframes; } void JackSendReturn::activate(bool act) { - m_active=act; + _active=act; } void JackSendReturn::sendVolume(float vol) { - m_sendvol=vol; + _sendVol=vol; } diff --git a/src/jacksendreturn.hxx b/src/jacksendreturn.hxx index e2fc3f6..36841d2 100644 --- a/src/jacksendreturn.hxx +++ b/src/jacksendreturn.hxx @@ -37,21 +37,21 @@ public: //The process callback virtual void process(unsigned int nframes, Buffers* buffers); - //Activate the return chain. When m_active=true then Buffers::RETURN_TRACK_0+m_trackid gets the data + //Activate the return chain. When _active=true then Buffers::RETURN_TRACK_0+_trackid gets the data //from the return port. The send port always send the incoming data void activate(bool act); void sendVolume(float vol); private: - bool m_active; - float m_sendvol; - jack_port_t* m_sendport_l; - jack_port_t* m_sendport_r; - jack_port_t* m_returnport_l; - jack_port_t* m_returnport_r; - int m_trackid; - AudioProcessor* m_previousProcessor; - int m_counter; + bool _active; + float _sendVol; + jack_port_t* _sendPortL; + jack_port_t* _sendPortR; + jack_port_t* _returnPortL; + jack_port_t* _returnPortR; + int _trackId; + AudioProcessor* _previousProcessor; + int _counter; }; #endif From 079154cc601830d4aaef38a33d44aa00ed4afb2f Mon Sep 17 00:00:00 2001 From: Georg Krause Date: Thu, 5 Jul 2018 21:18:54 +0200 Subject: [PATCH 02/16] apply smoothing to fx sends --- src/jacksendreturn.cxx | 6 ++++-- src/jacksendreturn.hxx | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/jacksendreturn.cxx b/src/jacksendreturn.cxx index f3f752c..2b3be95 100644 --- a/src/jacksendreturn.cxx +++ b/src/jacksendreturn.cxx @@ -52,8 +52,10 @@ void JackSendReturn::process(unsigned int nframes, Buffers *buffers) } for(int i=0; i Date: Thu, 5 Jul 2018 21:51:26 +0200 Subject: [PATCH 03/16] apply smoothing to fx send button --- src/jacksendreturn.cxx | 14 ++++++-------- src/jacksendreturn.hxx | 2 ++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/jacksendreturn.cxx b/src/jacksendreturn.cxx index 2b3be95..061a79e 100644 --- a/src/jacksendreturn.cxx +++ b/src/jacksendreturn.cxx @@ -17,6 +17,7 @@ JackSendReturn::JackSendReturn(int trackid, AudioProcessor *prev, jack_client_t sprintf(name, "Return_track_%d_r\n",trackid_human); _returnPortR=jack_port_register(client,name,JACK_DEFAULT_AUDIO_TYPE,JackPortIsInput,0); _active=false; + _activeLag = 0; _counter=0; } @@ -56,19 +57,16 @@ void JackSendReturn::process(unsigned int nframes, Buffers *buffers) sendL[i] = _sendVolLag * sendtrackL[i]; sendR[i] = _sendVolLag * sendtrackR[i]; + + _activeLag += SMOOTHING_CONST * (float(_active) - _activeLag); + + rettrackL[i] = retL[i] * _activeLag + sendtrackL[i] * std::fabs(_activeLag - 1); + rettrackR[i] = retR[i] * _activeLag + sendtrackR[i] * std::fabs(_activeLag - 1); } if(offset) assert(offset+nframes==buffers->nframes); - if(_active) { - memcpy(rettrackL,retL,nframes*sizeof(float)); - memcpy(rettrackR,retR,nframes*sizeof(float)); - } - else { - memcpy(rettrackL, sendtrackL,nframes*sizeof(float)); - memcpy(rettrackR, sendtrackR,nframes*sizeof(float)); - } _counter+=nframes; } diff --git a/src/jacksendreturn.hxx b/src/jacksendreturn.hxx index eee9a3a..4c0704c 100644 --- a/src/jacksendreturn.hxx +++ b/src/jacksendreturn.hxx @@ -44,6 +44,8 @@ public: private: bool _active; + float _activeLag; + float _sendVol; float _sendVolLag; From 4a176c2d963edbb3aa05eb0c102a4fdeb93cb29c Mon Sep 17 00:00:00 2001 From: Georg Krause Date: Mon, 9 Jul 2018 11:23:46 +0200 Subject: [PATCH 04/16] reduce smoothing const This values introduces a latency of 5ms on 44.1kHz which shouldn't be noticable for anyone. At least I can't notice it. This will be the base for calculating the smoothing value based on the samplerate, because higher samplerates need other values. --- src/config.hxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/config.hxx b/src/config.hxx index 6e07473..c594b29 100644 --- a/src/config.hxx +++ b/src/config.hxx @@ -70,8 +70,7 @@ #define LUPPP_RETURN_ERROR 2 // Smoothing value -#define SMOOTHING_CONST 0.05 - +#define SMOOTHING_CONST 0.005 /// debug.hxx for printing convienience #include "debug.hxx" From eff6d2a8244aef8c739972aced4fcef19837a2bd Mon Sep 17 00:00:00 2001 From: Georg Krause Date: Mon, 9 Jul 2018 11:30:47 +0200 Subject: [PATCH 05/16] apply smoothing to Postfader Sends (Snd-Button) --- src/trackoutput.cxx | 16 ++++++++++------ src/trackoutput.hxx | 2 ++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/trackoutput.cxx b/src/trackoutput.cxx index b026a99..fd925a3 100644 --- a/src/trackoutput.cxx +++ b/src/trackoutput.cxx @@ -51,6 +51,8 @@ TrackOutput::TrackOutput(int t, AudioProcessor* ap) : _toPostSidechainLag = 0.0; _toPostfaderActive = 0; + _toPostfaderActiveLag = 0; + _toKeyActive = 0; _toXSideActive = true; } @@ -185,7 +187,10 @@ void TrackOutput::process(unsigned int nframes, Buffers* buffers) // compute sidechain signal lag _toPostSidechainLag += SMOOTHING_CONST * (_toPostSidechain - _toPostSidechainLag); - + + // compute discrete lag values + _toPostfaderActiveLag += SMOOTHING_CONST * (float(_toPostfaderActive) - _toPostfaderActiveLag); + // * master for "post-fader" sends float tmpL = trackBufferL[i]; float tmpR = trackBufferR[i]; @@ -197,11 +202,10 @@ void TrackOutput::process(unsigned int nframes, Buffers* buffers) jackoutputL[i] = tmpL * _toMasterLag * (1-_toPostSidechainLag); if(jackoutputR) jackoutputR[i] = tmpR * _toMasterLag * (1-_toPostSidechainLag); - if ( _toPostfaderActive ) { - sendL[i] += tmpL * _toSendLag * _toMasterLag; - sendR[i] += tmpR * _toSendLag * _toMasterLag; - } - + + sendL[i] += tmpL * _toSendLag * _toMasterLag * _toPostfaderActiveLag; + sendR[i] += tmpR * _toSendLag * _toMasterLag * _toPostfaderActiveLag; + if ( _toXSideActive ) { postSidechainL[i] += tmpL * _toPostSidechainLag * _toMasterLag; postSidechainR[i] += tmpR * _toPostSidechainLag * _toMasterLag; diff --git a/src/trackoutput.hxx b/src/trackoutput.hxx index 1ed2ebe..25b29ec 100644 --- a/src/trackoutput.hxx +++ b/src/trackoutput.hxx @@ -80,6 +80,8 @@ private: float _toPostSidechainLag; bool _toPostfaderActive; + float _toPostfaderActiveLag; + bool _toKeyActive; bool _toXSideActive; From 73662713d37536e7cb703b91c1df0655e70a89fe Mon Sep 17 00:00:00 2001 From: Georg Krause Date: Mon, 9 Jul 2018 11:40:14 +0200 Subject: [PATCH 06/16] apply smoothing to sidechain key control --- src/trackoutput.cxx | 14 +++++++------- src/trackoutput.hxx | 2 ++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/trackoutput.cxx b/src/trackoutput.cxx index fd925a3..cf1bd1c 100644 --- a/src/trackoutput.cxx +++ b/src/trackoutput.cxx @@ -52,8 +52,10 @@ TrackOutput::TrackOutput(int t, AudioProcessor* ap) : _toPostfaderActive = 0; _toPostfaderActiveLag = 0; - + _toKeyActive = 0; + _toKeyActiveLag = 0; + _toXSideActive = true; } @@ -190,7 +192,8 @@ void TrackOutput::process(unsigned int nframes, Buffers* buffers) // compute discrete lag values _toPostfaderActiveLag += SMOOTHING_CONST * (float(_toPostfaderActive) - _toPostfaderActiveLag); - + _toKeyActiveLag += SMOOTHING_CONST * (float(_toKeyActive) - _toKeyActiveLag); + // * master for "post-fader" sends float tmpL = trackBufferL[i]; float tmpR = trackBufferR[i]; @@ -212,11 +215,8 @@ void TrackOutput::process(unsigned int nframes, Buffers* buffers) } // turning down an element in the mix should *NOT* influence sidechaining - if ( _toKeyActive ) { - sidechainL[i] += tmpL; - sidechainR[i] += tmpR; - } - + sidechainL[i] += tmpL * _toKeyActiveLag; + sidechainR[i] += tmpR * _toKeyActiveLag; } } diff --git a/src/trackoutput.hxx b/src/trackoutput.hxx index 25b29ec..21428ae 100644 --- a/src/trackoutput.hxx +++ b/src/trackoutput.hxx @@ -83,6 +83,8 @@ private: float _toPostfaderActiveLag; bool _toKeyActive; + float _toKeyActiveLag; + bool _toXSideActive; /// Pointer to "previous" processor: the graph is backwards From 8b9b3bce441131061b7a9eecdd09612f26eadd45 Mon Sep 17 00:00:00 2001 From: Georg Krause Date: Mon, 9 Jul 2018 13:26:30 +0200 Subject: [PATCH 07/16] apply smoothing to input to mix volume --- src/jack.cxx | 12 ++++++++---- src/jack.hxx | 4 +++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/jack.cxx b/src/jack.cxx index 706acaa..e34fa71 100644 --- a/src/jack.cxx +++ b/src/jack.cxx @@ -204,6 +204,7 @@ Jack::Jack( std::string name ) : inputToSendEnable = false; inputToKeyEnable = false; inputToMixVol = 0.f; + inputToMixVolLag = 0.f; inputToSendVol = 0.f; inputToXSideVol = 0.f; @@ -536,6 +537,9 @@ void Jack::processFrames(int nframes) /// mix input, reverb & post-sidechain in for(unsigned int i = 0; i < nframes; i++) { + // compute *lags für smoothing + inputToMixVolLag += SMOOTHING_CONST * (inputToMixVol - inputToMixVolLag); + float inputL = buffers.audio[Buffers::MASTER_INPUT_L][i] * inputVol; float inputR = buffers.audio[Buffers::MASTER_INPUT_R][i] * inputVol; @@ -546,15 +550,15 @@ void Jack::processFrames(int nframes) if ( inputToMixEnable ) { // if sending to mix, scale by volume *and* by XSide send - float tmpL = inputL * inputToMixVol * (1-inputToXSideVol); - float tmpR = inputR * inputToMixVol * (1-inputToXSideVol); + float tmpL = inputL * inputToMixVolLag * (1-inputToXSideVol); + float tmpR = inputR * inputToMixVolLag * (1-inputToXSideVol); L += tmpL; R += tmpR; if ( inputToSendEnable ) { // post-mix-send amount: hence * inputToMixVol - buffers.audio[Buffers::SEND_L][i] += inputL * inputToSendVol * inputToMixVol; - buffers.audio[Buffers::SEND_R][i] += inputR * inputToSendVol * inputToMixVol; + buffers.audio[Buffers::SEND_L][i] += inputL * inputToSendVol * inputToMixVolLag; + buffers.audio[Buffers::SEND_R][i] += inputR * inputToSendVol * inputToMixVolLag; } } if ( inputToKeyEnable ) { diff --git a/src/jack.hxx b/src/jack.hxx index 23137b1..175614e 100644 --- a/src/jack.hxx +++ b/src/jack.hxx @@ -138,7 +138,7 @@ public: JackSendReturn *getJackSendReturn(int t); private: int lastnframes; - jack_client_t* client; + jack_client_t* client; Buffers buffers; TimeManager* timeManager; @@ -166,6 +166,8 @@ private: float returnVol; float inputToMixVol; + float inputToMixVolLag; + float inputToSendVol; float inputToXSideVol; From c7f268a45b238e2c7934c74eb3173d8e83022996 Mon Sep 17 00:00:00 2001 From: Georg Krause Date: Mon, 9 Jul 2018 13:34:13 +0200 Subject: [PATCH 08/16] apply smoothing to input to send volume --- src/jack.cxx | 6 ++++-- src/jack.hxx | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/jack.cxx b/src/jack.cxx index e34fa71..5ea9d75 100644 --- a/src/jack.cxx +++ b/src/jack.cxx @@ -206,6 +206,7 @@ Jack::Jack( std::string name ) : inputToMixVol = 0.f; inputToMixVolLag = 0.f; inputToSendVol = 0.f; + inputToSendVolLag = 0.f; inputToXSideVol = 0.f; /// prepare internal buffers @@ -539,6 +540,7 @@ void Jack::processFrames(int nframes) for(unsigned int i = 0; i < nframes; i++) { // compute *lags für smoothing inputToMixVolLag += SMOOTHING_CONST * (inputToMixVol - inputToMixVolLag); + inputToSendVolLag += SMOOTHING_CONST * (inputToSendVol - inputToSendVolLag); float inputL = buffers.audio[Buffers::MASTER_INPUT_L][i] * inputVol; float inputR = buffers.audio[Buffers::MASTER_INPUT_R][i] * inputVol; @@ -557,8 +559,8 @@ void Jack::processFrames(int nframes) if ( inputToSendEnable ) { // post-mix-send amount: hence * inputToMixVol - buffers.audio[Buffers::SEND_L][i] += inputL * inputToSendVol * inputToMixVolLag; - buffers.audio[Buffers::SEND_R][i] += inputR * inputToSendVol * inputToMixVolLag; + buffers.audio[Buffers::SEND_L][i] += inputL * inputToSendVolLag * inputToMixVolLag; + buffers.audio[Buffers::SEND_R][i] += inputR * inputToSendVolLag * inputToMixVolLag; } } if ( inputToKeyEnable ) { diff --git a/src/jack.hxx b/src/jack.hxx index 175614e..26b6328 100644 --- a/src/jack.hxx +++ b/src/jack.hxx @@ -169,6 +169,8 @@ private: float inputToMixVolLag; float inputToSendVol; + float inputToSendVolLag; + float inputToXSideVol; bool inputToKeyEnable; From df763be9fb42c6e2a98d81deeb13bfd2e8f2e329 Mon Sep 17 00:00:00 2001 From: Georg Krause Date: Mon, 9 Jul 2018 13:46:31 +0200 Subject: [PATCH 09/16] apply smoothing to input sidechain volume --- src/jack.cxx | 10 ++++++---- src/jack.hxx | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/jack.cxx b/src/jack.cxx index 5ea9d75..7aca082 100644 --- a/src/jack.cxx +++ b/src/jack.cxx @@ -208,6 +208,7 @@ Jack::Jack( std::string name ) : inputToSendVol = 0.f; inputToSendVolLag = 0.f; inputToXSideVol = 0.f; + inputToXSideVolLag = 0.f; /// prepare internal buffers buffers.audio[Buffers::SEND_L] = new float[ buffers.nframes ]; @@ -541,6 +542,7 @@ void Jack::processFrames(int nframes) // compute *lags für smoothing inputToMixVolLag += SMOOTHING_CONST * (inputToMixVol - inputToMixVolLag); inputToSendVolLag += SMOOTHING_CONST * (inputToSendVol - inputToSendVolLag); + inputToXSideVolLag += SMOOTHING_CONST * (inputToXSideVol - inputToXSideVolLag); float inputL = buffers.audio[Buffers::MASTER_INPUT_L][i] * inputVol; float inputR = buffers.audio[Buffers::MASTER_INPUT_R][i] * inputVol; @@ -552,8 +554,8 @@ void Jack::processFrames(int nframes) if ( inputToMixEnable ) { // if sending to mix, scale by volume *and* by XSide send - float tmpL = inputL * inputToMixVolLag * (1-inputToXSideVol); - float tmpR = inputR * inputToMixVolLag * (1-inputToXSideVol); + float tmpL = inputL * inputToMixVolLag * (1-inputToXSideVolLag); + float tmpR = inputR * inputToMixVolLag * (1-inputToXSideVolLag); L += tmpL; R += tmpR; @@ -568,8 +570,8 @@ void Jack::processFrames(int nframes) buffers.audio[Buffers::SIDECHAIN_KEY_R][i] += inputR; } - buffers.audio[Buffers::SIDECHAIN_SIGNAL_L][i] += inputL * inputToXSideVol; - buffers.audio[Buffers::SIDECHAIN_SIGNAL_R][i] += inputR * inputToXSideVol; + buffers.audio[Buffers::SIDECHAIN_SIGNAL_L][i] += inputL * inputToXSideVolLag; + buffers.audio[Buffers::SIDECHAIN_SIGNAL_R][i] += inputR * inputToXSideVolLag; //compute master volume lag; masterVolLag += SMOOTHING_CONST * (masterVol - masterVolLag); diff --git a/src/jack.hxx b/src/jack.hxx index 26b6328..ef2064d 100644 --- a/src/jack.hxx +++ b/src/jack.hxx @@ -170,8 +170,9 @@ private: float inputToSendVol; float inputToSendVolLag; - + float inputToXSideVol; + float inputToXSideVolLag; bool inputToKeyEnable; bool inputToMixEnable; From 211a8c886ff31a591514dcd0facfe940e724556c Mon Sep 17 00:00:00 2001 From: Georg Krause Date: Mon, 9 Jul 2018 13:50:39 +0200 Subject: [PATCH 10/16] apply smoothing to master return vol --- src/jack.cxx | 7 ++++--- src/jack.hxx | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/jack.cxx b/src/jack.cxx index 7aca082..3eb7ea7 100644 --- a/src/jack.cxx +++ b/src/jack.cxx @@ -199,7 +199,7 @@ Jack::Jack( std::string name ) : returnVol = 1.0f; - + returnVolLag = 1.0f; inputToMixEnable = false; inputToSendEnable = false; inputToKeyEnable = false; @@ -543,6 +543,7 @@ void Jack::processFrames(int nframes) inputToMixVolLag += SMOOTHING_CONST * (inputToMixVol - inputToMixVolLag); inputToSendVolLag += SMOOTHING_CONST * (inputToSendVol - inputToSendVolLag); inputToXSideVolLag += SMOOTHING_CONST * (inputToXSideVol - inputToXSideVolLag); + returnVolLag += SMOOTHING_CONST * (returnVol - returnVolLag); float inputL = buffers.audio[Buffers::MASTER_INPUT_L][i] * inputVol; float inputR = buffers.audio[Buffers::MASTER_INPUT_R][i] * inputVol; @@ -576,8 +577,8 @@ void Jack::processFrames(int nframes) //compute master volume lag; masterVolLag += SMOOTHING_CONST * (masterVol - masterVolLag); /// mixdown returns into master buffers - buffers.audio[Buffers::JACK_MASTER_OUT_L][i] = (L + returnL*returnVol) * masterVolLag; - buffers.audio[Buffers::JACK_MASTER_OUT_R][i] = (R + returnR*returnVol) * masterVolLag; + buffers.audio[Buffers::JACK_MASTER_OUT_L][i] = (L + returnL*returnVolLag) * masterVolLag; + buffers.audio[Buffers::JACK_MASTER_OUT_R][i] = (R + returnR*returnVolLag) * masterVolLag; /// write SEND content to JACK port buffers.audio[Buffers::JACK_SEND_OUT_L][i] = buffers.audio[Buffers::SEND_L][i]; diff --git a/src/jack.hxx b/src/jack.hxx index ef2064d..207c432 100644 --- a/src/jack.hxx +++ b/src/jack.hxx @@ -163,7 +163,9 @@ private: /// This prohibits audible jumps when rapidly changing the volume float masterVol; float masterVolLag; + float returnVol; + float returnVolLag; float inputToMixVol; float inputToMixVolLag; From 74c40a55e39fe35c64272f1dbe8ede0b7dd575fe Mon Sep 17 00:00:00 2001 From: Georg Krause Date: Mon, 9 Jul 2018 13:54:11 +0200 Subject: [PATCH 11/16] apply smoothing to input volume --- src/jack.cxx | 8 +++++--- src/jack.hxx | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/jack.cxx b/src/jack.cxx index 3eb7ea7..a56c361 100644 --- a/src/jack.cxx +++ b/src/jack.cxx @@ -266,6 +266,7 @@ Jack::Jack( std::string name ) : /// setup DSP instances inputVol = 1.0f; + inputVolLag = 1.0f; masterVol = 0.75f; masterVolLag =0.75f; @@ -544,9 +545,10 @@ void Jack::processFrames(int nframes) inputToSendVolLag += SMOOTHING_CONST * (inputToSendVol - inputToSendVolLag); inputToXSideVolLag += SMOOTHING_CONST * (inputToXSideVol - inputToXSideVolLag); returnVolLag += SMOOTHING_CONST * (returnVol - returnVolLag); + inputVolLag += SMOOTHING_CONST * (inputVol - inputVolLag); - float inputL = buffers.audio[Buffers::MASTER_INPUT_L][i] * inputVol; - float inputR = buffers.audio[Buffers::MASTER_INPUT_R][i] * inputVol; + float inputL = buffers.audio[Buffers::MASTER_INPUT_L][i] * inputVolLag; + float inputR = buffers.audio[Buffers::MASTER_INPUT_R][i] * inputVolLag; float L = buffers.audio[Buffers::MASTER_OUT_L][i]; float R = buffers.audio[Buffers::MASTER_OUT_R][i]; @@ -598,7 +600,7 @@ void Jack::processFrames(int nframes) // instead of scaling whole buffer, just scale output by vol EventTrackSignalLevel e(-1, masterMeter->getLeftDB(), masterMeter->getRightDB() ); writeToGuiRingbuffer( &e ); - EventTrackSignalLevel e2(-2, inputMeter->getLeftDB() * inputVol, inputMeter->getRightDB() * inputVol ); + EventTrackSignalLevel e2(-2, inputMeter->getLeftDB() * inputVolLag, inputMeter->getRightDB() * inputVol ); writeToGuiRingbuffer( &e2 ); uiUpdateCounter = 0; diff --git a/src/jack.hxx b/src/jack.hxx index 207c432..1763df3 100644 --- a/src/jack.hxx +++ b/src/jack.hxx @@ -157,10 +157,12 @@ private: // FX DBMeter* inputMeter; DBMeter* masterMeter; - - float inputVol; - /// _toMasterLag is a volume that lags behind _toMaster when setMaster() is called + + /// *Lag are values that lag behind their corresponding value /// This prohibits audible jumps when rapidly changing the volume + float inputVol; + float inputVolLag; + float masterVol; float masterVolLag; From 08835eac75d0c488e68b3b1424e7fc85285a2397 Mon Sep 17 00:00:00 2001 From: Georg Krause Date: Mon, 9 Jul 2018 13:57:06 +0200 Subject: [PATCH 12/16] apply smoothing to input to key button --- src/jack.cxx | 11 +++++++---- src/jack.hxx | 2 ++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/jack.cxx b/src/jack.cxx index a56c361..7561e68 100644 --- a/src/jack.cxx +++ b/src/jack.cxx @@ -203,6 +203,7 @@ Jack::Jack( std::string name ) : inputToMixEnable = false; inputToSendEnable = false; inputToKeyEnable = false; + inputToKeyEnableLag = 0; inputToMixVol = 0.f; inputToMixVolLag = 0.f; inputToSendVol = 0.f; @@ -547,6 +548,8 @@ void Jack::processFrames(int nframes) returnVolLag += SMOOTHING_CONST * (returnVol - returnVolLag); inputVolLag += SMOOTHING_CONST * (inputVol - inputVolLag); + inputToKeyEnableLag += SMOOTHING_CONST * (inputToKeyEnable - inputToKeyEnableLag); + float inputL = buffers.audio[Buffers::MASTER_INPUT_L][i] * inputVolLag; float inputR = buffers.audio[Buffers::MASTER_INPUT_R][i] * inputVolLag; @@ -568,10 +571,10 @@ void Jack::processFrames(int nframes) buffers.audio[Buffers::SEND_R][i] += inputR * inputToSendVolLag * inputToMixVolLag; } } - if ( inputToKeyEnable ) { - buffers.audio[Buffers::SIDECHAIN_KEY_L][i] += inputL; - buffers.audio[Buffers::SIDECHAIN_KEY_R][i] += inputR; - } + + buffers.audio[Buffers::SIDECHAIN_KEY_L][i] += inputL * inputToKeyEnableLag; + buffers.audio[Buffers::SIDECHAIN_KEY_R][i] += inputR * inputToKeyEnableLag; + buffers.audio[Buffers::SIDECHAIN_SIGNAL_L][i] += inputL * inputToXSideVolLag; buffers.audio[Buffers::SIDECHAIN_SIGNAL_R][i] += inputR * inputToXSideVolLag; diff --git a/src/jack.hxx b/src/jack.hxx index 1763df3..1b1f861 100644 --- a/src/jack.hxx +++ b/src/jack.hxx @@ -179,6 +179,8 @@ private: float inputToXSideVolLag; bool inputToKeyEnable; + float inputToKeyEnableLag; + bool inputToMixEnable; bool inputToSendEnable; From abdf24dada4176700450c8ab32e495bffc0b13b9 Mon Sep 17 00:00:00 2001 From: Georg Krause Date: Mon, 9 Jul 2018 14:09:44 +0200 Subject: [PATCH 13/16] apply smoothing to input to mix button --- src/jack.cxx | 27 ++++++++++++++------------- src/jack.hxx | 4 +++- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/jack.cxx b/src/jack.cxx index 7561e68..239bbd8 100644 --- a/src/jack.cxx +++ b/src/jack.cxx @@ -201,9 +201,10 @@ Jack::Jack( std::string name ) : returnVol = 1.0f; returnVolLag = 1.0f; inputToMixEnable = false; + inputToMixEnableLag = 0.f; inputToSendEnable = false; inputToKeyEnable = false; - inputToKeyEnableLag = 0; + inputToKeyEnableLag = 0.f; inputToMixVol = 0.f; inputToMixVolLag = 0.f; inputToSendVol = 0.f; @@ -549,6 +550,7 @@ void Jack::processFrames(int nframes) inputVolLag += SMOOTHING_CONST * (inputVol - inputVolLag); inputToKeyEnableLag += SMOOTHING_CONST * (inputToKeyEnable - inputToKeyEnableLag); + inputToMixEnableLag += SMOOTHING_CONST * (inputToMixEnable - inputToMixEnableLag); float inputL = buffers.audio[Buffers::MASTER_INPUT_L][i] * inputVolLag; float inputR = buffers.audio[Buffers::MASTER_INPUT_R][i] * inputVolLag; @@ -558,20 +560,19 @@ void Jack::processFrames(int nframes) float returnL = buffers.audio[Buffers::MASTER_RETURN_L][i]; float returnR = buffers.audio[Buffers::MASTER_RETURN_R][i]; - if ( inputToMixEnable ) { - // if sending to mix, scale by volume *and* by XSide send - float tmpL = inputL * inputToMixVolLag * (1-inputToXSideVolLag); - float tmpR = inputR * inputToMixVolLag * (1-inputToXSideVolLag); - L += tmpL; - R += tmpR; - - if ( inputToSendEnable ) { - // post-mix-send amount: hence * inputToMixVol - buffers.audio[Buffers::SEND_L][i] += inputL * inputToSendVolLag * inputToMixVolLag; - buffers.audio[Buffers::SEND_R][i] += inputR * inputToSendVolLag * inputToMixVolLag; - } + // if sending to mix, scale by volume *and* by XSide send + float tmpL = inputL * inputToMixVolLag * (1-inputToXSideVolLag) * inputToMixEnableLag; + float tmpR = inputR * inputToMixVolLag * (1-inputToXSideVolLag) * inputToMixEnableLag; + L += tmpL; + R += tmpR; + + if ( inputToSendEnable ) { + // post-mix-send amount: hence * inputToMixVol + buffers.audio[Buffers::SEND_L][i] += inputL * inputToSendVolLag * inputToMixVolLag * inputToMixEnableLag; + buffers.audio[Buffers::SEND_R][i] += inputR * inputToSendVolLag * inputToMixVolLag * inputToMixEnableLag; } + buffers.audio[Buffers::SIDECHAIN_KEY_L][i] += inputL * inputToKeyEnableLag; buffers.audio[Buffers::SIDECHAIN_KEY_R][i] += inputR * inputToKeyEnableLag; diff --git a/src/jack.hxx b/src/jack.hxx index 1b1f861..e3078a5 100644 --- a/src/jack.hxx +++ b/src/jack.hxx @@ -180,8 +180,10 @@ private: bool inputToKeyEnable; float inputToKeyEnableLag; - + bool inputToMixEnable; + float inputToMixEnableLag; + bool inputToSendEnable; // JACK member variables From 701e9dc24beddde2c6036ed4a0ebd2e843be96ec Mon Sep 17 00:00:00 2001 From: Georg Krause Date: Mon, 9 Jul 2018 14:16:41 +0200 Subject: [PATCH 14/16] apply smoothing to input to send button --- src/jack.cxx | 20 ++++++++++---------- src/jack.hxx | 1 + 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/jack.cxx b/src/jack.cxx index 239bbd8..3d2d60d 100644 --- a/src/jack.cxx +++ b/src/jack.cxx @@ -203,6 +203,7 @@ Jack::Jack( std::string name ) : inputToMixEnable = false; inputToMixEnableLag = 0.f; inputToSendEnable = false; + inputToSendEnableLag = 0.f; inputToKeyEnable = false; inputToKeyEnableLag = 0.f; inputToMixVol = 0.f; @@ -551,6 +552,7 @@ void Jack::processFrames(int nframes) inputToKeyEnableLag += SMOOTHING_CONST * (inputToKeyEnable - inputToKeyEnableLag); inputToMixEnableLag += SMOOTHING_CONST * (inputToMixEnable - inputToMixEnableLag); + inputToSendEnableLag += SMOOTHING_CONST * (inputToSendEnable - inputToSendEnableLag); float inputL = buffers.audio[Buffers::MASTER_INPUT_L][i] * inputVolLag; float inputR = buffers.audio[Buffers::MASTER_INPUT_R][i] * inputVolLag; @@ -561,17 +563,15 @@ void Jack::processFrames(int nframes) float returnR = buffers.audio[Buffers::MASTER_RETURN_R][i]; // if sending to mix, scale by volume *and* by XSide send - float tmpL = inputL * inputToMixVolLag * (1-inputToXSideVolLag) * inputToMixEnableLag; - float tmpR = inputR * inputToMixVolLag * (1-inputToXSideVolLag) * inputToMixEnableLag; - L += tmpL; - R += tmpR; - - if ( inputToSendEnable ) { - // post-mix-send amount: hence * inputToMixVol - buffers.audio[Buffers::SEND_L][i] += inputL * inputToSendVolLag * inputToMixVolLag * inputToMixEnableLag; - buffers.audio[Buffers::SEND_R][i] += inputR * inputToSendVolLag * inputToMixVolLag * inputToMixEnableLag; - } + float tmpL = inputL * inputToMixVolLag * inputToMixEnableLag; + float tmpR = inputR * inputToMixVolLag * inputToMixEnableLag; + L += tmpL * (1-inputToXSideVolLag); + R += tmpR * (1-inputToXSideVolLag); + // post-mix-send amount: hence * inputToMixVol + buffers.audio[Buffers::SEND_L][i] += tmpL * inputToSendVolLag * inputToSendEnableLag; + buffers.audio[Buffers::SEND_R][i] += tmpR * inputToSendVolLag * inputToSendEnableLag; + buffers.audio[Buffers::SIDECHAIN_KEY_L][i] += inputL * inputToKeyEnableLag; buffers.audio[Buffers::SIDECHAIN_KEY_R][i] += inputR * inputToKeyEnableLag; diff --git a/src/jack.hxx b/src/jack.hxx index e3078a5..8c3c822 100644 --- a/src/jack.hxx +++ b/src/jack.hxx @@ -185,6 +185,7 @@ private: float inputToMixEnableLag; bool inputToSendEnable; + float inputToSendEnableLag; // JACK member variables bool clientActive; From 21e53c391d8867bd956cd24c6a36650d9a61e8a1 Mon Sep 17 00:00:00 2001 From: Georg Krause Date: Mon, 9 Jul 2018 14:38:52 +0200 Subject: [PATCH 15/16] calculate smoothing value depending on samplerate Because smoothing "speed" distinguish between two sample rates, we need to calculate the right smoothing value for the used sample rate on runtime. This commit changes this. The SMOOTHING_CONST in config.hxx can still be used to configurate the general speed for smoothing. --- src/jack.cxx | 24 ++++++++++++++---------- src/jack.hxx | 2 ++ src/jacksendreturn.cxx | 4 ++-- src/trackoutput.cxx | 16 ++++++++-------- 4 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/jack.cxx b/src/jack.cxx index 3d2d60d..93b4e3f 100644 --- a/src/jack.cxx +++ b/src/jack.cxx @@ -78,12 +78,16 @@ Jack::Jack( std::string name ) : client( jack_client_open ( name.c_str(), JackNullOption, 0, 0 ) ), state( new State() ), controllerUpdater( new ControllerUpdater() ), - clientActive(false) + clientActive(false), + smoothing_value(SMOOTHING_CONST * (44100.f / samplerate)) { jack = this; lastnframes=0; samplerate = jack_get_sample_rate( client ); + // calculate smoothing value for current sample rate + //smoothing_value = SMOOTHING_CONST * (44100.f / samplerate); + // construct Observer classes here, not in the initializer list as the Jack* // will be 0x0 until then. timeManager = new TimeManager(), @@ -544,15 +548,15 @@ void Jack::processFrames(int nframes) /// mix input, reverb & post-sidechain in for(unsigned int i = 0; i < nframes; i++) { // compute *lags für smoothing - inputToMixVolLag += SMOOTHING_CONST * (inputToMixVol - inputToMixVolLag); - inputToSendVolLag += SMOOTHING_CONST * (inputToSendVol - inputToSendVolLag); - inputToXSideVolLag += SMOOTHING_CONST * (inputToXSideVol - inputToXSideVolLag); - returnVolLag += SMOOTHING_CONST * (returnVol - returnVolLag); - inputVolLag += SMOOTHING_CONST * (inputVol - inputVolLag); + inputToMixVolLag += smoothing_value * (inputToMixVol - inputToMixVolLag); + inputToSendVolLag += smoothing_value * (inputToSendVol - inputToSendVolLag); + inputToXSideVolLag += smoothing_value * (inputToXSideVol - inputToXSideVolLag); + returnVolLag += smoothing_value * (returnVol - returnVolLag); + inputVolLag += smoothing_value * (inputVol - inputVolLag); - inputToKeyEnableLag += SMOOTHING_CONST * (inputToKeyEnable - inputToKeyEnableLag); - inputToMixEnableLag += SMOOTHING_CONST * (inputToMixEnable - inputToMixEnableLag); - inputToSendEnableLag += SMOOTHING_CONST * (inputToSendEnable - inputToSendEnableLag); + inputToKeyEnableLag += smoothing_value * (inputToKeyEnable - inputToKeyEnableLag); + inputToMixEnableLag += smoothing_value * (inputToMixEnable - inputToMixEnableLag); + inputToSendEnableLag += smoothing_value * (inputToSendEnable - inputToSendEnableLag); float inputL = buffers.audio[Buffers::MASTER_INPUT_L][i] * inputVolLag; float inputR = buffers.audio[Buffers::MASTER_INPUT_R][i] * inputVolLag; @@ -581,7 +585,7 @@ void Jack::processFrames(int nframes) buffers.audio[Buffers::SIDECHAIN_SIGNAL_R][i] += inputR * inputToXSideVolLag; //compute master volume lag; - masterVolLag += SMOOTHING_CONST * (masterVol - masterVolLag); + masterVolLag += smoothing_value * (masterVol - masterVolLag); /// mixdown returns into master buffers buffers.audio[Buffers::JACK_MASTER_OUT_L][i] = (L + returnL*returnVolLag) * masterVolLag; buffers.audio[Buffers::JACK_MASTER_OUT_R][i] = (R + returnR*returnVolLag) * masterVolLag; diff --git a/src/jack.hxx b/src/jack.hxx index 8c3c822..9386ba4 100644 --- a/src/jack.hxx +++ b/src/jack.hxx @@ -136,6 +136,8 @@ public: int bindingActive; JackSendReturn *getJackSendReturn(int t); + + const float smoothing_value; private: int lastnframes; jack_client_t* client; diff --git a/src/jacksendreturn.cxx b/src/jacksendreturn.cxx index 061a79e..a2bf1ac 100644 --- a/src/jacksendreturn.cxx +++ b/src/jacksendreturn.cxx @@ -53,12 +53,12 @@ void JackSendReturn::process(unsigned int nframes, Buffers *buffers) } for(int i=0; ismoothing_value * (_sendVol - _sendVolLag); sendL[i] = _sendVolLag * sendtrackL[i]; sendR[i] = _sendVolLag * sendtrackR[i]; - _activeLag += SMOOTHING_CONST * (float(_active) - _activeLag); + _activeLag += jack->smoothing_value * (float(_active) - _activeLag); rettrackL[i] = retL[i] * _activeLag + sendtrackL[i] * std::fabs(_activeLag - 1); rettrackR[i] = retR[i] * _activeLag + sendtrackR[i] * std::fabs(_activeLag - 1); diff --git a/src/trackoutput.cxx b/src/trackoutput.cxx index cf1bd1c..339ec4b 100644 --- a/src/trackoutput.cxx +++ b/src/trackoutput.cxx @@ -136,7 +136,7 @@ void TrackOutput::process(unsigned int nframes, Buffers* buffers) int trackoffset = track * NCHANNELS; //compute master volume lag; - _toMasterLag += SMOOTHING_CONST * (_toMaster - _toMasterLag); + _toMasterLag += jack->smoothing_value * (_toMaster - _toMasterLag); // get & zero track buffer float* trackBufferL = buffers->audio[Buffers::RETURN_TRACK_0_L + trackoffset]; @@ -178,21 +178,21 @@ void TrackOutput::process(unsigned int nframes, Buffers* buffers) for(unsigned int i = 0; i < nframes; i++) { //compute master volume lag; - _toMasterLag += SMOOTHING_CONST * (_toMaster - _toMasterLag); + _toMasterLag += jack->smoothing_value * (_toMaster - _toMasterLag); // compute pan lag: - _panLLag += SMOOTHING_CONST * (_panL - _panLLag); - _panRLag += SMOOTHING_CONST * (_panR - _panRLag); + _panLLag += jack->smoothing_value * (_panL - _panLLag); + _panRLag += jack->smoothing_value * (_panR - _panRLag); // compute send volume lag: - _toSendLag += SMOOTHING_CONST * (_toSend - _toSendLag); + _toSendLag += jack->smoothing_value * (_toSend - _toSendLag); // compute sidechain signal lag - _toPostSidechainLag += SMOOTHING_CONST * (_toPostSidechain - _toPostSidechainLag); + _toPostSidechainLag += jack->smoothing_value * (_toPostSidechain - _toPostSidechainLag); // compute discrete lag values - _toPostfaderActiveLag += SMOOTHING_CONST * (float(_toPostfaderActive) - _toPostfaderActiveLag); - _toKeyActiveLag += SMOOTHING_CONST * (float(_toKeyActive) - _toKeyActiveLag); + _toPostfaderActiveLag += jack->smoothing_value * (float(_toPostfaderActive) - _toPostfaderActiveLag); + _toKeyActiveLag += jack->smoothing_value * (float(_toKeyActive) - _toKeyActiveLag); // * master for "post-fader" sends float tmpL = trackBufferL[i]; From 210a08f418e8638a0ace2b3deb76d989b05b26f9 Mon Sep 17 00:00:00 2001 From: Georg Krause Date: Wed, 11 Jul 2018 21:51:42 +0200 Subject: [PATCH 16/16] removed const from smoothing_value I wanted to make this const to prevent changes, but since the smoothing_value needs to be calculated based on the samplerate which is a member of jack this does not work, I dont know how to do this. Any hints welcome. --- src/jack.cxx | 5 ++--- src/jack.hxx | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/jack.cxx b/src/jack.cxx index 93b4e3f..ff742b8 100644 --- a/src/jack.cxx +++ b/src/jack.cxx @@ -78,15 +78,14 @@ Jack::Jack( std::string name ) : client( jack_client_open ( name.c_str(), JackNullOption, 0, 0 ) ), state( new State() ), controllerUpdater( new ControllerUpdater() ), - clientActive(false), - smoothing_value(SMOOTHING_CONST * (44100.f / samplerate)) + clientActive(false) { jack = this; lastnframes=0; samplerate = jack_get_sample_rate( client ); // calculate smoothing value for current sample rate - //smoothing_value = SMOOTHING_CONST * (44100.f / samplerate); + smoothing_value = SMOOTHING_CONST * (44100.f / samplerate); // construct Observer classes here, not in the initializer list as the Jack* // will be 0x0 until then. diff --git a/src/jack.hxx b/src/jack.hxx index 9386ba4..1284426 100644 --- a/src/jack.hxx +++ b/src/jack.hxx @@ -137,7 +137,7 @@ public: JackSendReturn *getJackSendReturn(int t); - const float smoothing_value; + float smoothing_value; private: int lastnframes; jack_client_t* client;