mirror of
https://github.com/LMMS/lmms.git
synced 2026-05-19 04:06:17 -04:00
@@ -42,6 +42,8 @@ class FxChannel : public ThreadableJob
|
||||
|
||||
EffectChain m_fxChain;
|
||||
|
||||
// set to true when input fed from mixToChannel or child channel
|
||||
bool m_hasInput;
|
||||
// set to true if any effect in the channel is enabled and running
|
||||
bool m_stillRunning;
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
FxChannel::FxChannel( int idx, Model * _parent ) :
|
||||
m_fxChain( NULL ),
|
||||
m_hasInput( false ),
|
||||
m_stillRunning( false ),
|
||||
m_peakLeft( 0.0f ),
|
||||
m_peakRight( 0.0f ),
|
||||
@@ -100,25 +101,38 @@ void FxChannel::doProcessing( sampleFrame * _buf )
|
||||
sender->process();
|
||||
}
|
||||
|
||||
// get the send level...
|
||||
const float amt =
|
||||
fxm->channelSendModel( senderIndex, m_channelIndex )->value();
|
||||
|
||||
// mix it's output with this one's output
|
||||
sampleFrame * ch_buf = sender->m_buffer;
|
||||
const float v = sender->m_volumeModel.value() * amt;
|
||||
for( f_cnt_t f = 0; f < fpp; ++f )
|
||||
if( sender->m_hasInput || sender->m_stillRunning )
|
||||
{
|
||||
_buf[f][0] += ch_buf[f][0] * v;
|
||||
_buf[f][1] += ch_buf[f][1] * v;
|
||||
// get the send level...
|
||||
const float amt =
|
||||
fxm->channelSendModel( senderIndex, m_channelIndex )->value();
|
||||
|
||||
// mix it's output with this one's output
|
||||
sampleFrame * ch_buf = sender->m_buffer;
|
||||
const float v = sender->m_volumeModel.value() * amt;
|
||||
for( f_cnt_t f = 0; f < fpp; ++f )
|
||||
{
|
||||
_buf[f][0] += ch_buf[f][0] * v;
|
||||
_buf[f][1] += ch_buf[f][1] * v;
|
||||
}
|
||||
}
|
||||
|
||||
// if sender channel hasInput, then we hasInput too
|
||||
if( sender->m_hasInput ) m_hasInput = true;
|
||||
}
|
||||
}
|
||||
|
||||
const float v = m_volumeModel.value();
|
||||
|
||||
m_fxChain.startRunning();
|
||||
m_stillRunning = m_fxChain.processAudioBuffer( _buf, fpp, true );
|
||||
if( m_hasInput )
|
||||
{
|
||||
// only start fxchain when we have input...
|
||||
m_fxChain.startRunning();
|
||||
}
|
||||
if( m_hasInput || m_stillRunning )
|
||||
{
|
||||
m_stillRunning = m_fxChain.processAudioBuffer( _buf, fpp, m_hasInput );
|
||||
}
|
||||
m_peakLeft = qMax( m_peakLeft, engine::mixer()->peakValueLeft( _buf, fpp ) * v );
|
||||
m_peakRight = qMax( m_peakRight, engine::mixer()->peakValueRight( _buf, fpp ) * v );
|
||||
}
|
||||
@@ -420,6 +434,7 @@ void FxMixer::mixToChannel( const sampleFrame * _buf, fx_ch_t _ch )
|
||||
{
|
||||
m_fxChannels[_ch]->m_lock.lock();
|
||||
MixHelpers::add( m_fxChannels[_ch]->m_buffer, _buf, engine::mixer()->framesPerPeriod() );
|
||||
m_fxChannels[_ch]->m_hasInput = true;
|
||||
m_fxChannels[_ch]->m_lock.unlock();
|
||||
}
|
||||
}
|
||||
@@ -486,6 +501,8 @@ void FxMixer::masterMix( sampleFrame * _buf )
|
||||
engine::mixer()->clearAudioBuffer( m_fxChannels[i]->m_buffer, engine::mixer()->framesPerPeriod() );
|
||||
m_fxChannels[i]->reset();
|
||||
m_fxChannels[i]->m_queued = false;
|
||||
// also reset hasInput
|
||||
m_fxChannels[i]->m_hasInput = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user