1
0

Increase float compatibility, update DSP library

This commit is contained in:
Geraint 2022-12-06 18:00:16 +00:00
parent a5c32ecaf8
commit e38dada1d7
3 changed files with 37 additions and 10 deletions

2
.gitmodules vendored
View File

@ -1,3 +1,3 @@
[submodule "dsp"]
path = dsp
url = https://signalsmith-audio.co.uk/code/dsp.git/
url = https://signalsmith-audio.co.uk/code/dsp.git

View File

@ -98,10 +98,26 @@ namespace signalsmith { namespace basics {
.range(1, 2, 10)
.unit("", 1);
}
template<class Preset>
void presets(Preset &preset) {
if (preset("ambient")) {
wet = 0.85;
roomMs = 80;
rt20 = 11.5;
early = 0.55;
detune = 8.5;
lowCutHz = 50;
lowDampRate = 1.5;
highCutHz = 7200;
highDampRate = 2;
}
}
template<class Config>
void configure(Config &config) {
config.outputChannels = config.inputChannels = 2;
sampleRate = config.sampleRate;
config.outputChannels = config.inputChannels = 2; // stereo effect only
config.auxInputs.resize(0);
config.auxOutputs.resize(0);
@ -134,7 +150,11 @@ namespace signalsmith { namespace basics {
int latencySamples() const {
return 0;
}
int tailSamples() {
return std::round(sampleRate*rt20*3); // decay to -60dB
}
template<class Io, class Config, class Block>
void processSTFX(Io &io, Config &config, Block &block) {
using Hadamard = signalsmith::mix::Hadamard<Sample, 8>;
@ -166,7 +186,7 @@ namespace signalsmith { namespace basics {
return g*0.35; // tuned by ear
});
updateFilters(config.sampleRate, decayGainTo);
updateFilters(decayGainTo);
// Detuning LFO rate
double detuneCentsPerLoop = detune*std::sqrt(roomMs*0.001);
@ -177,7 +197,7 @@ namespace signalsmith { namespace basics {
Sample decayGain = smoothedDecayGain.at(i);
Sample earlyGain = smoothedEarlyGain.at(i);
std::array<Sample, 2> stereoIn = {inputLeft[i], inputRight[i]};
std::array<Sample, 2> stereoIn = {Sample(inputLeft[i]), Sample(inputRight[i])};
Array samples;
std::array<Sample, 2> stereoInScaled = {stereoIn[0]*inputGain, stereoIn[1]*inputGain};
@ -185,9 +205,9 @@ namespace signalsmith { namespace basics {
double lfoCos = std::cos(detuneLfoPhase*2*M_PI), lfoSin = std::sin(detuneLfoPhase*2*M_PI);
Array3 lfoArray = {
(0.5 + lfoCos*0.5)*detuneDepthSamples,
(0.5 + lfoCos*-0.25 + lfoSin*0.43301270189)*detuneDepthSamples,
(0.5 + lfoCos*-0.25 + lfoSin*-0.43301270189)*detuneDepthSamples
Sample((0.5 + lfoCos*0.5)*detuneDepthSamples),
Sample((0.5 + lfoCos*-0.25 + lfoSin*0.43301270189)*detuneDepthSamples),
Sample((0.5 + lfoCos*-0.25 + lfoSin*-0.43301270189)*detuneDepthSamples)
};
detuneLfoPhase += detuneLfoRate;
@ -262,6 +282,7 @@ namespace signalsmith { namespace basics {
private:
int channels = 0;
double sampleRate = 1;
double maxRoomMs, detuneDepthMs;
double detuneLfoPhase = 0;
double detuneDepthSamples = 0;
@ -270,7 +291,7 @@ namespace signalsmith { namespace basics {
std::array<Filter, 2> lowCutFilters, highCutFilters;
std::array<Filter, 8> lowDampFilters, highDampFilters;
void updateFilters(Sample sampleRate, Sample feedbackGain) {
void updateFilters(double feedbackGain) {
for (auto &f : lowCutFilters) f.highpassQ(lowCutHz/sampleRate, 0.5);
for (auto &f : highCutFilters) f.lowpassQ(highCutHz/sampleRate, 0.5);

View File

@ -238,9 +238,15 @@ namespace stfx {
double paramFadeMs() {
return 20;
}
int latencySamples() {
return 0;
}
int tailSamples() {
return 0;
}
template<class Presets>
void presets(Presets &) {}
};
/// Creates an effect class from an effect template, with optional extra config.