Merge branch 'stable-1.1'
Conflicts: data/locale/de.qm data/locale/de.ts src/gui/FxMixerView.cpp
This commit is contained in:
Binary file not shown.
File diff suppressed because it is too large
Load Diff
94
include/RmsHelper.h
Normal file
94
include/RmsHelper.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* RmsHelper.h - helper class for calculating RMS
|
||||
*
|
||||
* Copyright (c) 2014 Vesa Kivimäki <contact/dot/diizy/at/nbl/dot/fi>
|
||||
* Copyright (c) 2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of LMMS - http://lmms.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this program (see COPYING); if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef RMS_HELPER_H
|
||||
#define RMS_HELPER_H
|
||||
|
||||
#include "lmms_math.h"
|
||||
|
||||
class RmsHelper
|
||||
{
|
||||
public:
|
||||
RmsHelper( int size ) :
|
||||
m_buffer( NULL )
|
||||
{
|
||||
setSize( size );
|
||||
}
|
||||
virtual ~RmsHelper()
|
||||
{
|
||||
if( m_buffer ) delete m_buffer;
|
||||
}
|
||||
|
||||
inline void setSize( int size )
|
||||
{
|
||||
if( m_buffer )
|
||||
{
|
||||
if( m_size < size )
|
||||
{
|
||||
delete m_buffer;
|
||||
m_buffer = new float[ size ];
|
||||
m_size = size;
|
||||
reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_size = size;
|
||||
reset();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_buffer = new float[ size ];
|
||||
m_size = size;
|
||||
reset();
|
||||
}
|
||||
}
|
||||
|
||||
inline void reset()
|
||||
{
|
||||
m_sizef = 1.0f / (float) m_size;
|
||||
m_pos = 0;
|
||||
m_sum = 0.0f;
|
||||
memset( m_buffer, 0, m_size * sizeof( float ) );
|
||||
}
|
||||
|
||||
inline float update( const float in )
|
||||
{
|
||||
m_sum -= m_buffer[ m_pos ];
|
||||
m_sum += m_buffer[ m_pos ] = in * in;
|
||||
++m_pos %= m_size;
|
||||
return sqrtf( m_sum * m_sizef );
|
||||
}
|
||||
|
||||
private:
|
||||
float * m_buffer;
|
||||
float m_sum;
|
||||
unsigned int m_pos;
|
||||
unsigned int m_size;
|
||||
float m_sizef;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -58,7 +58,10 @@ dynProcEffect::dynProcEffect( Model * _parent,
|
||||
m_dpControls( this )
|
||||
{
|
||||
m_currentPeak[0] = m_currentPeak[1] = DYN_NOISE_FLOOR;
|
||||
m_needsUpdate = true;
|
||||
m_rms[0] = new RmsHelper( 64 * engine::mixer()->processingSampleRate() / 44100 );
|
||||
m_rms[1] = new RmsHelper( 64 * engine::mixer()->processingSampleRate() / 44100 );
|
||||
calcAttack();
|
||||
calcRelease();
|
||||
}
|
||||
|
||||
|
||||
@@ -66,17 +69,19 @@ dynProcEffect::dynProcEffect( Model * _parent,
|
||||
|
||||
dynProcEffect::~dynProcEffect()
|
||||
{
|
||||
delete m_rms[0];
|
||||
delete m_rms[1];
|
||||
}
|
||||
|
||||
|
||||
inline void dynProcEffect::calcAttack()
|
||||
{
|
||||
m_attCoeff = exp10( ( DNF_LOG / ( m_dpControls.m_attackModel.value() * 0.001 ) ) / engine::mixer()->processingSampleRate() );
|
||||
m_attCoeff = pow( 10, ( DNF_LOG / ( m_dpControls.m_attackModel.value() * 0.001 ) ) / engine::mixer()->processingSampleRate() );
|
||||
}
|
||||
|
||||
inline void dynProcEffect::calcRelease()
|
||||
{
|
||||
m_relCoeff = exp10( ( -DNF_LOG / ( m_dpControls.m_releaseModel.value() * 0.001 ) ) / engine::mixer()->processingSampleRate() );
|
||||
m_relCoeff = pow( 10, ( -DNF_LOG / ( m_dpControls.m_releaseModel.value() * 0.001 ) ) / engine::mixer()->processingSampleRate() );
|
||||
}
|
||||
|
||||
|
||||
@@ -110,15 +115,25 @@ bool dynProcEffect::processAudioBuffer( sampleFrame * _buf,
|
||||
// debug code
|
||||
// qDebug( "peaks %f %f", m_currentPeak[0], m_currentPeak[1] );
|
||||
|
||||
if( m_dpControls.m_attackModel.isValueChanged() || m_needsUpdate )
|
||||
if( m_needsUpdate )
|
||||
{
|
||||
m_rms[0]->setSize( 64 * engine::mixer()->processingSampleRate() / 44100 );
|
||||
m_rms[1]->setSize( 64 * engine::mixer()->processingSampleRate() / 44100 );
|
||||
calcAttack();
|
||||
}
|
||||
if( m_dpControls.m_releaseModel.isValueChanged() || m_needsUpdate )
|
||||
{
|
||||
calcRelease();
|
||||
m_needsUpdate = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( m_dpControls.m_attackModel.isValueChanged() )
|
||||
{
|
||||
calcAttack();
|
||||
}
|
||||
if( m_dpControls.m_releaseModel.isValueChanged() )
|
||||
{
|
||||
calcRelease();
|
||||
}
|
||||
}
|
||||
m_needsUpdate = false;
|
||||
|
||||
for( fpp_t f = 0; f < _frames; ++f )
|
||||
{
|
||||
@@ -131,14 +146,15 @@ bool dynProcEffect::processAudioBuffer( sampleFrame * _buf,
|
||||
// update peak values
|
||||
for ( i=0; i <= 1; i++ )
|
||||
{
|
||||
if( qAbs( s[i] ) > m_currentPeak[i] )
|
||||
const double t = m_rms[i]->update( s[i] );
|
||||
if( t > m_currentPeak[i] )
|
||||
{
|
||||
m_currentPeak[i] = qMin( m_currentPeak[i] * m_attCoeff, qAbs( s[i] ) );
|
||||
m_currentPeak[i] = qMin( m_currentPeak[i] * m_attCoeff, t );
|
||||
}
|
||||
else
|
||||
if( qAbs( s[i] ) < m_currentPeak[i] )
|
||||
if( t < m_currentPeak[i] )
|
||||
{
|
||||
m_currentPeak[i] = qMax( m_currentPeak[i] * m_relCoeff, qAbs( s[i] ) );
|
||||
m_currentPeak[i] = qMax( m_currentPeak[i] * m_relCoeff, t );
|
||||
}
|
||||
|
||||
m_currentPeak[i] = qBound( DYN_NOISE_FLOOR, m_currentPeak[i], 10.0f );
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
#include "Effect.h"
|
||||
#include "dynamics_processor_controls.h"
|
||||
|
||||
#include "RmsHelper.h"
|
||||
|
||||
|
||||
class dynProcEffect : public Effect
|
||||
@@ -59,6 +59,8 @@ private:
|
||||
double m_relCoeff;
|
||||
|
||||
bool m_needsUpdate;
|
||||
|
||||
RmsHelper * m_rms [2];
|
||||
|
||||
friend class dynProcControls;
|
||||
|
||||
|
||||
@@ -71,7 +71,6 @@ public:
|
||||
|
||||
|
||||
private slots:
|
||||
void changeControl();
|
||||
void samplesChanged( int, int );
|
||||
void sampleRateChanged();
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -128,6 +128,7 @@ EffectSelectDialog::EffectSelectDialog( QWidget * _parent ) :
|
||||
|
||||
EffectSelectDialog::~EffectSelectDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -412,12 +412,12 @@ void FxMixerView::moveChannelLeft(int index)
|
||||
int replaceIndex = chLayout->indexOf(m_fxChannelViews[i]->m_fxLine);
|
||||
|
||||
chLayout->removeWidget(m_fxChannelViews[i]->m_fxLine);
|
||||
m_racksLayout->removeWidget( m_fxChannelViews[i]->m_rackView );
|
||||
delete m_fxChannelViews[i]->m_fader;
|
||||
delete m_fxChannelViews[i]->m_muteBtn;
|
||||
delete m_fxChannelViews[i]->m_soloBtn;
|
||||
delete m_fxChannelViews[i]->m_fxLine;
|
||||
delete m_fxChannelViews[i];
|
||||
m_racksLayout->removeWidget( m_fxChannelViews[i]->m_rackView );
|
||||
|
||||
// add it again
|
||||
m_fxChannelViews[i] = new FxChannelView( m_channelAreaWidget, this, i );
|
||||
|
||||
Reference in New Issue
Block a user