Deduplication of hiir coefs in effects
This commit is contained in:
parent
ff359df5cd
commit
25dd348191
10 changed files with 25 additions and 39 deletions
|
|
@ -20,6 +20,7 @@
|
|||
#include "Opcode.h"
|
||||
#include "AudioSpan.h"
|
||||
#include "MathHelpers.h"
|
||||
#include "OversamplerHelpers.h"
|
||||
#include "absl/memory/memory.h"
|
||||
|
||||
static constexpr int _oversampling = 2;
|
||||
|
|
@ -35,8 +36,8 @@ namespace fx {
|
|||
float _inputGain { Default::compGain };
|
||||
AudioBuffer<float, 2> _tempBuffer2x { 2, _oversampling * config::defaultSamplesPerBlock };
|
||||
AudioBuffer<float, 2> _gain2x { 2, _oversampling * config::defaultSamplesPerBlock };
|
||||
hiir::Downsampler2xFpu<12> _downsampler2x[EffectChannels];
|
||||
hiir::Upsampler2xFpu<12> _upsampler2x[EffectChannels];
|
||||
hiir::Downsampler2x<12> _downsampler2x[EffectChannels];
|
||||
hiir::Upsampler2x<12> _upsampler2x[EffectChannels];
|
||||
|
||||
#define DEFINE_SET_GET(type, ident, name, var, def, min, max, step) \
|
||||
float get_##ident(size_t i) const noexcept { return _compressor[i].var; } \
|
||||
|
|
@ -65,11 +66,9 @@ namespace fx {
|
|||
comp.instanceConstants(sampleRate);
|
||||
}
|
||||
|
||||
static constexpr double coefs2x[12] = { 0.036681502163648017, 0.13654762463195794, 0.27463175937945444, 0.42313861743656711, 0.56109869787919531, 0.67754004997416184, 0.76974183386322703, 0.83988962484963892, 0.89226081800387902, 0.9315419599631839, 0.96209454837808417, 0.98781637073289585 };
|
||||
|
||||
for (unsigned c = 0; c < EffectChannels; ++c) {
|
||||
impl._downsampler2x[c].set_coefs(coefs2x);
|
||||
impl._upsampler2x[c].set_coefs(coefs2x);
|
||||
impl._downsampler2x[c].set_coefs(OSCoeffs2x);
|
||||
impl._upsampler2x[c].set_coefs(OSCoeffs2x);
|
||||
}
|
||||
|
||||
clear();
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@
|
|||
|
||||
#pragma once
|
||||
#include "Effects.h"
|
||||
#include "hiir/Downsampler2xFpu.h"
|
||||
#include "hiir/Upsampler2xFpu.h"
|
||||
#include <memory>
|
||||
|
||||
namespace sfz {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#include "Opcode.h"
|
||||
#include "AudioSpan.h"
|
||||
#include "MathHelpers.h"
|
||||
#include "OversamplerHelpers.h"
|
||||
#include "absl/memory/memory.h"
|
||||
|
||||
static constexpr int _oversampling = 2;
|
||||
|
|
@ -38,8 +39,8 @@ namespace fx {
|
|||
float _inputGain = 1.0;
|
||||
AudioBuffer<float, 2> _tempBuffer2x { 2, _oversampling * config::defaultSamplesPerBlock };
|
||||
AudioBuffer<float, 2> _gain2x { 2, _oversampling * config::defaultSamplesPerBlock };
|
||||
hiir::Downsampler2xFpu<12> _downsampler2x[EffectChannels];
|
||||
hiir::Upsampler2xFpu<12> _upsampler2x[EffectChannels];
|
||||
hiir::Downsampler2x<12> _downsampler2x[EffectChannels];
|
||||
hiir::Upsampler2x<12> _upsampler2x[EffectChannels];
|
||||
|
||||
#define DEFINE_SET_GET(type, ident, name, var, def, min, max, step) \
|
||||
float get_##ident(size_t i) const noexcept { return _gate[i].var; } \
|
||||
|
|
@ -68,11 +69,9 @@ namespace fx {
|
|||
gate.instanceConstants(sampleRate);
|
||||
}
|
||||
|
||||
static constexpr double coefs2x[12] = { 0.036681502163648017, 0.13654762463195794, 0.27463175937945444, 0.42313861743656711, 0.56109869787919531, 0.67754004997416184, 0.76974183386322703, 0.83988962484963892, 0.89226081800387902, 0.9315419599631839, 0.96209454837808417, 0.98781637073289585 };
|
||||
|
||||
for (unsigned c = 0; c < EffectChannels; ++c) {
|
||||
impl._downsampler2x[c].set_coefs(coefs2x);
|
||||
impl._upsampler2x[c].set_coefs(coefs2x);
|
||||
impl._downsampler2x[c].set_coefs(OSCoeffs2x);
|
||||
impl._upsampler2x[c].set_coefs(OSCoeffs2x);
|
||||
}
|
||||
|
||||
clear();
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@
|
|||
|
||||
#pragma once
|
||||
#include "Effects.h"
|
||||
#include "hiir/Downsampler2xFpu.h"
|
||||
#include "hiir/Upsampler2xFpu.h"
|
||||
#include <memory>
|
||||
|
||||
namespace sfz {
|
||||
|
|
|
|||
|
|
@ -36,11 +36,9 @@ namespace fx {
|
|||
_limiter->classInit(sampleRate);
|
||||
_limiter->instanceConstants(sampleRate);
|
||||
|
||||
static constexpr double coefs2x[12] = { 0.036681502163648017, 0.13654762463195794, 0.27463175937945444, 0.42313861743656711, 0.56109869787919531, 0.67754004997416184, 0.76974183386322703, 0.83988962484963892, 0.89226081800387902, 0.9315419599631839, 0.96209454837808417, 0.98781637073289585 };
|
||||
|
||||
for (unsigned c = 0; c < EffectChannels; ++c) {
|
||||
_downsampler2x[c].set_coefs(coefs2x);
|
||||
_upsampler2x[c].set_coefs(coefs2x);
|
||||
_downsampler2x[c].set_coefs(OSCoeffs2x);
|
||||
_upsampler2x[c].set_coefs(OSCoeffs2x);
|
||||
}
|
||||
|
||||
clear();
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
#include "Effects.h"
|
||||
#include "hiir/Downsampler2xFpu.h"
|
||||
#include "hiir/Upsampler2xFpu.h"
|
||||
#include "OversamplerHelpers.h"
|
||||
class faustLimiter;
|
||||
|
||||
namespace sfz {
|
||||
|
|
@ -50,8 +49,8 @@ namespace fx {
|
|||
private:
|
||||
std::unique_ptr<faustLimiter> _limiter;
|
||||
AudioBuffer<float, 2> _tempBuffer2x { 2, 2 * config::defaultSamplesPerBlock };
|
||||
hiir::Downsampler2xFpu<12> _downsampler2x[EffectChannels];
|
||||
hiir::Upsampler2xFpu<12> _upsampler2x[EffectChannels];
|
||||
hiir::Downsampler2x<12> _downsampler2x[EffectChannels];
|
||||
hiir::Upsampler2x<12> _upsampler2x[EffectChannels];
|
||||
};
|
||||
|
||||
} // namespace fx
|
||||
|
|
|
|||
|
|
@ -101,8 +101,7 @@ namespace fx {
|
|||
{
|
||||
(void)sampleRate;
|
||||
|
||||
static constexpr double coefs2x[12] = { 0.036681502163648017, 0.13654762463195794, 0.27463175937945444, 0.42313861743656711, 0.56109869787919531, 0.67754004997416184, 0.76974183386322703, 0.83988962484963892, 0.89226081800387902, 0.9315419599631839, 0.96209454837808417, 0.98781637073289585 };
|
||||
fDownsampler2x.set_coefs(coefs2x);
|
||||
fDownsampler2x.set_coefs(OSCoeffs2x);
|
||||
}
|
||||
|
||||
void Lofi::Bitred::clear()
|
||||
|
|
@ -153,8 +152,7 @@ namespace fx {
|
|||
{
|
||||
fSampleTime = 1.0f / static_cast<float>(sampleRate);
|
||||
|
||||
static constexpr double coefs2x[12] = { 0.036681502163648017, 0.13654762463195794, 0.27463175937945444, 0.42313861743656711, 0.56109869787919531, 0.67754004997416184, 0.76974183386322703, 0.83988962484963892, 0.89226081800387902, 0.9315419599631839, 0.96209454837808417, 0.98781637073289585 };
|
||||
fDownsampler2x.set_coefs(coefs2x);
|
||||
fDownsampler2x.set_coefs(OSCoeffs2x);
|
||||
}
|
||||
|
||||
void Lofi::Decim::clear()
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
#include "Effects.h"
|
||||
#include "hiir/Downsampler2xFpu.h"
|
||||
#include "OversamplerHelpers.h"
|
||||
|
||||
namespace sfz {
|
||||
namespace fx {
|
||||
|
|
@ -57,7 +57,7 @@ namespace fx {
|
|||
private:
|
||||
float fDepth = 0.0;
|
||||
float fLastValue = 0.0;
|
||||
hiir::Downsampler2xFpu<12> fDownsampler2x;
|
||||
hiir::Downsampler2x<12> fDownsampler2x;
|
||||
};
|
||||
|
||||
///
|
||||
|
|
@ -73,7 +73,7 @@ namespace fx {
|
|||
float fDepth = 0.0;
|
||||
float fPhase = 0.0;
|
||||
float fLastValue = 0.0;
|
||||
hiir::Downsampler2xFpu<12> fDownsampler2x;
|
||||
hiir::Downsampler2x<12> fDownsampler2x;
|
||||
};
|
||||
|
||||
///
|
||||
|
|
|
|||
|
|
@ -28,11 +28,9 @@ namespace fx {
|
|||
{
|
||||
(void)sampleRate;
|
||||
|
||||
static constexpr double coefs2x[12] = { 0.036681502163648017, 0.13654762463195794, 0.27463175937945444, 0.42313861743656711, 0.56109869787919531, 0.67754004997416184, 0.76974183386322703, 0.83988962484963892, 0.89226081800387902, 0.9315419599631839, 0.96209454837808417, 0.98781637073289585 };
|
||||
|
||||
for (unsigned c = 0; c < EffectChannels; ++c) {
|
||||
_downsampler2x[c].set_coefs(coefs2x);
|
||||
_upsampler2x[c].set_coefs(coefs2x);
|
||||
_downsampler2x[c].set_coefs(OSCoeffs2x);
|
||||
_upsampler2x[c].set_coefs(OSCoeffs2x);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
#include "Effects.h"
|
||||
#include "hiir/Downsampler2xFpu.h"
|
||||
#include "hiir/Upsampler2xFpu.h"
|
||||
#include "OversamplerHelpers.h"
|
||||
|
||||
namespace sfz {
|
||||
namespace fx {
|
||||
|
|
@ -47,8 +46,8 @@ namespace fx {
|
|||
|
||||
private:
|
||||
AudioBuffer<float, 1> _tempBuffer { 1, config::defaultSamplesPerBlock };
|
||||
hiir::Downsampler2xFpu<12> _downsampler2x[2];
|
||||
hiir::Upsampler2xFpu<12> _upsampler2x[2];
|
||||
hiir::Downsampler2x<12> _downsampler2x[2];
|
||||
hiir::Upsampler2x<12> _upsampler2x[2];
|
||||
|
||||
float _amount = 0;
|
||||
bool _full = false;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue