FxMixer, ValueBuffer, etc. fixes
This commit is contained in:
@@ -22,8 +22,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _FX_MIXER_H
|
||||
#define _FX_MIXER_H
|
||||
#ifndef FX_MIXER_H
|
||||
#define FX_MIXER_H
|
||||
|
||||
#include "Model.h"
|
||||
#include "Mixer.h"
|
||||
|
||||
@@ -22,11 +22,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _MIX_HELPERS_H
|
||||
#define _MIX_HELPERS_H
|
||||
#ifndef MIX_HELPERS_H
|
||||
#define MIX_HELPERS_H
|
||||
|
||||
#include "lmms_basics.h"
|
||||
|
||||
class ValueBuffer;
|
||||
namespace MixHelpers
|
||||
{
|
||||
|
||||
@@ -39,6 +40,12 @@ void add( sampleFrame* dst, const sampleFrame* src, int frames );
|
||||
/*! \brief Add samples from src multiplied by coeffSrc to dst */
|
||||
void addMultiplied( sampleFrame* dst, const sampleFrame* src, float coeffSrc, int frames );
|
||||
|
||||
/*! \brief Add samples from src multiplied by coeffSrc and coeffSrcBuf to dst */
|
||||
void addMultipliedByBuffer( sampleFrame* dst, const sampleFrame* src, float coeffSrc, ValueBuffer * coeffSrcBuf, int frames );
|
||||
|
||||
/*! \brief Add samples from src multiplied by coeffSrc and coeffSrcBuf to dst */
|
||||
void addMultipliedByBuffers( sampleFrame* dst, const sampleFrame* src, ValueBuffer * coeffSrcBuf1, ValueBuffer * coeffSrcBuf2, int frames );
|
||||
|
||||
|
||||
/*! \brief Add samples from src multiplied by coeffSrcLeft/coeffSrcRight to dst */
|
||||
void addMultipliedStereo( sampleFrame* dst, const sampleFrame* src, float coeffSrcLeft, float coeffSrcRight, int frames );
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#ifndef VALUE_BUFFER_H
|
||||
#define VALUE_BUFFER_H
|
||||
|
||||
#include <QtGlobal>
|
||||
#include "interpolation.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@@ -115,10 +115,10 @@ bool AmplifierEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames )
|
||||
: m_ampControls.m_panModel.value();
|
||||
const float left1 = pan <= 0
|
||||
? 1.0
|
||||
: 1.0 - m_ampControls.m_panModel.value( f ) * 0.01f;
|
||||
: 1.0 - pan * 0.01f;
|
||||
const float right1 = pan >= 0
|
||||
? 1.0
|
||||
: 1.0 + m_ampControls.m_panModel.value( ) * 0.01f;
|
||||
: 1.0 + pan * 0.01f;
|
||||
|
||||
// second stage amplification
|
||||
const float left2 = leftBuf
|
||||
|
||||
@@ -79,7 +79,7 @@ void FxChannel::doProcessing( sampleFrame * _buf )
|
||||
|
||||
// SMF: OK, due to the fact, that the data from the audio-tracks has been
|
||||
// written into our buffer already, all which needs to be done at this
|
||||
// stage is to process inter-channel sends.
|
||||
// stage is to process inter-channel sends.
|
||||
|
||||
if( m_muteModel.value() == false )
|
||||
{
|
||||
@@ -110,45 +110,29 @@ void FxChannel::doProcessing( sampleFrame * _buf )
|
||||
|
||||
// mix it's output with this one's output
|
||||
sampleFrame * ch_buf = sender->m_buffer;
|
||||
|
||||
// use sample-exact mixing if sample-exact values are available
|
||||
|
||||
// use sample-exact mixing if sample-exact values are available
|
||||
if( ! volBuf && ! sendBuf ) // neither volume nor send has sample-exact data...
|
||||
{
|
||||
const float v = sender->m_volumeModel.value() * fxm->channelSendModel( senderIndex, m_channelIndex )->value();
|
||||
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;
|
||||
}
|
||||
MixHelpers::addMultiplied( _buf, ch_buf, v, fpp );
|
||||
}
|
||||
else if( volBuf && sendBuf ) // both volume and send have sample-exact data
|
||||
{
|
||||
for( f_cnt_t f = 0; f < fpp; ++f )
|
||||
{
|
||||
_buf[f][0] += ch_buf[f][0] * sendBuf->values()[f] * volBuf->values()[f];
|
||||
_buf[f][1] += ch_buf[f][1] * sendBuf->values()[f] * volBuf->values()[f];
|
||||
}
|
||||
MixHelpers::addMultipliedByBuffers( _buf, ch_buf, volBuf, sendBuf, fpp );
|
||||
}
|
||||
else if( volBuf ) // volume has sample-exact data but send does not
|
||||
{
|
||||
const float v = fxm->channelSendModel( senderIndex, m_channelIndex )->value();
|
||||
for( f_cnt_t f = 0; f < fpp; ++f )
|
||||
{
|
||||
_buf[f][0] += ch_buf[f][0] * v * volBuf->values()[f];
|
||||
_buf[f][1] += ch_buf[f][1] * v * volBuf->values()[f];
|
||||
}
|
||||
MixHelpers::addMultipliedByBuffer( _buf, ch_buf, v, volBuf, fpp );
|
||||
}
|
||||
else // vice versa
|
||||
{
|
||||
const float v = sender->m_volumeModel.value();
|
||||
for( f_cnt_t f = 0; f < fpp; ++f )
|
||||
{
|
||||
_buf[f][0] += ch_buf[f][0] * sendBuf->values()[f] * v;
|
||||
_buf[f][1] += ch_buf[f][1] * sendBuf->values()[f] * v;
|
||||
}
|
||||
MixHelpers::addMultipliedByBuffer( _buf, ch_buf, v, sendBuf, fpp );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if sender channel hasInput, then we hasInput too
|
||||
if( sender->m_hasInput ) m_hasInput = true;
|
||||
}
|
||||
@@ -156,10 +140,10 @@ void FxChannel::doProcessing( sampleFrame * _buf )
|
||||
|
||||
const float v = m_volumeModel.value();
|
||||
|
||||
if( m_hasInput )
|
||||
if( m_hasInput )
|
||||
{
|
||||
// only start fxchain when we have input...
|
||||
m_fxChain.startRunning();
|
||||
m_fxChain.startRunning();
|
||||
}
|
||||
if( m_hasInput || m_stillRunning )
|
||||
{
|
||||
@@ -533,7 +517,7 @@ void FxMixer::masterMix( sampleFrame * _buf )
|
||||
m_fxChannels[0]->m_buffer[f][1] *= volBuf->values()[f];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const float v = volBuf
|
||||
? 1.0f
|
||||
: m_fxChannels[0]->m_volumeModel.value();
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "MixHelpers.h"
|
||||
#include "ValueBuffer.h"
|
||||
|
||||
|
||||
namespace MixHelpers
|
||||
@@ -105,6 +106,25 @@ void addMultiplied( sampleFrame* dst, const sampleFrame* src, float coeffSrc, in
|
||||
}
|
||||
|
||||
|
||||
void addMultipliedByBuffer( sampleFrame* dst, const sampleFrame* src, float coeffSrc, ValueBuffer * coeffSrcBuf, int frames )
|
||||
{
|
||||
for( int f = 0; f < frames; ++f )
|
||||
{
|
||||
dst[f][0] += src[f][0] * coeffSrc * coeffSrcBuf->values()[f];
|
||||
dst[f][1] += src[f][1] * coeffSrc * coeffSrcBuf->values()[f];
|
||||
}
|
||||
}
|
||||
|
||||
void addMultipliedByBuffers( sampleFrame* dst, const sampleFrame* src, ValueBuffer * coeffSrcBuf1, ValueBuffer * coeffSrcBuf2, int frames )
|
||||
{
|
||||
for( int f = 0; f < frames; ++f )
|
||||
{
|
||||
dst[f][0] += src[f][0] * coeffSrcBuf1->values()[f] * coeffSrcBuf2->values()[f];
|
||||
dst[f][1] += src[f][1] * coeffSrcBuf1->values()[f] * coeffSrcBuf2->values()[f];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
struct AddMultipliedStereoOp
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user