diff --git a/data/themes/default/auto_limit.png b/data/themes/default/auto_limit.png deleted file mode 100644 index 0cb627601..000000000 Binary files a/data/themes/default/auto_limit.png and /dev/null differ diff --git a/include/mixer.h b/include/mixer.h index 5661a97ae..2d291e3f3 100644 --- a/include/mixer.h +++ b/include/mixer.h @@ -47,7 +47,7 @@ class midiClient; class audioPort; -const fpp_t DEFAULT_BUFFER_SIZE = 512; +const fpp_t DEFAULT_BUFFER_SIZE = 256; const ch_cnt_t DEFAULT_CHANNELS = 2; @@ -286,8 +286,10 @@ public: const f_cnt_t _offset = 0 ); #endif - float peakValueLeft( surroundSampleFrame * _ab, const f_cnt_t _frames ); - float peakValueRight( surroundSampleFrame * _ab, const f_cnt_t _frames ); + static float peakValueLeft( surroundSampleFrame * _ab, + const f_cnt_t _frames ); + static float peakValueRight( surroundSampleFrame * _ab, + const f_cnt_t _frames ); bool criticalXRuns( void ) const; @@ -300,7 +302,6 @@ public: public slots: void setHighQuality( bool _hq_on = FALSE ); - void setClipScaling( bool _state ); signals: @@ -339,13 +340,11 @@ private: audioDevice * tryAudioDevices( void ); midiClient * tryMIDIClients( void ); - void processBuffer( const surroundSampleFrame * _buf, - const fx_ch_t _fx_chnl ); - - void FASTCALL scaleClip( fpp_t _frame, ch_cnt_t _chnl ); const surroundSampleFrame * renderNextBuffer( void ); + + QVector m_audioPorts; fpp_t m_framesPerPeriod; @@ -359,11 +358,9 @@ private: Uint8 m_analBuffer; Uint8 m_poolDepth; - bool m_scaleClip; surroundSampleFrame m_maxClip; surroundSampleFrame m_previousSample; fpp_t m_halfStart[SURROUND_CHANNELS]; - bool m_clipped[SURROUND_CHANNELS]; bool m_oldBuffer[SURROUND_CHANNELS]; bool m_newBuffer[SURROUND_CHANNELS]; diff --git a/src/core/mixer.cpp b/src/core/mixer.cpp index b98a4fb82..b324bcdd8 100644 --- a/src/core/mixer.cpp +++ b/src/core/mixer.cpp @@ -175,9 +175,8 @@ private: bool me = a->processEffects(); if( a->m_bufferUsage != audioPort::NoUsage || me ) { - m_mixer->processBuffer( - a->firstBuffer(), - a->nextFxChannel() ); + engine::getFxMixer()->mixToChannel( a->firstBuffer(), + a->nextFxChannel() ); a->nextPeriod(); } } @@ -260,7 +259,10 @@ mixer::mixer( void ) : } } - setClipScaling( FALSE ); + m_poolDepth = 2; + m_readBuffer = 0; + m_writeBuffer = 1; + m_analBuffer = 1; } @@ -329,49 +331,6 @@ bool mixer::criticalXRuns( void ) const -void mixer::setClipScaling( bool _state ) -{ - lock(); - - m_scaleClip = _state; - - if( _state ) - { - m_poolDepth = 3; - m_readBuffer = 0; - m_analBuffer = m_readBuffer + 1; - m_writeBuffer = m_poolDepth - 1; - - for( ch_cnt_t chnl=0; chnl < m_audioDev->channels(); ++chnl ) - { - m_clipped[chnl] = FALSE; - m_halfStart[chnl] = m_framesPerPeriod; - m_maxClip[chnl] = 1.0f; - m_previousSample[chnl] = 0.0; - m_newBuffer[chnl] = FALSE; - } - // FIXME: why assign buffer-ptr to m_readBuf just for calling - // another method? - // clearAudioBuffer(m_bufferPool[i],...) would do as well - for( Uint8 i = 0; i < 3; i++ ) - { - m_readBuf = m_bufferPool[i]; - clearAudioBuffer( m_readBuf, m_framesPerPeriod ); - } - } - else - { - m_poolDepth = 2; - m_readBuffer = 0; - m_writeBuffer = 1; - m_analBuffer = 1; - } - - unlock(); -} - - - #define FILL_JOB_QUEUE(_jq,_vec_type,_vec,_job_type,_condition) \ int id = 0; \ for( _vec_type::iterator it = _vec.begin(); \ @@ -594,15 +553,18 @@ if( COND_NPH ) else { bool more_effects = FALSE; - for( QVector::iterator it = m_audioPorts.begin(); + for( QVector::iterator it = + m_audioPorts.begin(); it != m_audioPorts.end(); ++it ) { more_effects = ( *it )->processEffects(); - if( ( *it )->m_bufferUsage != audioPort::NoUsage || + if( ( *it )->m_bufferUsage != + audioPort::NoUsage || more_effects ) { - processBuffer( ( *it )->firstBuffer(), - ( *it )->nextFxChannel() ); + engine::getFxMixer()->mixToChannel( + ( *it )->firstBuffer(), + ( *it )->nextFxChannel() ); ( *it )->nextPeriod(); } } @@ -1005,88 +967,6 @@ midiClient * mixer::tryMIDIClients( void ) -void mixer::processBuffer( const surroundSampleFrame * _buf, fx_ch_t _fx_chnl ) -{ - // TODO: process according effect-channel - -/* if( m_scaleClip ) - { - for( ch_cnt_t chnl=0; - chnl < m_audioDev->channels(); - ++chnl ) - { - m_newBuffer[chnl] = TRUE; - } - }*/ - engine::getFxMixer()->mixToChannel( _buf, _fx_chnl ); -} - - - - -void FASTCALL mixer::scaleClip( fpp_t _frame, ch_cnt_t _chnl ) -{ - // Check for zero crossing - if( ( m_writeBuf[_frame][_chnl] >=0 && - m_previousSample[_chnl] < 0 ) || - ( m_writeBuf[_frame][_chnl] <=0 && - m_previousSample[_chnl] > 0 ) ) - { - // if a clip occurred between the zero - // crossings, scale the half-wave - if( m_clipped[_chnl] ) - { - if( m_newBuffer[_chnl] ) - { - for( fpp_t i = m_halfStart[_chnl]; - i < m_framesPerPeriod; - i++ ) - { - m_bufferPool[m_analBuffer][i][_chnl] /= - m_maxClip[_chnl]; - } - - for( fpp_t i = 0; - i < _frame; - i++ ) - { - m_writeBuf[i][_chnl] /= - m_maxClip[_chnl]; - } - } - else - { - for( fpp_t i = m_halfStart[_chnl]; - i < _frame; - i++ ) - { - m_writeBuf[i][_chnl] /= m_maxClip[_chnl]; - } - } - } - m_halfStart[_chnl] = _frame; - m_clipped[_chnl] = FALSE; - m_newBuffer[_chnl] = FALSE; - m_maxClip[_chnl] = 1.0; - } - - // check for clip - if( fabsf( m_writeBuf[_frame][_chnl] ) > 1.0f ) - { - m_clipped[_chnl] = TRUE; - if( fabs( m_writeBuf[_frame][_chnl] ) > - m_maxClip[_chnl] ) - { - m_maxClip[_chnl] = fabs( - m_writeBuf[_frame][_chnl] ); - } - } - - m_previousSample[_chnl] = m_writeBuf[_frame][_chnl]; -} - - - diff --git a/src/core/song_editor.cpp b/src/core/song_editor.cpp index f9960ea98..02c7bc9ba 100644 --- a/src/core/song_editor.cpp +++ b/src/core/song_editor.cpp @@ -136,17 +136,6 @@ songEditor::songEditor( song * _song ) : engine::getMainWindow()->addWidgetToToolBar( hq_btn, 1, col ); - toolButton * cp_btn = new toolButton( - embed::getIconPixmap( "auto_limit" ), - tr( "Auto limiter" ), - NULL, NULL, tb ); - cp_btn->setCheckable( TRUE ); - connect( cp_btn, SIGNAL( toggled( bool ) ), engine::getMixer(), - SLOT( setClipScaling( bool ) ) ); - cp_btn->setFixedWidth( 30 ); - engine::getMainWindow()->addWidgetToToolBar( cp_btn, 1, col + 1 ); - - engine::getMainWindow()->addSpacingToToolBar( 10 ); connect( engine::getMixer(), SIGNAL( sampleRateChanged() ), this,