From d7931fdb0d372ac5a05d23b2d856a277d406147a Mon Sep 17 00:00:00 2001 From: Vesa Date: Mon, 17 Nov 2014 13:16:28 +0200 Subject: [PATCH] Some waveshaper improvements --- plugins/waveshaper/waveshaper.cpp | 29 +++++++++++++--------- plugins/waveshaper/waveshaper_controls.cpp | 25 ------------------- plugins/waveshaper/waveshaper_controls.h | 7 ++---- 3 files changed, 19 insertions(+), 42 deletions(-) diff --git a/plugins/waveshaper/waveshaper.cpp b/plugins/waveshaper/waveshaper.cpp index 3b780d806..ab379d8d1 100644 --- a/plugins/waveshaper/waveshaper.cpp +++ b/plugins/waveshaper/waveshaper.cpp @@ -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( fabsf( s[i] ) * 200.0f ); - const float frac = fraction( fabsf( s[i] ) * 200.0f ); + const int lookup = static_cast( 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]; diff --git a/plugins/waveshaper/waveshaper_controls.cpp b/plugins/waveshaper/waveshaper_controls.cpp index 253634d52..ac48727d8 100644 --- a/plugins/waveshaper/waveshaper_controls.cpp +++ b/plugins/waveshaper/waveshaper_controls.cpp @@ -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) { diff --git a/plugins/waveshaper/waveshaper_controls.h b/plugins/waveshaper/waveshaper_controls.h index cbb7c48aa..3828f1a8b 100644 --- a/plugins/waveshaper/waveshaper_controls.h +++ b/plugins/waveshaper/waveshaper_controls.h @@ -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();