Merge pull request #997 from diizy/mixer-opt2

Improve performance of effect processing, fix autoquit bugs
This commit is contained in:
Vesa V
2014-07-17 02:01:53 +03:00
4 changed files with 22 additions and 21 deletions

View File

@@ -23,8 +23,8 @@
*
*/
#ifndef _EFFECT_H
#define _EFFECT_H
#ifndef EFFECT_H
#define EFFECT_H
#include "Plugin.h"
#include "engine.h"
@@ -118,8 +118,7 @@ public:
inline float gate() const
{
const float level = m_gateModel.value();
return level*level * m_processors *
engine::mixer()->framesPerPeriod();
return level*level * m_processors;
}
inline f_cnt_t bufferCount() const

View File

@@ -25,9 +25,6 @@
#include <QtXml/QDomElement>
#include <cstdio>
#include <cfloat>
#include "Effect.h"
#include "engine.h"
#include "EffectChain.h"
@@ -136,7 +133,7 @@ void Effect::checkGate( double _out_sum )
{
// Check whether we need to continue processing input. Restart the
// counter if the threshold has been exceeded.
if( _out_sum <= gate() + FLT_MIN )
if( _out_sum - gate() <= typeInfo<float>::minEps() )
{
incrementBufferCount();
if( bufferCount() > timeout() )
@@ -176,7 +173,7 @@ void Effect::reinitSRC()
libsrcInterpolation(),
DEFAULT_CHANNELS, &error ) ) == NULL )
{
fprintf( stderr, "Error: src_new() failed in effect.cpp!\n" );
qFatal( "Error: src_new() failed in effect.cpp!\n" );
}
}
}
@@ -202,7 +199,7 @@ void Effect::resample( int _i, const sampleFrame * _src_buf,
int error;
if( ( error = src_process( m_srcState[_i], &m_srcData[_i] ) ) )
{
fprintf( stderr, "Effect::resample(): error while resampling: %s\n",
qFatal( "Effect::resample(): error while resampling: %s\n",
src_strerror( error ) );
}
}

View File

@@ -137,9 +137,8 @@ void FxChannel::doProcessing( sampleFrame * _buf )
_buf[f][1] += ch_buf[f][1] * v;
}
}
// if sender channel hasInput, then we hasInput too
if( sender->m_hasInput ) m_hasInput = true;
if( sender->m_hasInput ) { m_hasInput = true; }
}
}
@@ -150,10 +149,9 @@ void FxChannel::doProcessing( sampleFrame * _buf )
// 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_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 );
}

View File

@@ -192,11 +192,18 @@ void NotePlayHandle::play( sampleFrame * _working_buffer )
{
if( m_scheduledNoteOff >= 0 ) // always trigger scheduled noteoffs, because they're only scheduled if the note is released
{
m_instrumentTrack->processOutEvent(
MidiEvent( MidiNoteOff, midiChannel(), midiKey(), 0 ),
MidiTime::fromFrames( m_scheduledNoteOff, engine::framesPerTick() ),
m_scheduledNoteOff );
m_scheduledNoteOff = -1;
if( m_scheduledNoteOff < engine::mixer()->framesPerPeriod() )
{
m_instrumentTrack->processOutEvent(
MidiEvent( MidiNoteOff, midiChannel(), midiKey(), 0 ),
MidiTime::fromFrames( m_scheduledNoteOff, engine::framesPerTick() ),
m_scheduledNoteOff );
m_scheduledNoteOff = -1;
}
else
{
m_scheduledNoteOff -= engine::mixer()->framesPerPeriod();
}
}
if( m_muted )