Some waveshaper improvements
This commit is contained in:
@@ -82,16 +82,21 @@ bool waveShaperEffect::processAudioBuffer( sampleFrame * _buf,
|
||||
double out_sum = 0.0;
|
||||
const float d = dryLevel();
|
||||
const float w = wetLevel();
|
||||
const float input = m_wsControls.m_inputModel.value();
|
||||
const float output = m_wsControls.m_outputModel.value();
|
||||
const float * samples = m_wsControls.m_wavegraphModel.samples();
|
||||
const bool clip = m_wsControls.m_clipModel.value();
|
||||
|
||||
for( fpp_t f = 0; f < _frames; ++f )
|
||||
{
|
||||
sample_t s[2] = { _buf[f][0], _buf[f][1] };
|
||||
float s[2] = { _buf[f][0], _buf[f][1] };
|
||||
|
||||
// apply input gain
|
||||
s[0] *= m_wsControls.m_inputModel.value();
|
||||
s[1] *= m_wsControls.m_inputModel.value();
|
||||
s[0] *= input;
|
||||
s[1] *= input;
|
||||
|
||||
// clip if clip enabled
|
||||
if( m_wsControls.m_clipModel.value() )
|
||||
if( clip )
|
||||
{
|
||||
s[0] = qBound( -1.0f, s[0], 1.0f );
|
||||
s[1] = qBound( -1.0f, s[1], 1.0f );
|
||||
@@ -101,29 +106,29 @@ bool waveShaperEffect::processAudioBuffer( sampleFrame * _buf,
|
||||
|
||||
for( i=0; i <= 1; ++i )
|
||||
{
|
||||
const int lookup = static_cast<int>( fabsf( s[i] ) * 200.0f );
|
||||
const float frac = fraction( fabsf( s[i] ) * 200.0f );
|
||||
const int lookup = static_cast<int>( qAbs( s[i] ) * 200.0f );
|
||||
const float frac = fraction( qAbs( s[i] ) * 200.0f );
|
||||
const float posneg = s[i] < 0 ? -1.0f : 1.0f;
|
||||
|
||||
if( lookup < 1 )
|
||||
{
|
||||
s[i] = frac * m_wsControls.m_wavegraphModel.samples()[0] * posneg;
|
||||
s[i] = frac * samples[0] * posneg;
|
||||
}
|
||||
else if( lookup < 200 )
|
||||
{
|
||||
s[i] = linearInterpolate( m_wsControls.m_wavegraphModel.samples()[ lookup - 1 ],
|
||||
m_wsControls.m_wavegraphModel.samples()[ lookup ], frac )
|
||||
s[i] = linearInterpolate( samples[ lookup - 1 ],
|
||||
samples[ lookup ], frac )
|
||||
* posneg;
|
||||
}
|
||||
else
|
||||
{
|
||||
s[i] *= m_wsControls.m_wavegraphModel.samples()[199];
|
||||
s[i] *= samples[199];
|
||||
}
|
||||
}
|
||||
|
||||
// apply output gain
|
||||
s[0] *= m_wsControls.m_outputModel.value();
|
||||
s[1] *= m_wsControls.m_outputModel.value();
|
||||
s[0] *= output;
|
||||
s[1] *= output;
|
||||
|
||||
// mix wet/dry signals
|
||||
_buf[f][0] = d * _buf[f][0] + w * s[0];
|
||||
|
||||
@@ -44,39 +44,14 @@ waveShaperControls::waveShaperControls( waveShaperEffect * _eff ) :
|
||||
m_wavegraphModel( 0.0f, 1.0f, 200, this ),
|
||||
m_clipModel( false, this )
|
||||
{
|
||||
/* connect( &m_inputModel, SIGNAL( dataChanged() ),
|
||||
this, SLOT( changeInput() ) );
|
||||
|
||||
connect( &m_outputModel, SIGNAL( dataChanged() ),
|
||||
this, SLOT( changeOutput() ) );
|
||||
|
||||
connect( &m_clipModel, SIGNAL( dataChanged() ),
|
||||
this, SLOT( changeClip() ) );
|
||||
*/
|
||||
connect( &m_wavegraphModel, SIGNAL( samplesChanged( int, int ) ),
|
||||
this, SLOT( samplesChanged( int, int ) ) );
|
||||
|
||||
|
||||
setDefaultShape();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void waveShaperControls::changeInput()
|
||||
{
|
||||
// engine::getSong()->setModified();
|
||||
}
|
||||
|
||||
void waveShaperControls::changeOutput()
|
||||
{
|
||||
// engine::getSong()->setModified();
|
||||
}
|
||||
|
||||
void waveShaperControls::changeClip()
|
||||
{
|
||||
// engine::getSong()->setModified();
|
||||
}
|
||||
|
||||
void waveShaperControls::samplesChanged( int _begin, int _end)
|
||||
{
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _WAVESHAPER_CONTROLS_H
|
||||
#define _WAVESHAPER_CONTROLS_H
|
||||
#ifndef WAVESHAPER_CONTROLS_H
|
||||
#define WAVESHAPER_CONTROLS_H
|
||||
|
||||
#include "EffectControls.h"
|
||||
#include "waveshaper_control_dialog.h"
|
||||
@@ -64,10 +64,7 @@ public:
|
||||
|
||||
|
||||
private slots:
|
||||
void changeInput();
|
||||
void changeOutput();
|
||||
void samplesChanged( int, int );
|
||||
void changeClip();
|
||||
|
||||
void resetClicked();
|
||||
void smoothClicked();
|
||||
|
||||
Reference in New Issue
Block a user