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"] [submodule "dsp"]
path = dsp path = dsp
url = https://signalsmith-audio.co.uk/code/dsp.git/ url = https://signalsmith-audio.co.uk/code/dsp.git

View File

@ -99,9 +99,25 @@ namespace signalsmith { namespace basics {
.unit("", 1); .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> template<class Config>
void configure(Config &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.auxInputs.resize(0);
config.auxOutputs.resize(0); config.auxOutputs.resize(0);
@ -135,6 +151,10 @@ namespace signalsmith { namespace basics {
return 0; return 0;
} }
int tailSamples() {
return std::round(sampleRate*rt20*3); // decay to -60dB
}
template<class Io, class Config, class Block> template<class Io, class Config, class Block>
void processSTFX(Io &io, Config &config, Block &block) { void processSTFX(Io &io, Config &config, Block &block) {
using Hadamard = signalsmith::mix::Hadamard<Sample, 8>; using Hadamard = signalsmith::mix::Hadamard<Sample, 8>;
@ -166,7 +186,7 @@ namespace signalsmith { namespace basics {
return g*0.35; // tuned by ear return g*0.35; // tuned by ear
}); });
updateFilters(config.sampleRate, decayGainTo); updateFilters(decayGainTo);
// Detuning LFO rate // Detuning LFO rate
double detuneCentsPerLoop = detune*std::sqrt(roomMs*0.001); double detuneCentsPerLoop = detune*std::sqrt(roomMs*0.001);
@ -177,7 +197,7 @@ namespace signalsmith { namespace basics {
Sample decayGain = smoothedDecayGain.at(i); Sample decayGain = smoothedDecayGain.at(i);
Sample earlyGain = smoothedEarlyGain.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; Array samples;
std::array<Sample, 2> stereoInScaled = {stereoIn[0]*inputGain, stereoIn[1]*inputGain}; 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); double lfoCos = std::cos(detuneLfoPhase*2*M_PI), lfoSin = std::sin(detuneLfoPhase*2*M_PI);
Array3 lfoArray = { Array3 lfoArray = {
(0.5 + lfoCos*0.5)*detuneDepthSamples, Sample((0.5 + lfoCos*0.5)*detuneDepthSamples),
(0.5 + lfoCos*-0.25 + lfoSin*0.43301270189)*detuneDepthSamples, Sample((0.5 + lfoCos*-0.25 + lfoSin*0.43301270189)*detuneDepthSamples),
(0.5 + lfoCos*-0.25 + lfoSin*-0.43301270189)*detuneDepthSamples Sample((0.5 + lfoCos*-0.25 + lfoSin*-0.43301270189)*detuneDepthSamples)
}; };
detuneLfoPhase += detuneLfoRate; detuneLfoPhase += detuneLfoRate;
@ -262,6 +282,7 @@ namespace signalsmith { namespace basics {
private: private:
int channels = 0; int channels = 0;
double sampleRate = 1;
double maxRoomMs, detuneDepthMs; double maxRoomMs, detuneDepthMs;
double detuneLfoPhase = 0; double detuneLfoPhase = 0;
double detuneDepthSamples = 0; double detuneDepthSamples = 0;
@ -270,7 +291,7 @@ namespace signalsmith { namespace basics {
std::array<Filter, 2> lowCutFilters, highCutFilters; std::array<Filter, 2> lowCutFilters, highCutFilters;
std::array<Filter, 8> lowDampFilters, highDampFilters; 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 : lowCutFilters) f.highpassQ(lowCutHz/sampleRate, 0.5);
for (auto &f : highCutFilters) f.lowpassQ(highCutHz/sampleRate, 0.5); for (auto &f : highCutFilters) f.lowpassQ(highCutHz/sampleRate, 0.5);

View File

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