0
mirror of https://github.com/torvalds/GuitarPedal.git synced 2026-06-06 04:51:54 +00:00
Files
Linus Torvalds 9c208692f7 Convert effects to metadata-driven boiler plate generation
This is the actual effect format update mentioned in the previous
commit: express the boiler plate details in the comment at the top of
the effect so that it can be auto-generated.

Part of that is that now the default values can be much more sanely
expressed: instead of setting the defaults as the particular integer
values the pot takes, express them in the user-visible units.

So the default noise gate level value can now be described as

    // POT: "Level" LINEAR(-100.0 -40.0) = -70.0 dB

instead of the inscrutable

    EFFECT_POT("Level", desc_dB, gate_pot0_level, 0),   // -70dB

where the default value of 0 ended up indeed being -70dB, but we had to
have a comment to that effect because it was so non-obvious (it came
from the fact that gate_pot0_level() did a linear interpolation between
-100 and -40, and -70 is the middle value).

So now the pot values make a lot more sense and defaults are easier to
see and set.

This also means that instead of having the pot values be -60 to +60 (in
order to make the default "noon" be zero and needing no initializer),
since we auto-generate the defaults we can make the actual internal
values be the more straightforward 0..120 range - not only matching what
we did for MIDI, but also simplifying a lot of the helper math cases.

As a result, the pot arrays are now done as 'unsigned char'.

While doing all this, I also noticed that the ->describe() function is
just entirely historical: it used to depend on the pot value for when
the enumerations were done as a separate hack.  But these days
enumeration pots are an integral part of the pot description, and the
->describe() functions were all just returning the unit string.

So get rid of the function pointer indirection, and just make it have a
simple and straightforward 'const char *unit' string.

This all makes the 'gen_effect' python script a bit bigger, but that is
more than made up for by the boiler plate removal in the effects
themselves, so not only does it make things clearer, this all removes
more lines than it adds.

And equally importantly, it means that now the Web UI actually can
convert the raw pot values into sensible units, because it too can take
the pot descriptions into account.  Some other minor UI updates while at
it.

All the python and JS scripting itself was obviously all done by AI.
Some day I might care enough to learn to actually write python, but for
now I'm perfectly happy just reading the end result.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2026-05-31 13:39:35 -07:00
..
2026-05-13 14:32:42 -07:00
2026-05-13 14:32:42 -07:00
2026-05-13 14:32:42 -07:00
2026-05-13 14:32:42 -07:00