From 81f0b14465456cdba8ab71c0d604ad8a406eb030 Mon Sep 17 00:00:00 2001 From: Dave French Date: Wed, 25 Feb 2015 22:12:22 +0000 Subject: [PATCH 1/5] smoothed the time parameter of the delay pluging --- plugins/Delay/DelayEffect.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/Delay/DelayEffect.cpp b/plugins/Delay/DelayEffect.cpp index aa01a49d0..5b13b92a0 100644 --- a/plugins/Delay/DelayEffect.cpp +++ b/plugins/Delay/DelayEffect.cpp @@ -91,13 +91,14 @@ bool DelayEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) sample_t dryS[2]; float lPeak = 0.0; float rPeak = 0.0; + float incr = ( m_currentLength - length ) / frames; if( m_delayControls.m_outGainModel.isValueChanged() ) { m_outGain = dbvToAmp( m_delayControls.m_outGainModel.value() ); } for( fpp_t f = 0; f < frames; ++f ) { - m_currentLength = linearInterpolate( length, m_currentLength, 0.9999 ); + m_currentLength -= incr; dryS[0] = buf[f][0]; dryS[1] = buf[f][1]; m_delay->setLength( ( float )m_currentLength + ( amplitude * ( float )m_lfo->tick() ) ); From a0360d2a8edf9a64e4e249b481e4e4173583dc9d Mon Sep 17 00:00:00 2001 From: Dave French Date: Thu, 26 Feb 2015 18:05:34 +0000 Subject: [PATCH 2/5] Delay effect, the delay time parameter now uses sample exact modeling --- plugins/Delay/DelayEffect.cpp | 8 ++++---- plugins/Delay/DelayEffect.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/Delay/DelayEffect.cpp b/plugins/Delay/DelayEffect.cpp index 5b13b92a0..c90669ab9 100644 --- a/plugins/Delay/DelayEffect.cpp +++ b/plugins/Delay/DelayEffect.cpp @@ -84,24 +84,24 @@ bool DelayEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) double outSum = 0.0; const float d = dryLevel(); const float w = wetLevel(); - const float length = m_delayControls.m_delayTimeModel.value() * Engine::mixer()->processingSampleRate(); const float amplitude = m_delayControls.m_lfoAmountModel.value() * Engine::mixer()->processingSampleRate(); m_lfo->setFrequency( 1.0 / m_delayControls.m_lfoTimeModel.value() ); m_delay->setFeedback( m_delayControls.m_feedbackModel.value() ); sample_t dryS[2]; float lPeak = 0.0; float rPeak = 0.0; - float incr = ( m_currentLength - length ) / frames; + ValueBuffer *lengthBuffer = m_delayControls.m_delayTimeModel.valueBuffer(); if( m_delayControls.m_outGainModel.isValueChanged() ) { m_outGain = dbvToAmp( m_delayControls.m_outGainModel.value() ); } for( fpp_t f = 0; f < frames; ++f ) { - m_currentLength -= incr; dryS[0] = buf[f][0]; dryS[1] = buf[f][1]; - m_delay->setLength( ( float )m_currentLength + ( amplitude * ( float )m_lfo->tick() ) ); + float length = lengthBuffer ? lengthBuffer->values()[ f ] : m_delayControls.m_delayTimeModel.value(); + length *= Engine::mixer()->processingSampleRate(); + m_delay->setLength( length + ( amplitude * ( float )m_lfo->tick() ) ); m_delay->tick( buf[f] ); buf[f][0] *= m_outGain; diff --git a/plugins/Delay/DelayEffect.h b/plugins/Delay/DelayEffect.h index b98a19e70..af4f86b07 100644 --- a/plugins/Delay/DelayEffect.h +++ b/plugins/Delay/DelayEffect.h @@ -29,6 +29,7 @@ #include "DelayControls.h" #include "Lfo.h" #include "StereoDelay.h" +#include "ValueBuffer.h" class DelayEffect : public Effect { From 0d220b9584f6f29e1d2be8e8c9b5fc49517d490d Mon Sep 17 00:00:00 2001 From: Dave French Date: Fri, 27 Feb 2015 18:00:56 +0000 Subject: [PATCH 3/5] Added the use of sample exact controls to the Delay plugin Added Sample exactness to the following parameters Delay time Regen Lfo time Lfo amount Did not add this to the output gain contol, This model is used in a dbScale, and a much more pleaseing result was gained by using an amplifier plugin. --- plugins/Delay/DelayEffect.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/plugins/Delay/DelayEffect.cpp b/plugins/Delay/DelayEffect.cpp index c90669ab9..3ca1e17ce 100644 --- a/plugins/Delay/DelayEffect.cpp +++ b/plugins/Delay/DelayEffect.cpp @@ -82,15 +82,20 @@ bool DelayEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) return( false ); } double outSum = 0.0; + const float sr = Engine::mixer()->processingSampleRate(); const float d = dryLevel(); const float w = wetLevel(); - const float amplitude = m_delayControls.m_lfoAmountModel.value() * Engine::mixer()->processingSampleRate(); - m_lfo->setFrequency( 1.0 / m_delayControls.m_lfoTimeModel.value() ); - m_delay->setFeedback( m_delayControls.m_feedbackModel.value() ); + float length = m_delayControls.m_delayTimeModel.value(); + float amplitude = m_delayControls.m_lfoAmountModel.value() * sr; + float lfoTime = 1.0 / m_delayControls.m_lfoTimeModel.value(); + float feedback = m_delayControls.m_feedbackModel.value(); sample_t dryS[2]; float lPeak = 0.0; float rPeak = 0.0; ValueBuffer *lengthBuffer = m_delayControls.m_delayTimeModel.valueBuffer(); + ValueBuffer *feedbackBuffer = m_delayControls.m_feedbackModel.valueBuffer(); + ValueBuffer *lfoTimeBuffer = m_delayControls.m_lfoTimeModel.valueBuffer(); + ValueBuffer *lfoAmountBuffer = m_delayControls.m_lfoAmountModel.valueBuffer(); if( m_delayControls.m_outGainModel.isValueChanged() ) { m_outGain = dbvToAmp( m_delayControls.m_outGainModel.value() ); @@ -99,7 +104,14 @@ bool DelayEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) { dryS[0] = buf[f][0]; dryS[1] = buf[f][1]; - float length = lengthBuffer ? lengthBuffer->values()[ f ] : m_delayControls.m_delayTimeModel.value(); + length = lengthBuffer ? lengthBuffer->values()[ f ] : length; + amplitude = lfoAmountBuffer ? lfoAmountBuffer->values()[ f ] * sr : amplitude; + lfoTime = lfoTimeBuffer ? 1 / lfoTimeBuffer->values()[ f ] : lfoTime; + feedback = feedbackBuffer ? feedbackBuffer->values()[ f ] : feedback; + + + m_delay->setFeedback( feedback ); + m_lfo->setFrequency( lfoTime ); length *= Engine::mixer()->processingSampleRate(); m_delay->setLength( length + ( amplitude * ( float )m_lfo->tick() ) ); m_delay->tick( buf[f] ); From 9343cb75496daf0a629c36c1a46d3fa12ee2853c Mon Sep 17 00:00:00 2001 From: Dave French Date: Sat, 28 Feb 2015 13:26:17 +0000 Subject: [PATCH 4/5] Optimised sample exactness in the Delay plugin implemented a pointer increment system as suggested by diizy --- plugins/Delay/DelayEffect.cpp | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/plugins/Delay/DelayEffect.cpp b/plugins/Delay/DelayEffect.cpp index 3ca1e17ce..4b3095ab2 100644 --- a/plugins/Delay/DelayEffect.cpp +++ b/plugins/Delay/DelayEffect.cpp @@ -85,35 +85,40 @@ bool DelayEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) const float sr = Engine::mixer()->processingSampleRate(); const float d = dryLevel(); const float w = wetLevel(); + sample_t dryS[2]; + float lPeak = 0.0; + float rPeak = 0.0; float length = m_delayControls.m_delayTimeModel.value(); float amplitude = m_delayControls.m_lfoAmountModel.value() * sr; float lfoTime = 1.0 / m_delayControls.m_lfoTimeModel.value(); float feedback = m_delayControls.m_feedbackModel.value(); - sample_t dryS[2]; - float lPeak = 0.0; - float rPeak = 0.0; ValueBuffer *lengthBuffer = m_delayControls.m_delayTimeModel.valueBuffer(); ValueBuffer *feedbackBuffer = m_delayControls.m_feedbackModel.valueBuffer(); ValueBuffer *lfoTimeBuffer = m_delayControls.m_lfoTimeModel.valueBuffer(); ValueBuffer *lfoAmountBuffer = m_delayControls.m_lfoAmountModel.valueBuffer(); + int lengthInc = lengthBuffer ? 1 : 0; + int amplitudeInc = lfoAmountBuffer ? 1 : 0; + int lfoTimeInc = lfoTimeBuffer ? 1 : 0; + int feedbackInc = feedbackBuffer ? 1 : 0; + float *lengthPtr = lengthBuffer ? &( lengthBuffer->values()[ 0 ] ) : &length; + float *amplitudePtr = lfoAmountBuffer ? &( lfoAmountBuffer->values()[ 0 ] ) : &litude; + float *lfoTimePtr = lfoTimeBuffer ? &( lfoTimeBuffer->values()[ 0 ] ) : &lfoTime; + float *feedbackPtr = feedbackBuffer ? &( feedbackBuffer->values()[ 0 ] ) : &feedback; + if( m_delayControls.m_outGainModel.isValueChanged() ) { m_outGain = dbvToAmp( m_delayControls.m_outGainModel.value() ); } + int sampleLength; for( fpp_t f = 0; f < frames; ++f ) { dryS[0] = buf[f][0]; dryS[1] = buf[f][1]; - length = lengthBuffer ? lengthBuffer->values()[ f ] : length; - amplitude = lfoAmountBuffer ? lfoAmountBuffer->values()[ f ] * sr : amplitude; - lfoTime = lfoTimeBuffer ? 1 / lfoTimeBuffer->values()[ f ] : lfoTime; - feedback = feedbackBuffer ? feedbackBuffer->values()[ f ] : feedback; - - m_delay->setFeedback( feedback ); - m_lfo->setFrequency( lfoTime ); - length *= Engine::mixer()->processingSampleRate(); - m_delay->setLength( length + ( amplitude * ( float )m_lfo->tick() ) ); + m_delay->setFeedback( *feedbackPtr ); + m_lfo->setFrequency( *lfoTimePtr ); + sampleLength = *lengthPtr * Engine::mixer()->processingSampleRate(); + m_delay->setLength( sampleLength + ( *amplitudePtr * ( float )m_lfo->tick() ) ); m_delay->tick( buf[f] ); buf[f][0] *= m_outGain; @@ -125,6 +130,11 @@ bool DelayEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) buf[f][0] = ( d * dryS[0] ) + ( w * buf[f][0] ); buf[f][1] = ( d * dryS[1] ) + ( w * buf[f][1] ); outSum += buf[f][0]*buf[f][0] + buf[f][1]*buf[f][1]; + + lengthPtr += lengthInc; + amplitudePtr += amplitudeInc; + lfoTimePtr += lfoTimeInc; + feedbackPtr += feedbackInc; } checkGate( outSum / frames ); m_delayControls.m_outPeakL = lPeak; From 8a588d4934b11cff6769bc0dd1e78b0e28345e28 Mon Sep 17 00:00:00 2001 From: Dave French Date: Sun, 1 Mar 2015 00:03:24 +0000 Subject: [PATCH 5/5] Delay added addional smoothing to the delay time parameter The delay time paramter was responding very badly ui user input. This now has a much more plesant sound, not dis simular to a record being sped up or slowed down. --- plugins/Delay/DelayEffect.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/Delay/DelayEffect.cpp b/plugins/Delay/DelayEffect.cpp index 4b3095ab2..7f41653a2 100644 --- a/plugins/Delay/DelayEffect.cpp +++ b/plugins/Delay/DelayEffect.cpp @@ -118,7 +118,8 @@ bool DelayEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) m_delay->setFeedback( *feedbackPtr ); m_lfo->setFrequency( *lfoTimePtr ); sampleLength = *lengthPtr * Engine::mixer()->processingSampleRate(); - m_delay->setLength( sampleLength + ( *amplitudePtr * ( float )m_lfo->tick() ) ); + m_currentLength = linearInterpolate( sampleLength, m_currentLength, 0.9999 ); + m_delay->setLength( m_currentLength + ( *amplitudePtr * ( float )m_lfo->tick() ) ); m_delay->tick( buf[f] ); buf[f][0] *= m_outGain;