- made effect::processAudioBuffer(...) process a sampleFrame- instead of

surroundSampleFrame-array
- divide out_sum by number of frames processed to have a
  period-size-independent value



git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@876 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2008-04-03 20:29:11 +00:00
parent 297b57274c
commit 8146dc3d30
13 changed files with 95 additions and 41 deletions

View File

@@ -70,7 +70,7 @@ bassBoosterEffect::~bassBoosterEffect()
bool FASTCALL bassBoosterEffect::processAudioBuffer( surroundSampleFrame * _buf,
bool bassBoosterEffect::processAudioBuffer( sampleFrame * _buf,
const fpp_t _frames )
{
if( !isEnabled() || !isRunning () )
@@ -79,20 +79,20 @@ bool FASTCALL bassBoosterEffect::processAudioBuffer( surroundSampleFrame * _buf,
}
double out_sum = 0.0;
const float d = getDryLevel();
const float w = getWetLevel();
for( fpp_t f = 0; f < _frames; ++f )
{
sample_t s[2] = { _buf[f][0], _buf[f][1] };
m_bbFX.nextSample( s[0], s[1] );
for( ch_cnt_t ch = 0; ch < SURROUND_CHANNELS; ++ch )
for( ch_cnt_t ch = 0; ch < DEFAULT_CHANNELS; ++ch )
{
_buf[f][ch] = getDryLevel() * _buf[f][ch] +
getWetLevel() *
s[ch%DEFAULT_CHANNELS];
_buf[f][ch] = d * _buf[f][ch] + w * s[ch];
out_sum += _buf[f][ch]*_buf[f][ch];
}
}
if( out_sum <= getGate()+0.00001f )
if( out_sum / _frames <= getGate()+0.000001 )
{
incrementBufferCount();
if( getBufferCount() > getTimeout() )

View File

@@ -43,7 +43,7 @@ public:
bassBoosterEffect( model * _parent,
const descriptor::subPluginFeatures::key * _key );
virtual ~bassBoosterEffect();
virtual bool FASTCALL processAudioBuffer( surroundSampleFrame * _buf,
virtual bool processAudioBuffer( sampleFrame * _buf,
const fpp_t _frames );
virtual effectControls * getControls( void )

View File

@@ -328,7 +328,7 @@ ladspaEffect::~ladspaEffect()
bool FASTCALL ladspaEffect::processAudioBuffer( surroundSampleFrame * _buf,
bool ladspaEffect::processAudioBuffer( sampleFrame * _buf,
const fpp_t _frames )
{
if( !isOkay() || dontRun() || !isRunning() || !isEnabled() )
@@ -403,6 +403,8 @@ bool FASTCALL ladspaEffect::processAudioBuffer( surroundSampleFrame * _buf,
// Copy the LADSPA output buffers to the LMMS buffer.
double out_sum = 0.0;
channel = 0;
const float d = getDryLevel();
const float w = getWetLevel();
for( ch_cnt_t proc = 0; proc < getProcessorCount(); proc++)
{
for( Uint16 port = 0; port < m_portCount; port++ )
@@ -418,15 +420,15 @@ bool FASTCALL ladspaEffect::processAudioBuffer( surroundSampleFrame * _buf,
frame < _frames; frame++ )
{
_buf[frame][channel] =
getDryLevel() *
d *
_buf[frame][channel] +
getWetLevel() *
w *
m_ports[proc][port]->buffer[frame];
out_sum +=
_buf[frame][channel] *
_buf[frame][channel];
}
channel++;
++channel;
break;
case AUDIO_RATE_OUTPUT:
case CONTROL_RATE_OUTPUT:
@@ -439,7 +441,7 @@ bool FASTCALL ladspaEffect::processAudioBuffer( surroundSampleFrame * _buf,
// Check whether we need to continue processing input. Restart the
// counter if the threshold has been exceeded.
if( out_sum <= getGate()+0.00001f )
if( out_sum / _frames <= getGate()+0.000001 )
{
incrementBufferCount();
if( getBufferCount() > getTimeout() )

View File

@@ -44,7 +44,7 @@ public:
const descriptor::subPluginFeatures::key * _key );
virtual ~ladspaEffect();
virtual bool FASTCALL processAudioBuffer( surroundSampleFrame * _buf,
virtual bool processAudioBuffer( sampleFrame * _buf,
const fpp_t _frames );
void FASTCALL setControl( Uint16 _control, LADSPA_Data _data );

View File

@@ -1,7 +1,7 @@
/*
* stereo_enhancer.cpp - stereo-enhancer-effect-plugin
*
* Copyright (c) 2006-2007 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2006-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -79,7 +79,7 @@ stereoEnhancerEffect::~stereoEnhancerEffect()
bool FASTCALL stereoEnhancerEffect::processAudioBuffer( surroundSampleFrame * _buf,
bool stereoEnhancerEffect::processAudioBuffer( sampleFrame * _buf,
const fpp_t _frames )
{
@@ -96,6 +96,9 @@ bool FASTCALL stereoEnhancerEffect::processAudioBuffer( surroundSampleFrame * _b
return( FALSE );
}
const float d = getDryLevel();
const float w = getWetLevel();
for( fpp_t f = 0; f < _frames; ++f )
{
@@ -120,11 +123,9 @@ bool FASTCALL stereoEnhancerEffect::processAudioBuffer( surroundSampleFrame * _b
m_seFX.nextSample( s[0], s[1] );
for( ch_cnt_t ch = 0; ch < SURROUND_CHANNELS; ++ch )
for( ch_cnt_t ch = 0; ch < DEFAULT_CHANNELS; ++ch )
{
_buf[f][ch] = getDryLevel() * _buf[f][ch] +
getWetLevel() *
s[ch%DEFAULT_CHANNELS];
_buf[f][ch] = d * _buf[f][ch] + w * s[ch];
out_sum += _buf[f][ch]*_buf[f][ch];
}
@@ -133,7 +134,7 @@ bool FASTCALL stereoEnhancerEffect::processAudioBuffer( surroundSampleFrame * _b
m_currFrame %= DEFAULT_BUFFER_SIZE;
}
if( out_sum <= getGate() )
if( out_sum / _frames <= getGate()+0.00001 )
{
incrementBufferCount();
if( getBufferCount() > getTimeout() )
@@ -152,6 +153,8 @@ bool FASTCALL stereoEnhancerEffect::processAudioBuffer( surroundSampleFrame * _b
}
void stereoEnhancerEffect::clearMyBuffer()
{
int i;

View File

@@ -1,7 +1,7 @@
/*
* stereo_enhancer.h - stereo-enhancer-effect-plugin
*
* Copyright (c) 2006-2007 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2006-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -40,8 +40,8 @@ public:
stereoEnhancerEffect( model * parent,
const descriptor::subPluginFeatures::key * _key );
virtual ~stereoEnhancerEffect();
virtual bool FASTCALL processAudioBuffer( surroundSampleFrame * _buf,
const fpp_t _frames );
virtual bool processAudioBuffer( sampleFrame * _buf,
const fpp_t _frames );
virtual effectControls * getControls( void )
{