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