Skip to content

Commit

Permalink
Merge pull request #1 from LMMS/master
Browse files Browse the repository at this point in the history
rebase from master
  • Loading branch information
curlymorphic committed Dec 13, 2014
2 parents d20b1e9 + 7b61c54 commit a774e5d
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 23 deletions.
20 changes: 10 additions & 10 deletions include/BasicFilters.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,42 +75,42 @@ class LinkwitzRiley
inline void setCoeffs( float freq )
{
// wc
const float wc = F_2PI * freq;
const float wc = F_2PI * freq / m_sampleRate;
const float wc2 = wc * wc;
const float wc3 = wc2 * wc;
m_wc4 = wc2 * wc2;

// k
const float k = wc / tanf( F_PI * freq / m_sampleRate );
const float k = wc / tan( wc * 0.5 );
const float k2 = k * k;
const float k3 = k2 * k;
m_k4 = k2 * k2;

// a
static const float sqrt2 = sqrtf( 2.0f );
static const double sqrt2 = sqrt( 2.0 );
const float sq_tmp1 = sqrt2 * wc3 * k;
const float sq_tmp2 = sqrt2 * wc * k3;
m_a = 4.0f * wc2 * k2 + 2.0f * sq_tmp1 + m_k4 + 2.0f * sq_tmp2 + m_wc4;
m_a = 1.0f / ( 4.0f * wc2 * k2 + 2.0f * sq_tmp1 + m_k4 + 2.0f * sq_tmp2 + m_wc4 );

// b
m_b1 = ( 4.0f * ( m_wc4 + sq_tmp1 - m_k4 - sq_tmp2 ) ) / m_a;
m_b2 = ( 6.0f * m_wc4 - 8.0f * wc2 * k2 + 6.0f * m_k4 ) / m_a;
m_b3 = ( 4.0f * ( m_wc4 - sq_tmp1 + sq_tmp2 - m_k4 ) ) / m_a;
m_b4 = ( m_k4 - 2.0f * sq_tmp1 + m_wc4 - 2.0f * sq_tmp2 + 4.0f * wc2 * k2 ) / m_a;
m_b1 = ( 4.0f * ( m_wc4 + sq_tmp1 - m_k4 - sq_tmp2 ) ) * m_a;
m_b2 = ( 6.0f * m_wc4 - 8.0f * wc2 * k2 + 6.0f * m_k4 ) * m_a;
m_b3 = ( 4.0f * ( m_wc4 - sq_tmp1 + sq_tmp2 - m_k4 ) ) * m_a;
m_b4 = ( m_k4 - 2.0f * sq_tmp1 + m_wc4 - 2.0f * sq_tmp2 + 4.0f * wc2 * k2 ) * m_a;
}

inline void setLowpass( float freq )
{
setCoeffs( freq );
m_a0 = m_wc4 / m_a;
m_a0 = m_wc4 * m_a;
m_a1 = 4.0f * m_a0;
m_a2 = 6.0f * m_a0;
}

inline void setHighpass( float freq )
{
setCoeffs( freq );
m_a0 = m_k4 / m_a;
m_a0 = m_k4 * m_a;
m_a1 = 4.0f * m_a0;
m_a2 = 6.0f * m_a0;
}
Expand Down
6 changes: 6 additions & 0 deletions include/Fader.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ class Fader : public QWidget, public FloatModelView
{
m_displayConversion = b;
}
inline void setHintText( const QString & _txt_before,
const QString & _txt_after )
{
setDescription( _txt_before );
setUnit( _txt_after );
}

private:
virtual void contextMenuEvent( QContextMenuEvent * _me );
Expand Down
29 changes: 21 additions & 8 deletions include/lmms_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,28 @@
#ifndef LMMS_CONSTANTS_H
#define LMMS_CONSTANTS_H

const double D_PI = 3.14159265358979323846;
const double D_2PI = D_PI * 2.0;
const double D_PI_2 = D_PI * 0.5;
const double D_E = 2.71828182845904523536;
const long double LD_PI = 3.14159265358979323846264338327950288419716939937510;
const long double LD_2PI = LD_PI * 2.0;
const long double LD_PI_2 = LD_PI * 0.5;
const long double LD_PI_R = 1.0 / LD_PI;
const long double LD_PI_SQR = LD_PI * LD_PI;
const long double LD_E = 2.71828182845904523536028747135266249775724709369995;
const long double LD_E_R = 1.0 / LD_E;

const float F_PI = (float) D_PI;
const float F_2PI = (float) D_2PI;
const float F_PI_2 = (float) D_PI_2;
const float F_E = (float) D_E;
const double D_PI = (double) LD_PI;
const double D_2PI = (double) LD_2PI;
const double D_PI_2 = (double) LD_PI_2;
const double D_PI_R = (double) LD_PI_R;
const double D_PI_SQR = (double) LD_PI_SQR;
const double D_E = (double) LD_E;
const double D_E_R = (double) LD_E_R;

const float F_PI = (float) LD_PI;
const float F_2PI = (float) LD_2PI;
const float F_PI_2 = (float) LD_PI_2;
const float F_PI_R = (float) LD_PI_R;
const float F_PI_SQR = (float) LD_PI_SQR;
const float F_E = (float) LD_E;
const float F_E_R = (float) LD_E_R;

#endif
14 changes: 14 additions & 0 deletions include/lmms_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,18 @@ static inline float fastSqrt( float n )
return u.f;
}

//! returns value furthest from zero
template<class T>
static inline T absMax( T a, T b )
{
return qAbs<T>(a) > qAbs<T>(b) ? a : b;
}

//! returns value nearest to zero
template<class T>
static inline T absMin( T a, T b )
{
return qAbs<T>(a) < qAbs<T>(b) ? a : b;
}

#endif
13 changes: 10 additions & 3 deletions plugins/Bitcrush/Bitcrush.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const int OS_RATE = 5;
const float OS_RATIO = 1.0f / OS_RATE;
const float CUTOFF_RATIO = 0.353553391f;
const int SILENCEFRAMES = 10;
const float OS_RESAMPLE [5] = { 0.0001490062883964112, 0.1645978376763992, 0.6705063120704088,
0.1645978376763992, 0.0001490062883964112 };

extern "C"
{
Expand Down Expand Up @@ -78,7 +80,7 @@ void BitcrushEffect::sampleRateChanged()
{
m_sampleRate = Engine::mixer()->processingSampleRate();
m_filter.setSampleRate( m_sampleRate );
m_filter.setLowpass( m_sampleRate * CUTOFF_RATIO );
m_filter.setLowpass( m_sampleRate * ( CUTOFF_RATIO * OS_RATIO ) );
m_needsUpdate = true;
}

Expand All @@ -95,6 +97,11 @@ inline float BitcrushEffect::noise( float amt )

bool BitcrushEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames )
{
if( !isEnabled() || !isRunning () )
{
return( false );
}

// update values
if( m_needsUpdate || m_controls.m_rateEnabled.isValueChanged() )
{
Expand Down Expand Up @@ -219,8 +226,8 @@ bool BitcrushEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames )
float rsum = 0.0f;
for( int o = 0; o < OS_RATE; ++o )
{
lsum += m_buffer[f * OS_RATE + o][0] * OS_RATIO;
rsum += m_buffer[f * OS_RATE + o][1] * OS_RATIO;
lsum += m_buffer[f * OS_RATE + o][0] * OS_RESAMPLE[o];
rsum += m_buffer[f * OS_RATE + o][1] * OS_RESAMPLE[o];
}
buf[f][0] = d * buf[f][0] + w * qBound( -m_outClip, lsum, m_outClip ) * m_outGain;
buf[f][1] = d * buf[f][1] + w * qBound( -m_outClip, rsum, m_outClip ) * m_outGain;
Expand Down
2 changes: 1 addition & 1 deletion src/core/FxMixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ inline void FxChannel::processed()
void FxChannel::incrementDeps()
{
m_dependenciesMet.ref();
if( m_dependenciesMet >= m_receives.size() )
if( m_dependenciesMet >= m_receives.size() && ! m_queued )
{
m_queued = true;
MixerWorkerThread::addJob( this );
Expand Down
4 changes: 3 additions & 1 deletion src/gui/widgets/Fader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ Fader::Fader( FloatModel * _model, const QString & _name, QWidget * _parent ) :
setMaximumSize( 23, 116);
resize( 23, 116 );
setModel( _model );
setHintText( "Volume:","%");
}


Expand Down Expand Up @@ -141,6 +142,7 @@ Fader::Fader( FloatModel * model, const QString & name, QWidget * parent, QPixma
setMaximumSize( m_back->width(), m_back->height() );
resize( m_back->width(), m_back->height() );
setModel( model );
setHintText( "Volume:","%");
}


Expand Down Expand Up @@ -324,7 +326,7 @@ void Fader::updateTextFloat()
}
else
{
s_textFloat->setText( QString("Volume: %1 %").arg( m_displayConversion ? m_model->value() * 100 : m_model->value() ) );
s_textFloat->setText( m_description + " " + QString("%1 ").arg( m_displayConversion ? m_model->value() * 100 : m_model->value() ) + " " + m_unit );
}
s_textFloat->moveGlobal( this, QPoint( width() - ( *m_knob ).width() - 5, knobPosY() - 46 ) );
}
Expand Down

0 comments on commit a774e5d

Please sign in to comment.