simplified filtering, VST fixes

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@478 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Javier Serrano Polo
2007-04-25 20:48:18 +00:00
parent 416d208cc3
commit f94614cd77
11 changed files with 108 additions and 92 deletions

View File

@@ -1,3 +1,21 @@
2007-04-25 Javier Serrano Polo <jasp00/at/terra/dot/es>
* include/basic_filters.h:
* plugins/flp_import/flp_import.cpp:
* src/core/envelope_tab_widget.cpp:
simplified filtering
* plugins/vst_base/lvsl_server.c:
clear output buffers before processing
* plugins/vestige/vestige.cpp:
* plugins/vst_base/lvsl_client.cpp:
* plugins/vst_base/lvsl_client.h:
fixed sample rate change
* data/locale/ca.ts:
updated translation
2007-04-24 Javier Serrano Polo <jasp00/at/terra/dot/es>
* include/buffer_allocator.h:

View File

@@ -2,8 +2,8 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.50)
AC_INIT(lmms, 0.2.1-svn20070424, lmms-devel/at/lists/dot/sf/dot/net)
AM_INIT_AUTOMAKE(lmms, 0.2.1-svn20070424)
AC_INIT(lmms, 0.2.1-svn20070425, lmms-devel/at/lists/dot/sf/dot/net)
AM_INIT_AUTOMAKE(lmms, 0.2.1-svn20070425)
AM_CONFIG_HEADER(config.h)

Binary file not shown.

View File

@@ -4236,11 +4236,11 @@ clic dret = apaga totes les altres pistes (solo)</translation>
</message>
<message>
<source>use frequency modulation for modulating oscillator 2 with oscillator 1</source>
<translation>usa modulació de freqüència per a modular l&apos;oscil·lador 2 amb l&apos;oscil·lador 1</translation>
<translation>modula la freqüència de l&apos;oscil·lador 1 amb l&apos;oscil·lador 2</translation>
</message>
<message>
<source>use amplitude modulation for modulating oscillator 2 with oscillator 1</source>
<translation>usa modulació d&apos;amplitud per a modular l&apos;oscil·lador 2 amb l&apos;oscil·lador 1</translation>
<translation>modula l&apos;amplitud de l&apos;oscil·lador 1 amb l&apos;oscil·lador 2</translation>
</message>
<message>
<source>mix output of oscillator 1 &amp; 2</source>
@@ -4252,11 +4252,11 @@ clic dret = apaga totes les altres pistes (solo)</translation>
</message>
<message>
<source>use frequency modulation for modulating oscillator 3 with oscillator 2</source>
<translation>usa modulació de freqüència per a modular l&apos;oscil·lador 3 amb l&apos;oscil·lador 2</translation>
<translation>modula la freqüència de l&apos;oscil·lador 2 amb l&apos;oscil·lador 3</translation>
</message>
<message>
<source>use amplitude modulation for modulating oscillator 3 with oscillator 2</source>
<translation>usa modulació d&apos;amplitud per a modular l&apos;oscil·lador 3 amb l&apos;oscil·lador 2</translation>
<translation>modula l&apos;amplitud de l&apos;oscil·lador 2 amb l&apos;oscil·lador 3</translation>
</message>
<message>
<source>mix output of oscillator 2 &amp; 3</source>
@@ -4356,11 +4356,11 @@ clic dret = apaga totes les altres pistes (solo)</translation>
</message>
<message>
<source>use phase modulation for modulating oscillator 2 with oscillator 1</source>
<translation>usa modulació de fase per a modular l&apos;oscil·lador 2 amb l&apos;oscil·lador 1</translation>
<translation>modula la fase de l&apos;oscil·lador 1 amb l&apos;oscil·lador 2</translation>
</message>
<message>
<source>use phase modulation for modulating oscillator 3 with oscillator 2</source>
<translation>usa modulació de fase per a modular l&apos;oscil·lador 3 amb l&apos;oscil·lador 2</translation>
<translation>modula la fase de l&apos;oscil·lador 2 amb l&apos;oscil·lador 3</translation>
</message>
<message>
<source>Modulation type 1</source>

View File

@@ -46,7 +46,6 @@ template<ch_cnt_t CHANNELS = DEFAULT_CHANNELS>
class basicFilters
{
public:
enum filterTypes
{
LOWPASS,
@@ -56,9 +55,7 @@ public:
NOTCH,
ALLPASS,
MOOG,
SIMPLE_FLT_CNT,
DOUBLE_LOWPASS = 16+LOWPASS,
DOUBLE_MOOG = 16+MOOG
SIMPLE_FLT_CNT
} ;
static inline float minQ( void )
@@ -66,14 +63,23 @@ public:
return( 0.01f );
}
static inline filterTypes getFilterType( const int _idx )
inline void setFilterType( const int _idx )
{
if( _idx < SIMPLE_FLT_CNT )
m_double_filter = _idx >= SIMPLE_FLT_CNT;
if( !m_double_filter )
{
return( static_cast<filterTypes>( _idx ) );
m_type = static_cast<filterTypes>( _idx );
return;
}
return( static_cast<filterTypes>( DOUBLE_LOWPASS + _idx -
SIMPLE_FLT_CNT ) );
m_type = static_cast<filterTypes>( LOWPASS + _idx -
SIMPLE_FLT_CNT );
if( m_subFilter == NULL )
{
m_subFilter = new basicFilters<CHANNELS>(
static_cast<sample_rate_t>(
m_sampleRate ) );
}
m_subFilter->m_type = m_type;
}
inline basicFilters( const sample_rate_t _sample_rate ) :
@@ -82,6 +88,7 @@ public:
m_b2a0( 0.0f ),
m_a1a0( 0.0f ),
m_a2a0( 0.0f ),
m_double_filter( FALSE ),
m_sampleRate( _sample_rate ),
m_subFilter( NULL )
{
@@ -109,27 +116,26 @@ public:
switch( m_type )
{
case MOOG:
case DOUBLE_MOOG:
{
sample_t x = _in0 - m_r*m_y4[_chnl];
// four cascaded onepole filters
// (bilinear transform)
m_y1[_chnl] = tLimit(
x*m_p + m_oldx[_chnl]*m_p -
m_k*m_y1[_chnl],
( x + m_oldx[_chnl] ) * m_p
- m_k * m_y1[_chnl],
-10.0f, 10.0f );
m_y2[_chnl] = tLimit(
m_y1[_chnl]*m_p+m_oldy1[_chnl]*
m_p - m_k*m_y2[_chnl],
( m_y1[_chnl] + m_oldy1[_chnl] ) * m_p
- m_k * m_y2[_chnl],
-10.0f, 10.0f );
m_y3[_chnl] = tLimit(
m_y2[_chnl]*m_p+m_oldy2[_chnl]*
m_p - m_k*m_y3[_chnl],
( m_y2[_chnl] + m_oldy2[_chnl] ) * m_p
- m_k * m_y3[_chnl],
-10.0f, 10.0f );
m_y4[_chnl] = tLimit(
m_y3[_chnl]*m_p+m_oldy3[_chnl]*
m_p - m_k*m_y4[_chnl],
( m_y3[_chnl] + m_oldy3[_chnl] ) * m_p
- m_k * m_y4[_chnl],
-10.0f, 10.0f );
m_oldx[_chnl] = x;
@@ -222,7 +228,7 @@ public:
break;
}
if( m_subFilter != NULL )
if( m_double_filter )
{
return( m_subFilter->update( out, _chnl ) );
}
@@ -232,12 +238,6 @@ public:
}
void setType( const filterTypes _type )
{
m_type = _type;
}
inline void calcFilterCoeffs( float _freq, float _q
/*, const bool _q_is_bandwidth = FALSE*/ )
{
@@ -246,30 +246,22 @@ public:
// bad noise out of the filter...
_q = tMax( _q, minQ() );
switch( m_type )
if( m_type == MOOG )
{
case DOUBLE_MOOG:
{
if( m_subFilter == NULL )
{
m_subFilter =
new basicFilters<CHANNELS>(
static_cast<sample_rate_t>( m_sampleRate ) );
m_subFilter->setType( MOOG );
}
m_subFilter->calcFilterCoeffs( _freq, _q );
}
// [ 0 - 0.5 ]
const float f = _freq / m_sampleRate;
// (Empirical tunning)
m_p = ( 3.6f - 3.2f * f ) * f;
m_k = 2.0f * m_p - 1;
m_r = _q * powf( M_E, ( 1 - m_p ) * 1.386249f );
case MOOG:
if( m_double_filter )
{
// [ 0 - 1 ]
const float f = 2 * _freq / m_sampleRate;
// (Empirical tunning)
m_k = 3.6f * f - 1.6f * f * f - 1;
m_p = ( m_k + 1 ) * 0.5f;
m_r = _q * powf( M_E, ( 1 - m_p ) * 1.386249f );
return;
m_subFilter->m_r = m_r;
m_subFilter->m_p = m_p;
m_subFilter->m_k = m_k;
}
return;
/* case DOUBLE_MOOG2:
{
@@ -297,9 +289,6 @@ public:
m_r = 4 * _q * kacr;
break;
}*/
default:
break;
}
// other filters
@@ -316,62 +305,53 @@ public:
const float a0 = 1.0f / ( 1.0f + alpha );
m_a1a0 = -2.0f * tcos * a0;
m_a2a0 = ( 1.0f - alpha ) * a0;
switch( m_type )
{
case LOWPASS:
case DOUBLE_LOWPASS:
m_b0a0 = ( 1.0f - tcos ) * 0.5f * a0;
m_b1a0 = ( 1.0f - tcos ) * a0;
m_b0a0 = m_b1a0 * 0.5f;
m_b2a0 = m_b0a0;//((1.0f-tcos)/2.0f)*a0;
m_a1a0 = -2.0f * tcos * a0;
if( m_type == DOUBLE_LOWPASS )
{
if( m_subFilter == NULL )
{
m_subFilter =
new basicFilters<CHANNELS>( static_cast<sample_rate_t>(
m_sampleRate ) );
m_subFilter->setType( LOWPASS );
}
m_subFilter->calcFilterCoeffs( _freq,
_q );
}
break;
case HIPASS:
m_b0a0 = ( 1.0f + tcos ) * 0.5f * a0;
m_b1a0 = ( -1.0f - tcos ) * a0;
m_b0a0 = m_b1a0 * -0.5f;
m_b2a0 = m_b0a0;//((1.0f+tcos)/2.0f)*a0;
m_a1a0 = -2.0f * tcos * a0;
break;
case BANDPASS_CSG:
m_b0a0 = tsin * 0.5f * a0;
m_b1a0 = 0.0f;
m_b2a0 = -tsin * 0.5f * a0;
m_a1a0 = -2.0f * tcos * a0;
m_b0a0 = tsin * 0.5f * a0;
m_b2a0 = -m_b0a0;
break;
case BANDPASS_CZPG:
m_b0a0 = alpha * a0;
m_b1a0 = 0.0f;
m_b2a0 = -alpha * a0;
m_a1a0 = -2.0f * tcos * a0;
m_b0a0 = alpha * a0;
m_b2a0 = -m_b0a0;
break;
case NOTCH:
m_b1a0 = m_a1a0;
m_b0a0 = a0;
m_b1a0 = -2.0f * tcos * a0;
m_b2a0 = a0;
m_a1a0 = m_b1a0;//(-2.0f*tcos)*a0;
break;
case ALLPASS:
m_b0a0 = ( 1.0f - alpha ) * a0;
m_b1a0 = -2.0f * tcos * a0;
m_b1a0 = m_a1a0;
m_b0a0 = m_a2a0;
m_b2a0 = 1.0f;//(1.0f+alpha)*a0;
m_a1a0 = m_b1a0;//(-2.0f*tcos)*a0;
//m_a2a0 = m_b0a0;//(1.0f-alpha)*a0;
break;
default:
break;
}
m_a2a0 = ( 1.0f - alpha ) * a0;
if( m_double_filter )
{
m_subFilter->m_b0a0 = m_b0a0;
m_subFilter->m_b1a0 = m_b1a0;
m_subFilter->m_b2a0 = m_b2a0;
m_subFilter->m_a1a0 = m_a1a0;
m_subFilter->m_a2a0 = m_a2a0;
}
}
@@ -391,9 +371,11 @@ private:
frame m_y1, m_y2, m_y3, m_y4, m_oldx, m_oldy1, m_oldy2, m_oldy3;
filterTypes m_type;
bool m_double_filter;
float m_sampleRate;
basicFilters<CHANNELS> * m_subFilter;
} ;

View File

@@ -700,6 +700,8 @@ bool flpImport::tryImport( trackContainer * _tc )
case FLP_FilterParams:
{
// TODO: Dirty hack!
// SIMPLE_FLT_CNT equals to old DOUBLE_LOWPASS
const basicFilters<>::filterTypes
mappedFilter[] =
{
@@ -708,9 +710,9 @@ bool flpImport::tryImport( trackContainer * _tc )
basicFilters<>::BANDPASS_CSG,
basicFilters<>::HIPASS,
basicFilters<>::NOTCH,
basicFilters<>::DOUBLE_LOWPASS,
basicFilters<>::SIMPLE_FLT_CNT,
basicFilters<>::LOWPASS,
basicFilters<>::DOUBLE_LOWPASS
basicFilters<>::SIMPLE_FLT_CNT
} ;
Uint32 * p = (Uint32 *) text;
envelopeTabWidget * etw = it->m_envWidget;

View File

@@ -262,8 +262,10 @@ void vestigeInstrument::setParameter( const QString & _param,
m_plugin->showEditor();
connect( engine::getSongEditor(),
SIGNAL( tempoChanged( bpm_t ) ),
m_plugin, SLOT( setTempo( bpm_t ) ) );
m_plugin, SLOT( setTempo( bpm_t ) ) );
m_plugin->setTempo( engine::getSongEditor()->getTempo() );
connect( engine::getMixer(), SIGNAL( sampleRateChanged() ),
m_plugin, SLOT( updateSampleRate() ) );
if( set_ch_name == TRUE )
{
getInstrumentTrack()->setName( m_plugin->name() );

View File

@@ -453,6 +453,17 @@ void remoteVSTPlugin::setTempo( bpm_t _bpm )
void remoteVSTPlugin::updateSampleRate( void )
{
lock();
writeValueS<Sint16>( VST_SAMPLE_RATE );
writeValueS<sample_rate_t>( engine::getMixer()->sampleRate() );
unlock();
}
const QMap<QString, QString> & remoteVSTPlugin::parameterDump( void )
{
writeValueS<Sint16>( VST_GET_PARAMETER_DUMP );

View File

@@ -127,6 +127,7 @@ public:
public slots:
void setTempo( bpm_t _bpm );
void updateSampleRate( void );
private:

View File

@@ -1,7 +1,7 @@
/*
* lvsl_server.cpp - LMMS VST Support Layer Server
*
* Copyright (c) 2005-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005-2007 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -466,6 +466,7 @@ void VSTPlugin::process( void )
for( ch_cnt_t i = 0; i < outputCount(); ++i )
{
m_outputs[i] = &m_shm[( i + inputCount() ) * m_blockSize];
memset( m_outputs[i], 0, m_blockSize * sizeof( float ) );
}
#ifdef OLD_VST_SDK

View File

@@ -280,8 +280,7 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab,
_n->m_filter = new basicFilters<>(
engine::getMixer()->sampleRate() );
}
_n->m_filter->setType( basicFilters<>::getFilterType(
m_filterComboBox->value() ) );
_n->m_filter->setFilterType( m_filterComboBox->value() );
float * cut_buf = NULL;
float * res_buf = NULL;