You've already forked ivan-torvalds-GuitarPedal
forked from AllSpiceMirrors/torvalds-GuitarPedal
The attention brightness setting stopped doing anything visible when the second LED went away. It had been shown by settings_effect.intense = settings_effect.active_pot == 4; which lit LED2 while you were sitting on that pot - and LED2 does not exist any more. So the one setting whose whole purpose is to change how the LED looks became the one setting you could not see yourself change. While fixing that, deal with the other two users of the same brightness, because there are exactly three and they had never been written down together: - the output hitting full scale - the audio core missing its DMA deadline - now, previewing the attention setting itself Keep all three sharing the LED, on purpose. With one bit of light there is no way to spell out which it is, but the two failures sound completely different and the ear does the work: clipping follows how hard you play and may well be something you want, while sample loss means too many effects are stacked up and everything has gone to mush and stays there. "Something is wrong, listen" is the part worth signalling. What was actually wrong was the *internal* conflation, and that goes: missing a deadline used to set the clipping flag, so the pedal told the world it was clipping when the signal had been nowhere near full scale, and you went looking for a level problem. Now 'samples_dropped' is only a count and 'output_clipped' is only clipping, which also means MIDI_CC_AUDIO_CLIPPING finally means what it says. A smart LED will have colours to spend and can start telling them apart for real. The timing gets written down while here, because it reads like an accident and is not. These flags are set on the audio core at 48kHz and cleared by update_ui() at about 25Hz, and that asymmetry is the whole mechanism. A clipped sample lasts twenty microseconds, which no eye will catch; holding the flag until the next UI tick stretches it to 40ms, which is about the shortest thing worth showing a human. And it does the averaging for free - clip one sample in a hundred and the LED stays solidly lit, because the audio core sets the flag far faster than the UI clears it, so "once in a while" and "all the time" look different without counting or filtering anything. Both properties disappear if this is ever moved to a faster loop. The preview holds for half a second rather than the single 40ms tick a change would otherwise get, so a nudge from the web app is visible and not just theoretically visible. The three live in status.h, which is what they are and which only this translation unit includes - types.h is also pulled in by the USB code, where they would be nothing but unused-variable warnings. They are named for what they hold and share one type, rather than being 'clipping' and 'dropped' and disagreeing about signedness for no reason. Settings pots get names while here. pot[4] was the attention level and pot[5] the tuning, and neither said so. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
76 lines
2.1 KiB
C
76 lines
2.1 KiB
C
// NAME: Settings [SETTINGS]
|
|
// PRIORITY: 130
|
|
// POT: "USB L/R Out" ENUM(None Wet Dry Wet/Dry) = Dry
|
|
// POT: "USB L/R In" ENUM(Off Pre-FX Mix) = Off
|
|
// POT: "MIDI Ch" ENUM(Omni Ch1 Ch2 Ch3 Ch4 Ch5 Ch6 Ch7 Ch8 Ch9 Ch10 Ch11 Ch12 Ch13 Ch14 Ch15 Ch16) = Omni
|
|
// POT: "LED" LINEAR(0 100) = 10 %
|
|
// POT: " ATTN" LINEAR(0 100) = 50 %
|
|
// POT: "Tuning" ENUM(EADGBE DADGAD BEADGC EADG) = EADGBE
|
|
//
|
|
// Settings "effect" - dummy effect to save various settings
|
|
//
|
|
enum usb_output {
|
|
LR_None, LR_Wet, LR_Dry, LR_WetDry,
|
|
};
|
|
|
|
enum usb_input {
|
|
USB_IN_OFF, USB_IN_PRE_FX, USB_IN_MIX
|
|
};
|
|
|
|
struct {
|
|
enum usb_output usb_output;
|
|
enum usb_input usb_input;
|
|
int midi_channel;
|
|
float led_pwm, led_intense;
|
|
int tuning;
|
|
} settings;
|
|
|
|
//
|
|
// Which pot is which. These have to stay in step with the POT lines
|
|
// at the top of this file - that is the order gen_effects.py assigns.
|
|
//
|
|
enum settings_pot {
|
|
SETTINGS_USB_OUT,
|
|
SETTINGS_USB_IN,
|
|
SETTINGS_MIDI_CH,
|
|
SETTINGS_LED,
|
|
SETTINGS_ATTN,
|
|
SETTINGS_TUNING,
|
|
};
|
|
|
|
static void settings_init(unsigned char pot[10])
|
|
{
|
|
settings.usb_output = pot[SETTINGS_USB_OUT];
|
|
settings.usb_input = pot[SETTINGS_USB_IN];
|
|
settings.midi_channel = pot[SETTINGS_MIDI_CH];
|
|
|
|
settings.led_pwm = settings_pot3(pot[SETTINGS_LED]) / 100;
|
|
|
|
//
|
|
// The attention brightness is the one setting whose effect you
|
|
// cannot see while you are setting it, because the only thing
|
|
// that can show it is the LED going into that mode. So ask it
|
|
// to, for half a second, whenever the setting moves - or for as
|
|
// long as this is the pot being edited from the pedal itself,
|
|
// where you are looking at the LED and not at a browser.
|
|
//
|
|
// This is also what the second LED used to do, back when there
|
|
// was one to do it with.
|
|
//
|
|
float intense = settings_pot4(pot[SETTINGS_ATTN]) / 100;
|
|
if (intense != settings.led_intense ||
|
|
settings_effect.active_pot == SETTINGS_ATTN)
|
|
attention_preview = ATTENTION_PREVIEW_TICKS;
|
|
settings.led_intense = intense;
|
|
|
|
// Hacky hacky
|
|
settings_effect.target = EFF_ENABLE_STEPS;
|
|
|
|
settings.tuning = pot[SETTINGS_TUNING];
|
|
}
|
|
|
|
static inline float settings_step(float in)
|
|
{
|
|
return in;
|
|
}
|