Esempio n. 1
0
float EqHandle::getLowShelfCurve( float x )
{
    double freqZ = xPixelToFreq( EqHandle::x(), m_width );
    const int SR = Engine::mixer()->processingSampleRate();
    double w0 = 2 * LD_PI * freqZ / SR ;
    double c = cosf( w0 );
    double s = sinf( w0 );
    double A =  pow( 10, yPixelToGain( EqHandle::y(), m_heigth, m_pixelsPerUnitHeight ) / 40 );
    double beta = sqrt( A ) / m_resonance;
    double a0, a1, a2, b0, b1, b2; // coeffs to calculate

    //calc coefficents
    b0 = A * ( ( A + 1 ) - ( A - 1 ) * c + beta * s );
    b1 = 2  * A * ( ( A - 1 ) - ( A + 1 ) * c ) ;
    b2 = A * ( ( A + 1 ) - ( A - 1 ) * c - beta * s);
    a0 = ( A + 1 ) + ( A - 1 ) * c + beta * s;
    a1 = -2 * ( ( A - 1 ) + ( A + 1 ) * c );
    a2 = ( A + 1 ) + ( A - 1) * c - beta * s;

    //normalise
    b0 /= a0;
    b1 /= a0;
    b2 /= a0;
    a1 /= a0;
    a2 /= a0;
    a0 = 1;

    double freq = xPixelToFreq( x, m_width );
    double gain = calculateGain( freq, a1, a2, b0, b1, b2 );
    float y = gainToYPixel( gain, m_heigth, m_pixelsPerUnitHeight );

    return y;
}
Esempio n. 2
0
float EqHandle::getPeakCurve( float x )
{
    double freqZ = xPixelToFreq( EqHandle::x(), m_width );
    const int SR = Engine::mixer()->processingSampleRate();
    double w0 = 2 * LD_PI * freqZ / SR ;
    double c = cosf( w0 );
    double s = sinf( w0 );
    double Q = getResonance();
    double A =  pow( 10, yPixelToGain( EqHandle::y(), m_heigth, m_pixelsPerUnitHeight ) / 40 );
    double alpha = s * sinh( log( 2 ) / 2 * Q * w0 / sinf( w0 ) );
    double a0, a1, a2, b0, b1, b2; // coeffs to calculate

    //calc coefficents
    b0 =   1 + alpha * A;
    b1 =  -2 * c;
    b2 =   1 - alpha * A;
    a0 =   1 + alpha / A;
    a1 =  -2 * c;
    a2 =   1 - alpha / A;

    //normalise
    b0 /= a0;
    b1 /= a0;
    b2 /= a0;
    a1 /= a0;
    a2 /= a0;
    a0 = 1;

    double freq = xPixelToFreq( x, m_width );
    double gain = calculateGain( freq, a1, a2, b0, b1, b2 );
    float y = gainToYPixel( gain, m_heigth, m_pixelsPerUnitHeight );

    return y;
}
Esempio n. 3
0
float EqHandle::getHighCutCurve( float x )
{
    double freqZ = xPixelToFreq( EqHandle::x(), m_width );
    const int SR = Engine::mixer()->processingSampleRate();
    double w0 = 2 * LD_PI * freqZ / SR ;
    double c = cosf( w0 );
    double s = sinf( w0 );
    double resonance = getResonance();
    double A = pow( 10, yPixelToGain( EqHandle::y(), m_heigth, m_pixelsPerUnitHeight ) / 20 );
    double alpha = s / 2 * sqrt ( ( A + 1 / A ) * ( 1 / resonance -1 ) +2 );
    double a0, a1, a2, b0, b1, b2; // coeffs to calculate

    b0 = ( 1 - c ) * 0.5;
    b1 = 1 - c;
    b2 = ( 1 - c ) * 0.5;
    a0 = 1 + alpha;
    a1 = -2 * c;
    a2 = 1 - alpha;
    //normalise
    b0 /= a0;
    b1 /= a0;
    b2 /= a0;
    a1 /= a0;
    a2 /= a0;
    a0 = 1;

    double freq = xPixelToFreq( x, m_width );
    double gain = calculateGain( freq, a1, a2, b0, b1, b2 );
    if ( m_lp24 )
    {
        gain = gain * 2;
    }
    if ( m_lp48 )
    {
        gain = gain * 3;
    }
    float y = gainToYPixel( gain, m_heigth, m_pixelsPerUnitHeight );

    return y;
}
const QString KInvestmentListItem::calculateYTDGain(const equity_price_history& history)
{
  return calculateGain(history, 0, 0, true, bColumn9Negative);
}
const QString KInvestmentListItem::calculate3MonthGain(const equity_price_history& history)
{
  return calculateGain(history, 0, -3, false, bColumn8Negative);
}
const QString KInvestmentListItem::calculate4WeekGain(const equity_price_history& history)
{
  return calculateGain(history, -28, 0, false, bColumn7Negative);
}