Merge branch 'master' into ed_refac

This commit is contained in:
Lukas W
2014-12-17 11:35:42 +01:00
73 changed files with 1373 additions and 350 deletions

View File

@@ -1,5 +1,5 @@
/*
* AutomatableSlider.h - class automatableSlider, a QSlider with automation
* AutomatableSlider.h - class AutomatableSlider, a QSlider with automation
*
* Copyright (c) 2006-2008 Javier Serrano Polo <jasp00/at/users.sourceforge.net>
*

View File

@@ -75,68 +75,69 @@ public:
inline void setCoeffs( float freq )
{
// wc
const float wc = F_2PI * freq;
const float wc2 = wc * wc;
const float wc3 = wc2 * wc;
const double wc = D_2PI * freq;
const double wc2 = wc * wc;
const double wc3 = wc2 * wc;
m_wc4 = wc2 * wc2;
// k
const float k = wc / tanf( F_PI * freq / m_sampleRate );
const float k2 = k * k;
const float k3 = k2 * k;
const double k = wc / tan( D_PI * freq / m_sampleRate );
const double k2 = k * k;
const double k3 = k2 * k;
m_k4 = k2 * k2;
// a
static const float sqrt2 = sqrtf( 2.0f );
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;
static const double sqrt2 = sqrt( 2.0 );
const double sq_tmp1 = sqrt2 * wc3 * k;
const double sq_tmp2 = sqrt2 * wc * k3;
m_a = 1.0 / ( 4.0 * wc2 * k2 + 2.0 * sq_tmp1 + m_k4 + 2.0 * 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.0 * ( m_wc4 + sq_tmp1 - m_k4 - sq_tmp2 ) ) * m_a;
m_b2 = ( 6.0 * m_wc4 - 8.0 * wc2 * k2 + 6.0 * m_k4 ) * m_a;
m_b3 = ( 4.0 * ( m_wc4 - sq_tmp1 + sq_tmp2 - m_k4 ) ) * m_a;
m_b4 = ( m_k4 - 2.0 * sq_tmp1 + m_wc4 - 2.0 * sq_tmp2 + 4.0 * wc2 * k2 ) * m_a;
}
inline void setLowpass( float freq )
{
setCoeffs( freq );
m_a0 = m_wc4 / m_a;
m_a1 = 4.0f * m_a0;
m_a2 = 6.0f * m_a0;
m_a0 = m_wc4 * m_a;
m_a1 = 4.0 * m_a0;
m_a2 = 6.0 * m_a0;
}
inline void setHighpass( float freq )
{
setCoeffs( freq );
m_a0 = m_k4 / m_a;
m_a1 = 4.0f * m_a0;
m_a2 = 6.0f * m_a0;
m_a0 = m_k4 * m_a;
m_a1 = -4.0 * m_a0;
m_a2 = 6.0 * m_a0;
}
inline float update( float in, ch_cnt_t ch )
{
const float a0in = m_a0 * in;
const float a1in = m_a1 * in;
const float out = m_z1[ch] + a0in;
const double x = in - ( m_z1[ch] * m_b1 ) - ( m_z2[ch] * m_b2 ) -
( m_z3[ch] * m_b3 ) - ( m_z4[ch] * m_b4 );
const double y = ( m_a0 * x ) + ( m_z1[ch] * m_a1 ) + ( m_z2[ch] * m_a2 ) +
( m_z3[ch] * m_a1 ) + ( m_z4[ch] * m_a0 );
m_z4[ch] = m_z3[ch];
m_z3[ch] = m_z2[ch];
m_z2[ch] = m_z1[ch];
m_z1[ch] = x;
m_z1[ch] = a1in + m_z2[ch] - ( m_b1 * out );
m_z2[ch] = ( m_a2 * in ) + m_z3[ch] - ( m_b2 * out );
m_z3[ch] = a1in + m_z4[ch] - ( m_b3 * out );
m_z4[ch] = a0in - ( m_b4 * out );
return out;
return y;
}
private:
float m_sampleRate;
float m_wc4;
float m_k4;
float m_a, m_a0, m_a1, m_a2;
float m_b1, m_b2, m_b3, m_b4;
double m_wc4;
double m_k4;
double m_a, m_a0, m_a1, m_a2;
double m_b1, m_b2, m_b3, m_b4;
typedef float frame[CHANNELS];
typedef double frame[CHANNELS];
frame m_z1, m_z2, m_z3, m_z4;
};
typedef LinkwitzRiley<2> StereoLinkwitzRiley;

View File

@@ -57,13 +57,14 @@
class TextFloat;
class Fader : public QWidget, public FloatModelView
class EXPORT Fader : public QWidget, public FloatModelView
{
Q_OBJECT
public:
Q_PROPERTY( QColor peakGreen READ peakGreen WRITE setPeakGreen )
Q_PROPERTY( QColor peakRed READ peakRed WRITE setPeakRed )
Fader( FloatModel * _model, const QString & _name, QWidget * _parent );
Fader( FloatModel * _model, const QString & _name, QWidget * _parent, QPixmap * back, QPixmap * leds, QPixmap * knob );
virtual ~Fader();
void setPeak_L( float fPeak );
@@ -76,6 +77,17 @@ public:
QColor peakRed() const;
void setPeakGreen( const QColor & c );
void setPeakRed( const QColor & c );
void setDisplayConversion( bool b )
{
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 );
@@ -91,7 +103,7 @@ private:
float fRange = m_model->maxValue() - m_model->minValue();
float realVal = m_model->value() - m_model->minValue();
return height() - ( ( height() - ( *s_knob ).height() ) * ( realVal / fRange ) );
return height() - ( ( height() - m_knob->height() ) * ( realVal / fRange ) );
}
FloatModel * m_model;
@@ -112,6 +124,12 @@ private:
static QPixmap * s_back;
static QPixmap * s_leds;
static QPixmap * s_knob;
QPixmap * m_back;
QPixmap * m_leds;
QPixmap * m_knob;
bool m_displayConversion;
int m_moveStartPoint;
float m_startValue;

View File

@@ -74,7 +74,7 @@ public:
}
void clearJournal();
void stopAllJournalling();
JournallingObject * journallingObject( const jo_id_t _id )
{
if( m_joIDs.contains( _id ) )

View File

@@ -32,6 +32,7 @@
#include <math.h>
#include "lmms_constants.h"
#include "lmms_math.h"
inline float hermiteInterpolate( float x0, float x1, float x2, float x3,
float frac_pos )
@@ -80,24 +81,13 @@ inline float cubicInterpolate( float v0, float v1, float v2, float v3, float x )
inline float cosinusInterpolate( float v0, float v1, float x )
{
const float f = ( 1.0f - cosf( x * F_PI ) ) * 0.5f;
#ifdef FP_FAST_FMAF
return fmaf( f, v1-v0, v0 );
#else
return f * (v1-v0) + v0;
#endif
// return( v0*f + v1*( 1.0f-f ) );
return fastFmaf( f, v1-v0, v0 );
}
inline float linearInterpolate( float v0, float v1, float x )
{
// take advantage of fma function if present in hardware
#ifdef FP_FAST_FMAF
return fmaf( x, v1-v0, v0 );
#else
return x * (v1-v0) + v0;
#endif
return fastFmaf( x, v1-v0, v0 );
}

View File

@@ -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

View File

@@ -142,6 +142,44 @@ static inline float fastRandf( float range )
return fast_rand() * range * fast_rand_ratio;
}
//! @brief Takes advantage of fmal() function if present in hardware
static inline long double fastFmal( long double a, long double b, long double c )
{
#ifdef FP_FAST_FMAL
#ifdef __clang__
return fma( a, b, c );
#else
return fmal( a, b, c );
#endif
#else
return a * b + c;
#endif
}
//! @brief Takes advantage of fmaf() function if present in hardware
static inline float fastFmaf( float a, float b, float c )
{
#ifdef FP_FAST_FMAF
#ifdef __clang__
return fma( a, b, c );
#else
return fmaf( a, b, c );
#endif
#else
return a * b + c;
#endif
}
//! @brief Takes advantage of fma() function if present in hardware
static inline double fastFma( double a, double b, double c )
{
#ifdef FP_FAST_FMA
return fma( a, b, c );
#else
return a * b + c;
#endif
}
// source: http://martin.ankerl.com/2007/10/04/optimized-pow-approximation-for-java-and-c-c/
static inline double fastPow( double a, double b )
{
@@ -251,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