0
mirror of https://github.com/torvalds/GuitarPedal.git synced 2026-08-14 12:44:08 +00:00
Files
Linus Torvalds 52032bfe45 Validation: run the pedal's audio core on the host
The effects have never been measured.  The plumbing around them has -
boot, link gain, ring latency, the MIDI parser - but nothing has ever
asked an effect what it does to a signal, and the only DSP ever executed
off-target is the FFT in test-fft.c.

bench/ closes that.  It builds audio/effect.h, effects/*.h and
single_sample() for the host and replaces the only two things the audio
core touches - the DMA read and write pointers, and the free-running
timer - with ordinary memory.  So what runs is the signal path rather
than a model of it, which matters more than it sounds: a harness that
re-implemented the middle of single_sample() would be a second opinion
about what the pedal does, and a second opinion is exactly what you
cannot check an effect against.

It needed no change to anything under Software/.  That is worth
recording as a fact about the architecture: apart from __not_in_flash()
in reverb.h, the effect headers have no hardware in them at all.

Measured on a transparent chain, the bench's own floor is a gain error
of -0.000265 dB and noise 144.7 dB down.  The gain error is the
firmware's, not the bench's - it is eps(1.0)/2 * 512, where a 1/512 slew
stalls against float32 rounding.

bench.py drives it.  The stimulus is 440 Hz because 48000/440 is 1200/11
exactly, so 12000 samples hold 110 whole cycles and every harmonic lands
on a bin with no leakage - and because 48000/440 is *not* an integer,
which is what lets aliased harmonics fall off the harmonic grid where
they can be told from honest distortion.  A frequency that divides the
sample rate hides its own aliasing inside its harmonic series.

--map asks a single function out of audio/util.h directly, with no audio
path around it, so the fast approximations can be characterised against
double precision instead of being inferred through an effect that is
already distorting.

Three targets:

  check-effects   the two controls that say whether the instrument
                  works - a transparent chain has to come out
                  transparent, and boost's fold(), which is sharp on
                  purpose, has to read as sharp.  Host only.

  check-bench     whether the bench agrees with a real pedal.  Test
                  tone into boost's wavefolder, captured over USB, so
                  the path is digital end to end and a disagreement is
                  a real one.  Every harmonic agrees to 0.00 dB and the
                  aliasing to 0.04 dB.

  check-analog    the other half: a patch cable from the output back to
                  the input, one board and one codec so there is no
                  second clock to chase.  The converter pair is a gain
                  constant to 0.001 dB over 58 dB of level, 1.08 ms of
                  delay, and a residual 84.9 dB down once those two are
                  removed.

All three skip rather than fail when what they need is not plugged in.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2026-08-10 08:44:48 -07:00
..