diff --git a/ChangeLog b/ChangeLog index cf48bbf9c..8c786086b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,43 @@ +2008-10-04 Tobias Doerffel + + * plugins/lb302/lb302.cpp: + * plugins/lb302/lb302.h: + * plugins/bass_booster/bass_booster.cpp: + * plugins/bass_booster/bass_booster.h: + * plugins/bit_invader/bit_invader.cpp: + * plugins/vst_effect/vst_effect.cpp: + * plugins/peak_controller_effect/peak_controller_effect.cpp: + * plugins/stereo_enhancer/stereo_enhancer.cpp: + * plugins/stereo_enhancer/stereo_enhancer.h: + * plugins/spectrum_analyzer/spectrumanalyzer_control_dialog.cpp: + * plugins/kicker/kicker.cpp: + * include/sweep_oscillator.h: + * include/envelope_and_lfo_parameters.h: + * include/remote_plugin.h: + * include/types.h: + * src/core/midi/midi_client.cpp: + * src/core/journalling_object.cpp: + * src/core/audio/audio_pulseaudio.cpp: + * src/core/envelope_and_lfo_parameters.cpp: + * src/core/instrument_sound_shaping.cpp: + * src/core/effect.cpp: + * src/core/ladspa_control.cpp: + * src/core/peak_controller.cpp: + * src/gui/widgets/visualization_widget.cpp: + * src/gui/widgets/tempo_sync_knob.cpp: + - added missing includes to compile with GCC 4.4 + - optimized various loops for getting tree-vectorized, especially with + upcoming GCC 4.4 + + * CMakeLists.txt: + use -ftree-vectorize per default - everyone compiling LMMS (which + needs Qt >= 4.3.0) will at least have GCC 4.1, anyways only makes + sense when setting C(XX)FLAGS=-march=... + + * include/effect_lib.h: + improved effectLib for not being based on virtual-functions rather than + direct function-inlining via template parameter + 2008-10-02 Tobias Doerffel * plugins/lb302/lb302.h: diff --git a/include/envelope_and_lfo_parameters.h b/include/envelope_and_lfo_parameters.h index cf8673e19..c32d5a011 100644 --- a/include/envelope_and_lfo_parameters.h +++ b/include/envelope_and_lfo_parameters.h @@ -142,7 +142,6 @@ private: NumLfoShapes } ; - sample_t lfoShapeSample( fpp_t _frame_offset ); void updateLFOShapeData( void ); diff --git a/include/remote_plugin.h b/include/remote_plugin.h index 3bfad533d..8a4ce363d 100755 --- a/include/remote_plugin.h +++ b/include/remote_plugin.h @@ -30,6 +30,7 @@ #include "midi.h" #include +#include #include #include #include diff --git a/include/sweep_oscillator.h b/include/sweep_oscillator.h index b269297ad..33ed59e96 100644 --- a/include/sweep_oscillator.h +++ b/include/sweep_oscillator.h @@ -30,7 +30,7 @@ #include "effect_lib.h" -template > +template class sweepOscillator { public: @@ -51,11 +51,9 @@ public: const float df = _freq2 - _freq1; for( fpp_t frame = 0; frame < _frames; ++frame ) { - sample_t s = oscillator::sinSample( m_phase ); - for( ch_cnt_t ch = 0; ch < DEFAULT_CHANNELS; ++ch ) - { - _ab[frame][ch] = s; - } + const sample_t s = oscillator::sinSample( m_phase ); + _ab[frame][0] = s; + _ab[frame][1] = s; m_FX.nextSample( _ab[frame][0], _ab[frame][1] ); m_phase += ( _freq1 + ( frame * df / _frames ) ) / _sample_rate; diff --git a/include/types.h b/include/types.h index da3e6c5b0..dc6659f29 100644 --- a/include/types.h +++ b/include/types.h @@ -30,6 +30,10 @@ #include "lmmsconfig.h" +#ifdef LMMS_HAVE_STDINT_H +#include +#endif + typedef unsigned char Uint8; typedef signed char Sint8; typedef unsigned short Uint16; @@ -127,6 +131,8 @@ const ch_cnt_t SURROUND_CHANNELS = typedef sample_t sampleFrame[DEFAULT_CHANNELS]; typedef sample_t surroundSampleFrame[SURROUND_CHANNELS]; - +#if __GNUC__ +typedef sample_t sampleFrameA[DEFAULT_CHANNELS] __attribute__((__aligned__(16))); +#endif #endif diff --git a/plugins/bass_booster/bass_booster.cpp b/plugins/bass_booster/bass_booster.cpp index 6e5b37305..b52e4a49d 100644 --- a/plugins/bass_booster/bass_booster.cpp +++ b/plugins/bass_booster/bass_booster.cpp @@ -54,7 +54,7 @@ plugin::descriptor PLUGIN_EXPORT bassbooster_plugin_descriptor = bassBoosterEffect::bassBoosterEffect( model * _parent, const descriptor::subPluginFeatures::key * _key ) : effect( &bassbooster_plugin_descriptor, _parent, _key ), - m_bbFX( effectLib::fastBassBoost<>( 70.0f, 1.0f, 2.8f ) ), + m_bbFX( effectLib::fastBassBoost( 70.0f, 1.0f, 2.8f ) ), m_bbControls( this ) { } diff --git a/plugins/bass_booster/bass_booster.h b/plugins/bass_booster/bass_booster.h index 86f378dcd..17f5c107e 100644 --- a/plugins/bass_booster/bass_booster.h +++ b/plugins/bass_booster/bass_booster.h @@ -48,7 +48,7 @@ public: private: - effectLib::monoToStereoAdaptor > m_bbFX; + effectLib::monoToStereoAdaptor m_bbFX; bassBoosterControls m_bbControls; diff --git a/plugins/bit_invader/bit_invader.cpp b/plugins/bit_invader/bit_invader.cpp index 4ab7fa851..c85544a9b 100644 --- a/plugins/bit_invader/bit_invader.cpp +++ b/plugins/bit_invader/bit_invader.cpp @@ -72,7 +72,7 @@ bSynth::bSynth( float * _shape, int _length, notePlayHandle * _nph, bool _interp interpolation( _interpolation) { sample_shape = new float[sample_length]; - for (int i=0; i < _length; i++) + for (int i=0; i < _length; ++i) { sample_shape[i] = _shape[i] * _factor; } @@ -241,7 +241,8 @@ void bitInvader::normalize( void ) const float* samples = m_graph.samples(); for(int i=0; i < m_graph.length(); i++) { - if (fabsf(samples[i]) > max) { max = fabs(samples[i]); } + const float f = fabsf( samples[i] ); + if (f > max) { max = f; } } normalizeFactor = 1.0 / max; } diff --git a/plugins/kicker/kicker.cpp b/plugins/kicker/kicker.cpp index 9b5af9702..7b284fcd9 100644 --- a/plugins/kicker/kicker.cpp +++ b/plugins/kicker/kicker.cpp @@ -110,7 +110,7 @@ QString kickerInstrument::nodeName( void ) const //typedef effectLib::foldbackDistortion<> distFX; -typedef effectLib::distortion<> distFX; +typedef effectLib::distortion distFX; typedef sweepOscillator > sweepOsc; diff --git a/plugins/lb302/lb302.cpp b/plugins/lb302/lb302.cpp index cbe43cfb6..d47621d26 100644 --- a/plugins/lb302/lb302.cpp +++ b/plugins/lb302/lb302.cpp @@ -148,7 +148,7 @@ lb302FilterIIR2::lb302FilterIIR2(lb302FilterKnobState* p_fs) : vcf_c(1) { - m_dist = new effectLib::distortion<>( 1.0, 1.0f); + m_dist = new effectLib::distortion( 1.0, 1.0f); }; diff --git a/plugins/lb302/lb302.h b/plugins/lb302/lb302.h index 91f485391..289b75b26 100644 --- a/plugins/lb302/lb302.h +++ b/plugins/lb302/lb302.h @@ -94,8 +94,7 @@ class lb302FilterIIR2 : public lb302Filter vcf_b, // vcf_c; - effectLib::monoToStereoAdaptor > * m_dist_fx; - effectLib::distortion<> * m_dist; + effectLib::distortion * m_dist; }; diff --git a/plugins/peak_controller_effect/peak_controller_effect.cpp b/plugins/peak_controller_effect/peak_controller_effect.cpp index 6b564487d..64a32a9dc 100644 --- a/plugins/peak_controller_effect/peak_controller_effect.cpp +++ b/plugins/peak_controller_effect/peak_controller_effect.cpp @@ -104,7 +104,12 @@ bool peakControllerEffect::processAudioBuffer( sampleFrame * _buf, { for( int i = 0; i < _frames; ++i ) { + // is this really RMS??? sum += (_buf[i][0]+_buf[i][0]) * (_buf[i][1]+_buf[i][1]); + } + // eases vectorization + for( int i = 0; i < _frames; ++i ) + { _buf[i][0] = _buf[i][1] = 0.0f; } } diff --git a/plugins/spectrum_analyzer/spectrumanalyzer_control_dialog.cpp b/plugins/spectrum_analyzer/spectrumanalyzer_control_dialog.cpp index e17b2159d..1d24ba653 100644 --- a/plugins/spectrum_analyzer/spectrumanalyzer_control_dialog.cpp +++ b/plugins/spectrum_analyzer/spectrumanalyzer_control_dialog.cpp @@ -32,20 +32,19 @@ #include "embed.h" -inline void darken( QImage & _i, int _x, int _y, int _w, int _h ) +static inline void darken( QImage & _i, int _x, int _y, int _w, int _h ) { - uchar * d = _i.scanLine( _y ) + _x * sizeof( QRgb ); - const int add = ( _i.width() - _w ) * sizeof( QRgb ); + const int w = _i.width(); + QRgb * base = ( (QRgb *) _i.bits() ) + _y*w + _x; for( int y = 0; y < _h; ++y ) { + QRgb * d = base + y*w; for( int x = 0; x < _w; ++x ) { - *d = *d >> 1; ++d; - *d = *d >> 1; ++d; - *d = *d >> 1; ++d; - ++d; + // shift each color component by 1 bit and set alpha + // to 0xff + d[x] = ( ( d[x] >> 1 ) & 0x7f7f7f7f ) | 0xff000000; } - d += add; } } @@ -87,60 +86,54 @@ public: float * b = m_sa->m_bands; const int LOWER_Y = -60; // dB int h; + const int fh = height(); if( m_sa->m_saControls.m_linearSpec.value() ) { - for( int x = 0; x < MAX_BANDS; ++x, ++b ) + if( lin_y ) { - if( lin_y ) + for( int x = 0; x < MAX_BANDS; ++x, ++b ) { - h = height() * 2.0 / 3.0 * (*b / e ); + h = fh * 2.0 / 3.0 * (*b / e ); + if( h < 0 ) h = 0; else if( h >= fh ) continue; + darken( i, x, 0, 1, fh-h ); } - else + } + else + { + for( int x = 0; x < MAX_BANDS; ++x, ++b ) { - h = (int)( height() * 2.0 / 3.0 * (20*(log10( *b / e ) ) - LOWER_Y ) / (-LOWER_Y ) ); + h = (int)( fh * 2.0 / 3.0 * (20*(log10( *b / e ) ) - LOWER_Y ) / (-LOWER_Y ) ); + if( h < 0 ) h = 0; else if( h >= fh ) continue; + darken( i, x, 0, 1, fh-h ); } - if( h < 0 ) - { - h = 0; - } - else if( h > height() ) - { - h = height(); - } - darken( i, x, 0, 1, height()-h ); } } else { - for( int x = 0; x < 31; ++x, ++b ) + if( lin_y ) { - if( lin_y ) + for( int x = 0; x < 31; ++x, ++b ) { - h = height() * 2.0 / 3.0 * ( 1.2 * *b / e ); + h = fh * 2.0 / 3.0 * ( 1.2 * *b / e ); + if( h < 0 ) h = 0; else if( h >= fh ) continue; else h = ( h / 3 ) * 3; + darken( i, x*8, 0, 8, fh-h ); } - else - { - h = (int)( height() * 2.0 / 3.0 * (20*(log10( *b / e ) ) - LOWER_Y ) / (-LOWER_Y ) ); - } - if( h < 0 ) - { - h = 0; - } - else if( h > height() ) - { - h = height(); - } - else - { - h = ( h / 3 ) * 3; - } - darken( i, x*8, 0, 8, height()-h ); } - darken( i, 31*8, 0, 1, height() ); + else + { + for( int x = 0; x < 31; ++x, ++b ) + { + h = (int)( fh * 2.0 / 3.0 * (20*(log10( *b / e ) ) - LOWER_Y ) / (-LOWER_Y ) ); + if( h < 0 ) h = 0; else if( h >= fh ) continue; else h = ( h / 3 ) * 3; + darken( i, x*8, 0, 8, fh-h ); + } + } + darken( i, 31*8, 0, 1, fh ); } p.drawImage( 0, 0, i ); } + private: spectrumAnalyzer * m_sa; QImage m_backgroundPlain; diff --git a/plugins/stereo_enhancer/stereo_enhancer.cpp b/plugins/stereo_enhancer/stereo_enhancer.cpp index 17d1055a5..e120c5825 100644 --- a/plugins/stereo_enhancer/stereo_enhancer.cpp +++ b/plugins/stereo_enhancer/stereo_enhancer.cpp @@ -55,7 +55,7 @@ stereoEnhancerEffect::stereoEnhancerEffect( model * _parent, const descriptor::subPluginFeatures::key * _key ) : effect( &stereoenhancer_plugin_descriptor, _parent, _key ), - m_seFX( effectLib::stereoEnhancer<>( 0.0f ) ), + m_seFX( effectLib::stereoEnhancer( 0.0f ) ), m_delayBuffer( new sampleFrame[DEFAULT_BUFFER_SIZE] ), m_currFrame( 0 ), m_bbControls( this ) @@ -107,13 +107,13 @@ bool stereoEnhancerEffect::processAudioBuffer( sampleFrame * _buf, // copy samples into the delay buffer m_delayBuffer[m_currFrame][0] = _buf[f][0]; m_delayBuffer[m_currFrame][1] = _buf[f][1]; - + // Get the width knob value from the Stereo Enhancer effect width = m_seFX.getWideCoeff(); - + // Calculate the correct sample frame for processing frameIndex = m_currFrame - width; - + if( frameIndex < 0 ) { // e.g. difference = -10, frameIndex = DBS - 10 @@ -122,7 +122,7 @@ bool stereoEnhancerEffect::processAudioBuffer( sampleFrame * _buf, //sample_t s[2] = { _buf[f][0], _buf[f][1] }; //Vanilla sample_t s[2] = { _buf[f][0], m_delayBuffer[frameIndex][1] }; //Chocolate - + m_seFX.nextSample( s[0], s[1] ); _buf[f][0] = d * _buf[f][0] + w * s[0]; @@ -154,7 +154,7 @@ void stereoEnhancerEffect::clearMyBuffer() m_delayBuffer[i][0] = 0.0f; m_delayBuffer[i][1] = 0.0f; } - + m_currFrame = 0; } diff --git a/plugins/stereo_enhancer/stereo_enhancer.h b/plugins/stereo_enhancer/stereo_enhancer.h index faa557cf5..8fd10e3db 100644 --- a/plugins/stereo_enhancer/stereo_enhancer.h +++ b/plugins/stereo_enhancer/stereo_enhancer.h @@ -52,7 +52,7 @@ public: private: - effectLib::stereoEnhancer<> m_seFX; + effectLib::stereoEnhancer m_seFX; sampleFrame * m_delayBuffer; int m_currFrame; diff --git a/plugins/vst_effect/vst_effect.cpp b/plugins/vst_effect/vst_effect.cpp index ddda538c8..90b1a8904 100644 --- a/plugins/vst_effect/vst_effect.cpp +++ b/plugins/vst_effect/vst_effect.cpp @@ -91,32 +91,35 @@ bool vstEffect::processAudioBuffer( sampleFrame * _buf, const fpp_t _frames ) if( m_plugin ) { + const float d = getDryLevel(); +#ifdef __GNUC__ + sampleFrame buf[_frames]; +#else sampleFrame * buf = new sampleFrame[_frames]; - for( fpp_t f = 0; f < _frames; ++f ) - { - for( ch_cnt_t ch = 0; ch < DEFAULT_CHANNELS; ++ch ) - { - buf[f][ch] = _buf[f][ch]; - } - } +#endif + memcpy( buf, _buf, sizeof( sampleFrame ) * _frames ); m_pluginMutex.lock(); m_plugin->process( buf, buf ); m_pluginMutex.unlock(); double out_sum = 0.0; - const float d = getDryLevel(); const float w = getWetLevel(); for( fpp_t f = 0; f < _frames; ++f ) { - _buf[f][0] = d * _buf[f][0] + w * buf[f][0]; - _buf[f][1] = d * _buf[f][1] + w * buf[f][1]; + _buf[f][0] = w*buf[f][0] + d*_buf[f][0]; + _buf[f][1] = w*buf[f][1] + d*_buf[f][1]; + } + for( fpp_t f = 0; f < _frames; ++f ) + { out_sum += _buf[f][0]*_buf[f][0] + _buf[f][1]*_buf[f][1]; } +#ifndef __GNUC__ delete[] buf; +#endif checkGate( out_sum / _frames ); } - return( isRunning() ); + return isRunning(); } diff --git a/src/core/audio/audio_pulseaudio.cpp b/src/core/audio/audio_pulseaudio.cpp index 4922a6fbf..0a4b8978d 100644 --- a/src/core/audio/audio_pulseaudio.cpp +++ b/src/core/audio/audio_pulseaudio.cpp @@ -29,6 +29,7 @@ #include #include +#include #include "audio_pulseaudio.h" diff --git a/src/core/effect.cpp b/src/core/effect.cpp index 83070a23f..f899ebf9c 100644 --- a/src/core/effect.cpp +++ b/src/core/effect.cpp @@ -28,6 +28,8 @@ #include +#include + #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 ) ); } } diff --git a/src/core/envelope_and_lfo_parameters.cpp b/src/core/envelope_and_lfo_parameters.cpp index 203928ca3..84de70065 100644 --- a/src/core/envelope_and_lfo_parameters.cpp +++ b/src/core/envelope_and_lfo_parameters.cpp @@ -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( - 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( floorf( m_lfoAmount * 1000.0f ) ) == 0 ) { - m_lfoAmountIsZero = TRUE; + m_lfoAmountIsZero = true; if( static_cast( 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(); diff --git a/src/core/instrument_sound_shaping.cpp b/src/core/instrument_sound_shaping.cpp index de4912d04..ae77aa238 100644 --- a/src/core/instrument_sound_shaping.cpp +++ b/src/core/instrument_sound_shaping.cpp @@ -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( new_cut_val ) != old_filter_cut || static_cast( new_res_val*RES_PRECISION ) != old_filter_res ) @@ -202,70 +213,67 @@ void instrumentSoundShaping::processAudioBuffer( sampleFrame * _ab, old_filter_res = static_cast( 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( 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( 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( 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( 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; } diff --git a/src/core/journalling_object.cpp b/src/core/journalling_object.cpp index 26d8d788f..29a8e5920 100644 --- a/src/core/journalling_object.cpp +++ b/src/core/journalling_object.cpp @@ -27,6 +27,8 @@ #include +#include + #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( 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() ); diff --git a/src/core/ladspa_control.cpp b/src/core/ladspa_control.cpp index bd64d5321..845b8043b 100644 --- a/src/core/ladspa_control.cpp +++ b/src/core/ladspa_control.cpp @@ -23,6 +23,7 @@ * */ +#include #include "ladspa_control.h" #include "ladspa_base.h" diff --git a/src/core/midi/midi_client.cpp b/src/core/midi/midi_client.cpp index e183c5202..129829249 100644 --- a/src/core/midi/midi_client.cpp +++ b/src/core/midi/midi_client.cpp @@ -26,8 +26,9 @@ */ +#include + #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; } diff --git a/src/core/peak_controller.cpp b/src/core/peak_controller.cpp index a9d7f1678..161d17c95 100644 --- a/src/core/peak_controller.cpp +++ b/src/core/peak_controller.cpp @@ -26,6 +26,7 @@ */ #include +#include #include #include #include diff --git a/src/gui/widgets/tempo_sync_knob.cpp b/src/gui/widgets/tempo_sync_knob.cpp index aa1af7fa1..f35f2dabe 100644 --- a/src/gui/widgets/tempo_sync_knob.cpp +++ b/src/gui/widgets/tempo_sync_knob.cpp @@ -26,6 +26,8 @@ */ +#include + #include "tempo_sync_knob.h" #include diff --git a/src/gui/widgets/visualization_widget.cpp b/src/gui/widgets/visualization_widget.cpp index ddf25104c..bb44ef431 100644 --- a/src/gui/widgets/visualization_widget.cpp +++ b/src/gui/widgets/visualization_widget.cpp @@ -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];