0
mirror of https://github.com/torvalds/GuitarPedal.git synced 2026-06-07 04:55:36 +00:00
Files
Linus Torvalds c88f369fd3 Fix up lots more default pot settings
Bah.  It wasn't just the echo that had gotten messed up in the
conversion to the new and more legible pot metadata.

The *new* metadata defaults are pretty clear and obvious, but the old
ones were not, and I clearly should have been a whole lot more careful
in converting them, because half the effects had various messed up
default values.  Lots of "zero meant pot at noon - so float value 0.5"
turned into just plain "zero means zero".

So I do think the new model is a lot better, but "Mistakes were made".

I tried to go through every effect and double-check it against what it
used to be.  Not that all the old defaults were sane (I'm looking at
you, boost effect), but the metadata conversion wasn't meant to change
them.

Fixes: 9c208692f7 ("Convert effects to metadata-driven boiler plate generation")
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2026-06-01 08:34:11 -07:00

37 lines
1.1 KiB
C

// NAME: Flanger [FLNGR]
// PRIORITY: 60
// POT: "Freq" SQUARED(0.0 10.0) = 2.5 Hz
// POT: "Delay" LINEAR(0.0 4.0) = 2.0 ms
// POT: "Depth" LINEAR(0.0 1.0) = 0.5
// POT: "Feedback" LINEAR(0.0 1.0) = 0.5
// Flanger effect based on the MIT-licensed DaisySP library by Electrosmith
// which in turn seems to be based on Soundpipe by Paul Batchelor
static struct {
struct lfo_state lfo;
float delay, depth, feedback;
// Large enough history buffer for 10ms
unsigned int idx;
float samples[1024];
} flanger;
static inline void flanger_init(unsigned char pot[10])
{
set_lfo_freq(&flanger.lfo, flanger_pot0(pot[0]));
flanger.delay = flanger_pot1(pot[1]) * SAMPLES_PER_MSEC;
flanger.depth = flanger_pot2(pot[2]);
flanger.feedback = flanger_pot3(pot[3]);
}
static inline float flanger_step(float in)
{
float d = 1 + flanger.delay * (1 + lfo_step(&flanger.lfo, lfo_sinewave) * flanger.depth);
float out;
out = sample_array_read(d, &flanger.idx, flanger.samples);
sample_array_write(tanhf(in + out * flanger.feedback), &flanger.idx, flanger.samples);
return (in + out) / 2;
}