ValueBuffer related cleanups
* Move implementation to a new cpp file * Use std::vector as base class instead of doing our own memory management * Remove unused dangerous functions * Make more use of std algorithms * Some cleanups in code using ValueBuffer
This commit is contained in:
@@ -75,10 +75,10 @@ bool AmplifierEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames )
|
||||
const float d = dryLevel();
|
||||
const float w = wetLevel();
|
||||
|
||||
ValueBuffer * volBuf = m_ampControls.m_volumeModel.valueBuffer();
|
||||
ValueBuffer * panBuf = m_ampControls.m_panModel.valueBuffer();
|
||||
ValueBuffer * leftBuf = m_ampControls.m_leftModel.valueBuffer();
|
||||
ValueBuffer * rightBuf = m_ampControls.m_rightModel.valueBuffer();
|
||||
const ValueBuffer * volBuf = m_ampControls.m_volumeModel.valueBuffer();
|
||||
const ValueBuffer * panBuf = m_ampControls.m_panModel.valueBuffer();
|
||||
const ValueBuffer * leftBuf = m_ampControls.m_leftModel.valueBuffer();
|
||||
const ValueBuffer * rightBuf = m_ampControls.m_rightModel.valueBuffer();
|
||||
|
||||
for( fpp_t f = 0; f < frames; ++f )
|
||||
{
|
||||
@@ -90,8 +90,8 @@ bool AmplifierEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames )
|
||||
// vol knob
|
||||
if( volBuf )
|
||||
{
|
||||
s[0] *= volBuf->values()[ f ] * 0.01f;
|
||||
s[1] *= volBuf->values()[ f ] * 0.01f;
|
||||
s[0] *= volBuf->value( f ) * 0.01f;
|
||||
s[1] *= volBuf->value( f ) * 0.01f;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -101,7 +101,7 @@ bool AmplifierEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames )
|
||||
|
||||
// convert pan values to left/right values
|
||||
const float pan = panBuf
|
||||
? panBuf->values()[ f ]
|
||||
? panBuf->value( f )
|
||||
: m_ampControls.m_panModel.value();
|
||||
const float left1 = pan <= 0
|
||||
? 1.0
|
||||
@@ -112,10 +112,10 @@ bool AmplifierEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames )
|
||||
|
||||
// second stage amplification
|
||||
const float left2 = leftBuf
|
||||
? leftBuf->values()[ f ]
|
||||
? leftBuf->value( f )
|
||||
: m_ampControls.m_leftModel.value();
|
||||
const float right2 = rightBuf
|
||||
? rightBuf->values()[ f ]
|
||||
? rightBuf->value( f )
|
||||
: m_ampControls.m_rightModel.value();
|
||||
|
||||
s[0] *= left1 * left2 * 0.01;
|
||||
|
||||
@@ -83,45 +83,30 @@ bool BassBoosterEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames
|
||||
if( m_bbControls.m_gainModel.isValueChanged() ) { changeGain(); }
|
||||
if( m_bbControls.m_ratioModel.isValueChanged() ) { changeRatio(); }
|
||||
|
||||
float gain = m_bbControls.m_gainModel.value();
|
||||
ValueBuffer *gainBuffer = m_bbControls.m_gainModel.valueBuffer();
|
||||
int gainInc = gainBuffer ? 1 : 0;
|
||||
float *gainPtr = gainBuffer ? &( gainBuffer->values()[ 0 ] ) : &gain;
|
||||
const float const_gain = m_bbControls.m_gainModel.value();
|
||||
const ValueBuffer *gainBuffer = m_bbControls.m_gainModel.valueBuffer();
|
||||
|
||||
double outSum = 0.0;
|
||||
const float d = dryLevel();
|
||||
const float w = wetLevel();
|
||||
if( gainBuffer )
|
||||
|
||||
for( fpp_t f = 0; f < frames; ++f )
|
||||
{
|
||||
//process period using sample exact data
|
||||
for( fpp_t f = 0; f < frames; ++f )
|
||||
{
|
||||
m_bbFX.leftFX().setGain( *gainPtr );
|
||||
m_bbFX.rightFX().setGain( *gainPtr );
|
||||
outSum += buf[f][0]*buf[f][0] + buf[f][1]*buf[f][1];
|
||||
|
||||
sample_t s[2] = { buf[f][0], buf[f][1] };
|
||||
m_bbFX.nextSample( s[0], s[1] );
|
||||
|
||||
buf[f][0] = d * buf[f][0] + w * s[0];
|
||||
buf[f][1] = d * buf[f][1] + w * s[1];
|
||||
gainPtr += gainInc;
|
||||
float gain = const_gain;
|
||||
if (gainBuffer) {
|
||||
//process period using sample exact data
|
||||
gain = gainBuffer->value( f );
|
||||
}
|
||||
} else
|
||||
{
|
||||
//process period without sample exact data
|
||||
m_bbFX.leftFX().setGain( *gainPtr );
|
||||
m_bbFX.rightFX().setGain( *gainPtr );
|
||||
for( fpp_t f = 0; f < frames; ++f )
|
||||
{
|
||||
outSum += buf[f][0]*buf[f][0] + buf[f][1]*buf[f][1];
|
||||
//float gain = gainBuffer ? gainBuffer[f] : gain;
|
||||
m_bbFX.leftFX().setGain( const_gain );
|
||||
m_bbFX.rightFX().setGain( const_gain);
|
||||
outSum += buf[f][0]*buf[f][0] + buf[f][1]*buf[f][1];
|
||||
|
||||
sample_t s[2] = { buf[f][0], buf[f][1] };
|
||||
m_bbFX.nextSample( s[0], s[1] );
|
||||
sample_t s[2] = { buf[f][0], buf[f][1] };
|
||||
m_bbFX.nextSample( s[0], s[1] );
|
||||
|
||||
buf[f][0] = d * buf[f][0] + w * s[0];
|
||||
buf[f][1] = d * buf[f][1] + w * s[1];
|
||||
}
|
||||
buf[f][0] = d * buf[f][0] + w * s[0];
|
||||
buf[f][1] = d * buf[f][1] + w * s[1];
|
||||
}
|
||||
|
||||
checkGate( outSum / frames );
|
||||
|
||||
@@ -93,8 +93,8 @@ bool waveShaperEffect::processAudioBuffer( sampleFrame * _buf,
|
||||
int inputInc = inputBuffer ? 1 : 0;
|
||||
int outputInc = outputBufer ? 1 : 0;
|
||||
|
||||
float *inputPtr = inputBuffer ? &( inputBuffer->values()[ 0 ] ) : &input;
|
||||
float *outputPtr = outputBufer ? &( outputBufer->values()[ 0 ] ) : &output;
|
||||
const float *inputPtr = inputBuffer ? &( inputBuffer->values()[ 0 ] ) : &input;
|
||||
const float *outputPtr = outputBufer ? &( outputBufer->values()[ 0 ] ) : &output;
|
||||
|
||||
for( fpp_t f = 0; f < _frames; ++f )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user