From 28dc1deaa67f6a2380b17431e6a2ef06a445c1ee Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sat, 9 Dec 2023 17:28:35 -0800 Subject: modules/mixer: introduce bottom= setting This adds a bottom={a,b} setting when style={interlace,paintroller,sine} Note this only introduces the settings, not the implementation. The impetus for this is when experimenting with mixer transitions in a work-in-progress, you'll sometimes want to invert the bottom vs. top layers just to see how that looks. Instead of having to transpose the a_module<->b_module setting values, this provides a separate setting achieving that, which will simply be ignored for the irrelevant mixer styles. Conceptually "bottom" vs. "top" doesn't really apply to all the styles however. style=interlace already feels a bit forced to include here, but in the code it's clearly part of a group with paintroller and sine, so it's included here. But one could argue that *all* styles should have some kind of toggle to swap a_module<->b_module. Except there will probably be another setting introduced to invert T as well, which would effectively achieve that for the modules where "bottom" vs. "top" doesn't conceptually fit. --- src/modules/mixer/mixer.c | 56 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 5 deletions(-) diff --git a/src/modules/mixer/mixer.c b/src/modules/mixer/mixer.c index 0843ac2..ccd17a4 100644 --- a/src/modules/mixer/mixer.c +++ b/src/modules/mixer/mixer.c @@ -35,6 +35,11 @@ typedef enum mixer_orientation_t { MIXER_ORIENTATION_VERTICAL, } mixer_orientation_t; +typedef enum mixer_bottom_t { + MIXER_BOTTOM_A, + MIXER_BOTTOM_B, +} mixer_bottom_t; + typedef struct mixer_input_t { til_module_context_t *module_ctxt; /* XXX: it's expected that inputs will get more settable attributes to stick in here */ @@ -73,12 +78,14 @@ typedef struct mixer_setup_t { mixer_style_t style; mixer_setup_input_t inputs[2]; mixer_orientation_t orientation; + mixer_bottom_t bottom; unsigned n_passes; } mixer_setup_t; #define MIXER_DEFAULT_STYLE MIXER_STYLE_BLEND #define MIXER_DEFAULT_PASSES 8 #define MIXER_DEFAULT_ORIENTATION MIXER_ORIENTATION_VERTICAL +#define MIXER_DEFAULT_BOTTOM MIXER_BOTTOM_A static void mixer_update_taps(mixer_context_t *ctxt, til_stream_t *stream, unsigned ticks) { @@ -570,9 +577,15 @@ static int mixer_setup(const til_settings_t *settings, til_setting_t **res_setti "vertical", NULL }; + const char *bottom_values[] = { + "a", + "b", + NULL + }; til_setting_t *style; til_setting_t *passes; til_setting_t *orientation; + til_setting_t *bottom; const til_settings_t *inputs_settings[2]; til_setting_t *inputs[2]; int r; @@ -583,7 +596,6 @@ static int mixer_setup(const til_settings_t *settings, til_setting_t **res_setti .key = "style", .values = style_values, .preferred = style_values[MIXER_DEFAULT_STYLE], - .annotations = NULL }, &style, res_setting, @@ -591,6 +603,31 @@ static int mixer_setup(const til_settings_t *settings, til_setting_t **res_setti if (r) return r; + /* Though you can simply swap what you provide as a_module and b_module, it's + * convenient to have a discrete setting available for specifying which one + * goes on the bottom and which one goes on top as well. Sometimes you're just + * exploring mixer styles, and only for some is the "bottom" vs "top" + * relevant, and the preference can be style-specific, so just give an + * independent easy toggle. + */ + if (!strcasecmp(style->value, style_values[MIXER_STYLE_INTERLACE]) || + !strcasecmp(style->value, style_values[MIXER_STYLE_PAINTROLLER]) || + !strcasecmp(style->value, style_values[MIXER_STYLE_SINE])) { + + r = til_settings_get_and_describe_setting(settings, + &(til_setting_spec_t){ + .name = "Mixer bottom layer", + .key = "bottom", + .values = bottom_values, + .preferred = bottom_values[MIXER_DEFAULT_BOTTOM], + }, + &bottom, + res_setting, + res_desc); + if (r) + return r; + } + if (!strcasecmp(style->value, style_values[MIXER_STYLE_PAINTROLLER])) { r = til_settings_get_and_describe_setting(settings, @@ -599,7 +636,6 @@ static int mixer_setup(const til_settings_t *settings, til_setting_t **res_setti .key = "orientation", .values = orientation_values, .preferred = orientation_values[MIXER_DEFAULT_ORIENTATION], - .annotations = NULL }, &orientation, res_setting, @@ -613,7 +649,6 @@ static int mixer_setup(const til_settings_t *settings, til_setting_t **res_setti .key = "passes", .values = passes_values, .preferred = TIL_SETTINGS_STR(MIXER_DEFAULT_PASSES), - .annotations = NULL }, &passes, res_setting, @@ -664,14 +699,25 @@ static int mixer_setup(const til_settings_t *settings, til_setting_t **res_setti if (r < 0) return til_setup_free_with_failed_setting_ret_err(&setup->til_setup, style, res_setting, -EINVAL); - if (setup->style == MIXER_STYLE_PAINTROLLER) { - + switch (setup->style) { /* bake any style-specific settings */ + case MIXER_STYLE_PAINTROLLER: if (sscanf(passes->value, "%u", &setup->n_passes) != 1) return til_setup_free_with_failed_setting_ret_err(&setup->til_setup, passes, res_setting, -EINVAL); r = til_value_to_pos(orientation_values, orientation->value, (unsigned *)&setup->orientation); if (r < 0) return til_setup_free_with_failed_setting_ret_err(&setup->til_setup, orientation, res_setting, -EINVAL); + /* fallthrough */ + case MIXER_STYLE_INTERLACE: + /* fallthrough */ + case MIXER_STYLE_SINE: + r = til_value_to_pos(bottom_values, bottom->value, (unsigned *)&setup->bottom); + if (r < 0) + return til_setup_free_with_failed_setting_ret_err(&setup->til_setup, bottom, res_setting, -EINVAL); + break; + + default: + break; } for (i = 0; i < 2; i++) { -- cgit v1.2.1