* added missing includes to compile with GCC 4.4

* optimized various loops for getting tree-vectorized, especially with upcoming GCC 4.4



git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1733 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2008-10-04 14:27:55 +00:00
parent 30a452fd5d
commit 13c00f55a1
26 changed files with 257 additions and 190 deletions

View File

@@ -29,6 +29,7 @@
#include <QtGui/QLineEdit>
#include <QtGui/QLabel>
#include <cstdio>
#include "audio_pulseaudio.h"

View File

@@ -28,6 +28,8 @@
#include <QtXml/QDomElement>
#include <cstdio>
#include "effect.h"
#include "engine.h"
#include "dummy_effect.h"
@@ -172,7 +174,7 @@ void effect::reinitSRC( void )
libsrcInterpolation(),
DEFAULT_CHANNELS, &error ) ) == NULL )
{
printf( "Error: src_new() failed in effect.cpp!\n" );
fprintf( stderr, "Error: src_new() failed in effect.cpp!\n" );
}
}
}
@@ -198,7 +200,7 @@ void effect::resample( int _i, const sampleFrame * _src_buf,
int error;
if( ( error = src_process( m_srcState[_i], &m_srcData[_i] ) ) )
{
printf( "effect::resample(): error while resampling: %s\n",
fprintf( stderr, "effect::resample(): error while resampling: %s\n",
src_strerror( error ) );
}
}

View File

@@ -51,7 +51,7 @@ envelopeAndLFOParameters::envelopeAndLFOParameters(
float _value_for_zero_amount,
model * _parent ) :
model( _parent ),
m_used( FALSE ),
m_used( false ),
m_predelayModel( 0.0, 0.0, 1.0, 0.001, this, tr( "Predelay" ) ),
m_attackModel( 0.0, 0.0, 1.0, 0.001, this, tr( "Attack" ) ),
m_holdModel( 0.5, 0.0, 1.0, 0.001, this, tr( "Hold" ) ),
@@ -72,10 +72,10 @@ envelopeAndLFOParameters::envelopeAndLFOParameters(
tr( "LFO Modulation" ) ),
m_lfoWaveModel( SineWave, 0, NumLfoShapes, this,
tr( "LFO Wave Shape" ) ),
m_x100Model( FALSE, this, tr( "Freq x 100" ) ),
m_controlEnvAmountModel( FALSE, this, tr( "Modulate Env-Amount" ) ),
m_x100Model( false, this, tr( "Freq x 100" ) ),
m_controlEnvAmountModel( false, this, tr( "Modulate Env-Amount" ) ),
m_lfoFrame( 0 ),
m_lfoAmountIsZero( FALSE ),
m_lfoAmountIsZero( false ),
m_lfoShapeData( NULL )
{
s_EaLParametersInstances.push_back( this );
@@ -151,45 +151,39 @@ envelopeAndLFOParameters::~envelopeAndLFOParameters()
inline sample_t envelopeAndLFOParameters::lfoShapeSample( fpp_t _frame_offset )
{
f_cnt_t frame = ( m_lfoFrame + _frame_offset ) % m_lfoOscillationFrames;
const float phase = frame / static_cast<float>(
m_lfoOscillationFrames );
sample_t shape_sample;
switch( m_lfoWaveModel.value() )
{
case TriangleWave:
shape_sample = oscillator::triangleSample( phase );
break;
case SquareWave:
shape_sample = oscillator::squareSample( phase );
break;
case SawWave:
shape_sample = oscillator::sawSample( phase );
break;
case UserDefinedWave:
shape_sample = m_userWave.userWaveSample( phase );
break;
case SineWave:
default:
shape_sample = oscillator::sinSample( phase );
break;
}
return( shape_sample * m_lfoAmount );
}
void envelopeAndLFOParameters::updateLFOShapeData( void )
{
const fpp_t frames = engine::getMixer()->framesPerPeriod();
for( fpp_t offset = 0; offset < frames; ++offset )
const f_cnt_t end_frame = m_lfoFrame+engine::getMixer()->framesPerPeriod();
const float la = m_lfoAmount;
const int wave_model = m_lfoWaveModel.value();
const float lof = m_lfoOscillationFrames;
for( int f = m_lfoFrame; f < end_frame; ++f )
{
m_lfoShapeData[offset] = lfoShapeSample( offset );
const float phase = ( f % m_lfoOscillationFrames ) / lof;
sample_t shape_sample;
switch( wave_model )
{
case TriangleWave:
shape_sample = oscillator::triangleSample( phase );
break;
case SquareWave:
shape_sample = oscillator::squareSample( phase );
break;
case SawWave:
shape_sample = oscillator::sawSample( phase );
break;
case UserDefinedWave:
shape_sample = m_userWave.userWaveSample( phase );
break;
case SineWave:
default:
shape_sample = oscillator::sinSample( phase );
break;
}
m_lfoShapeData[f] = shape_sample * la;
}
m_bad_lfoShapeData = FALSE;
m_bad_lfoShapeData = false;
}
@@ -203,7 +197,7 @@ void envelopeAndLFOParameters::triggerLFO( void )
{
( *it )->m_lfoFrame +=
engine::getMixer()->framesPerPeriod();
( *it )->m_bad_lfoShapeData = TRUE;
( *it )->m_bad_lfoShapeData = true;
}
}
@@ -217,24 +211,20 @@ void envelopeAndLFOParameters::resetLFO( void )
it != v.end(); ++it )
{
( *it )->m_lfoFrame = 0;
( *it )->m_bad_lfoShapeData = TRUE;
( *it )->m_bad_lfoShapeData = true;
}
}
inline void envelopeAndLFOParameters::fillLFOLevel( float * _buf,
void envelopeAndLFOParameters::fillLFOLevel( float * _buf,
f_cnt_t _frame,
const fpp_t _frames )
{
if( m_lfoAmountIsZero || _frame <= m_lfoPredelayFrames )
{
memset( _buf, 0, _frames * sizeof( *_buf ) );
/* for( fpp_t offset = 0; offset < _frames; ++offset )
{
*_buf++ = 0.0f;
}*/
return;
}
_frame -= m_lfoPredelayFrames;
@@ -245,10 +235,15 @@ inline void envelopeAndLFOParameters::fillLFOLevel( float * _buf,
}
fpp_t offset = 0;
for( ; offset < _frames && _frame < m_lfoAttackFrames; ++offset,
++_frame )
const f_cnt_t laf = m_lfoAttackFrames;
float f = _frame;
for( ; offset < _frames; ++offset, ++f )
{
*_buf++ = m_lfoShapeData[offset] * _frame / m_lfoAttackFrames;
if( _frame >= laf )
{
break;
}
*_buf++ = m_lfoShapeData[offset] * _frame / laf;
}
for( ; offset < _frames; ++offset )
{
@@ -270,6 +265,7 @@ void envelopeAndLFOParameters::fillLevel( float * _buf, f_cnt_t _frame,
fillLFOLevel( _buf, _frame, _frames );
const bool control_env_am = m_controlEnvAmountModel.value();
for( fpp_t offset = 0; offset < _frames; ++offset, ++_buf, ++_frame )
{
float env_level;
@@ -296,9 +292,9 @@ void envelopeAndLFOParameters::fillLevel( float * _buf, f_cnt_t _frame,
}
// at this point, *_buf is LFO level
*_buf = m_controlEnvAmountModel.value() ?
env_level * ( 0.5f + *_buf ) :
env_level + *_buf;
*_buf = control_env_am ?
env_level * ( 0.5f + *_buf ) :
env_level + *_buf;
}
}
@@ -411,39 +407,48 @@ void envelopeAndLFOParameters::updateSampleVars( void )
m_pahdEnv = new sample_t[m_pahdFrames];
m_rEnv = new sample_t[m_rFrames];
// strange auto-vectorizer wants local variables
const float aa = m_amountAdd;
const float am = m_amount;
const float sl = m_sustainLevel;
const float afma = attack_frames * am;
const float hold = m_amount + m_amountAdd;
const float rf = m_rFrames;
// fill predelay
for( f_cnt_t i = 0; i < predelay_frames; ++i )
{
m_pahdEnv[i] = m_amountAdd;
m_pahdEnv[i] = aa;
}
// fill attack
f_cnt_t add = predelay_frames;
for( f_cnt_t i = 0; i < attack_frames; ++i )
{
m_pahdEnv[add + i] = ( (float)i / attack_frames ) *
m_amount + m_amountAdd;
m_pahdEnv[add + i] = (float)i / afma + aa;
}
// fill hold
add += attack_frames;
for( f_cnt_t i = 0; i < hold_frames; ++i )
{
m_pahdEnv[add + i] = m_amount + m_amountAdd;
m_pahdEnv[add + i] = hold;
}
// fill decay
add += hold_frames;
for( f_cnt_t i = 0; i < decay_frames; ++i )
{
m_pahdEnv[add + i] = ( m_sustainLevel + ( 1.0f -
(float)i / decay_frames ) *
( 1.0f - m_sustainLevel ) ) *
m_amount + m_amountAdd;
m_pahdEnv[add + i] = ( sl + ( 1.0f - (float)i / decay_frames ) *
( 1.0f - sl ) ) * am + aa;
}
for( f_cnt_t i = 0; i < m_rFrames; ++i )
// fill release
const f_cnt_t rfr = m_rFrames;
const float rfmam = rf * am;
for( f_cnt_t i = 0; i < rfr; ++i )
{
m_rEnv[i] = ( (float)( m_rFrames - i ) / m_rFrames
// * m_sustainLevel
) * m_amount;
m_rEnv[i] = (float)( rf - i ) / rfmam;
}
// save this calculation in real-time-part
@@ -465,21 +470,21 @@ void envelopeAndLFOParameters::updateSampleVars( void )
}
m_lfoAmount = m_lfoAmountModel.value() * 0.5f;
m_used = TRUE;
m_used = true;
if( static_cast<int>( floorf( m_lfoAmount * 1000.0f ) ) == 0 )
{
m_lfoAmountIsZero = TRUE;
m_lfoAmountIsZero = true;
if( static_cast<int>( floorf( m_amount * 1000.0f ) ) == 0 )
{
m_used = FALSE;
m_used = false;
}
}
else
{
m_lfoAmountIsZero = FALSE;
m_lfoAmountIsZero = false;
}
m_bad_lfoShapeData = TRUE;
m_bad_lfoShapeData = true;
emit dataChanged();

View File

@@ -166,33 +166,44 @@ void instrumentSoundShaping::processAudioBuffer( sampleFrame * _ab,
}
_n->m_filter->setFilterType( m_filterModel.value() );
#ifdef __GNUC__
float cut_buf[_frames];
float res_buf[_frames];
#else
float * cut_buf = NULL;
float * res_buf = NULL;
#endif
if( m_envLFOParameters[Cut]->used() )
{
#ifndef __GNUC__
cut_buf = new float[_frames];
#endif
m_envLFOParameters[Cut]->fillLevel( cut_buf, total_frames,
release_begin, _frames );
}
if( m_envLFOParameters[Resonance]->used() )
{
#ifndef __GNUC__
res_buf = new float[_frames];
#endif
m_envLFOParameters[Resonance]->fillLevel( res_buf,
total_frames, release_begin,
_frames );
}
const float fcv = m_filterCutModel.value();
const float frv = m_filterResModel.value();
if( m_envLFOParameters[Cut]->used() &&
m_envLFOParameters[Resonance]->used() )
{
for( fpp_t frame = 0; frame < _frames; ++frame )
{
float new_cut_val = envelopeAndLFOParameters::expKnobVal( cut_buf[frame] ) * CUT_FREQ_MULTIPLIER +
m_filterCutModel.value();
const float new_cut_val = envelopeAndLFOParameters::expKnobVal( cut_buf[frame] ) *
CUT_FREQ_MULTIPLIER + fcv;
float new_res_val = m_filterResModel.value() + RES_MULTIPLIER *
res_buf[frame];
const float new_res_val = frv + RES_MULTIPLIER * res_buf[frame];
if( static_cast<int>( new_cut_val ) != old_filter_cut ||
static_cast<int>( new_res_val*RES_PRECISION ) != old_filter_res )
@@ -202,70 +213,67 @@ void instrumentSoundShaping::processAudioBuffer( sampleFrame * _ab,
old_filter_res = static_cast<int>( new_res_val*RES_PRECISION );
}
for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl )
{
_ab[frame][chnl] = _n->m_filter->update( _ab[frame][chnl], chnl );
}
_ab[frame][0] = _n->m_filter->update( _ab[frame][0], 0 );
_ab[frame][1] = _n->m_filter->update( _ab[frame][1], 1 );
}
}
else if( m_envLFOParameters[Cut]->used() )
{
for( fpp_t frame = 0; frame < _frames; ++frame )
{
float new_cut_val = envelopeAndLFOParameters::expKnobVal( cut_buf[frame] ) * CUT_FREQ_MULTIPLIER +
m_filterCutModel.value();
float new_cut_val = envelopeAndLFOParameters::expKnobVal( cut_buf[frame] ) *
CUT_FREQ_MULTIPLIER + fcv;
if( static_cast<int>( new_cut_val ) != old_filter_cut )
{
_n->m_filter->calcFilterCoeffs( new_cut_val, m_filterResModel.value() );
_n->m_filter->calcFilterCoeffs( new_cut_val, frv );
old_filter_cut = static_cast<int>( new_cut_val );
}
for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl )
{
_ab[frame][chnl] = _n->m_filter->update( _ab[frame][chnl], chnl );
}
_ab[frame][0] = _n->m_filter->update( _ab[frame][0], 0 );
_ab[frame][1] = _n->m_filter->update( _ab[frame][1], 1 );
}
}
else if( m_envLFOParameters[Resonance]->used() )
{
for( fpp_t frame = 0; frame < _frames; ++frame )
{
float new_res_val = m_filterResModel.value() + RES_MULTIPLIER *
res_buf[frame];
float new_res_val = frv + RES_MULTIPLIER * res_buf[frame];
if( static_cast<int>( new_res_val*RES_PRECISION ) != old_filter_res )
{
_n->m_filter->calcFilterCoeffs( m_filterCutModel.value(), new_res_val );
_n->m_filter->calcFilterCoeffs( fcv, new_res_val );
old_filter_res = static_cast<int>( new_res_val*RES_PRECISION );
}
for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl )
{
_ab[frame][chnl] = _n->m_filter->update( _ab[frame][chnl], chnl );
}
_ab[frame][0] = _n->m_filter->update( _ab[frame][0], 0 );
_ab[frame][1] = _n->m_filter->update( _ab[frame][1], 1 );
}
}
else
{
_n->m_filter->calcFilterCoeffs( m_filterCutModel.value(), m_filterResModel.value() );
_n->m_filter->calcFilterCoeffs( fcv, frv );
for( fpp_t frame = 0; frame < _frames; ++frame )
{
for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl )
{
_ab[frame][chnl] = _n->m_filter->update( _ab[frame][chnl], chnl );
}
_ab[frame][0] = _n->m_filter->update( _ab[frame][0], 0 );
_ab[frame][1] = _n->m_filter->update( _ab[frame][1], 1 );
}
}
#ifndef __GNUC__
delete[] cut_buf;
delete[] res_buf;
#endif
}
if( m_envLFOParameters[Volume]->used() )
{
#ifdef __GNUC__
float vol_buf[_frames];
#else
float * vol_buf = new float[_frames];
#endif
m_envLFOParameters[Volume]->fillLevel( vol_buf, total_frames,
release_begin, _frames );
@@ -273,13 +281,12 @@ void instrumentSoundShaping::processAudioBuffer( sampleFrame * _ab,
{
float vol_level = vol_buf[frame];
vol_level = vol_level * vol_level;
for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS;
++chnl )
{
_ab[frame][chnl] = vol_level * _ab[frame][chnl];
}
_ab[frame][0] = vol_level * _ab[frame][0];
_ab[frame][1] = vol_level * _ab[frame][1];
}
#ifndef __GNUC__
delete[] vol_buf;
#endif
}
/* else if( m_envLFOParameters[Volume]->used() == false && m_envLFOParameters[PANNING]->used() )
@@ -315,13 +322,13 @@ f_cnt_t instrumentSoundShaping::envFrames( const bool _only_vol ) const
}
}
}
return( ret_val );
return ret_val;
}
f_cnt_t instrumentSoundShaping::releaseFrames(void ) const
f_cnt_t instrumentSoundShaping::releaseFrames( void ) const
{
f_cnt_t ret_val = m_envLFOParameters[Volume]->used() ?
m_envLFOParameters[Volume]->releaseFrames() : 0;
@@ -344,7 +351,7 @@ f_cnt_t instrumentSoundShaping::releaseFrames(void ) const
}
}
}
return( ret_val );
return ret_val;
}

View File

@@ -27,6 +27,8 @@
#include <QtXml/QDomElement>
#include <cstdio>
#include "journalling_object.h"
#include "automatable_model.h"
#include "project_journal.h"
@@ -155,8 +157,8 @@ void journallingObject::changeID( jo_id_t _id )
dynamic_cast<automatableModel *>( jo )->
displayName();
}
printf( "JO-ID %d already in use by %s!\n", (int) _id,
used_by.toAscii().constData() );
fprintf( stderr, "JO-ID %d already in use by %s!\n",
(int) _id, used_by.toAscii().constData() );
return;
}
engine::getProjectJournal()->forgetAboutID( id() );

View File

@@ -23,6 +23,7 @@
*
*/
#include <cstdio>
#include "ladspa_control.h"
#include "ladspa_base.h"

View File

@@ -26,8 +26,9 @@
*/
#include <cstdio>
#include "midi_client.h"
/*#include "midi_mapper.h"*/
#include "templates.h"
#include "midi_port.h"
#include "note.h"
@@ -285,7 +286,7 @@ void midiClientRaw::processOutEvent( const midiEvent & _me,
break;
default:
printf( "midiClientRaw: unhandled MIDI-event %d\n",
fprintf( stderr, "midiClientRaw: unhandled MIDI-event %d\n",
(int) _me.m_type );
break;
}

View File

@@ -26,6 +26,7 @@
*/
#include <math.h>
#include <cstdio>
#include <QtXml/QDomElement>
#include <QtCore/QObject>
#include <QtCore/QVector>

View File

@@ -26,6 +26,8 @@
*/
#include <cstdio>
#include "tempo_sync_knob.h"
#include <QtGui/QMouseEvent>

View File

@@ -78,8 +78,8 @@ void visualizationWidget::updateAudioBuffer( void )
engine::getMixer()->lock();
const surroundSampleFrame * c = engine::getMixer()->
currentReadBuffer();
for( f_cnt_t f = 0; f < engine::getMixer()->framesPerPeriod();
++f )
const fpp_t fpp = engine::getMixer()->framesPerPeriod();
for( f_cnt_t f = 0; f < fpp; ++f )
{
m_buffer[f][0] = c[f][0];
m_buffer[f][1] = c[f][1];