From 8178bd298b5e092bfc33be17a32e67bc8cb09a11 Mon Sep 17 00:00:00 2001 From: "Geoffrey D. Bennett" Date: Thu, 20 Feb 2025 23:02:44 +1030 Subject: [PATCH] Gen 1: Add support for 1st Gen input controls --- src/alsa-scarlett-gui.css | 4 ++++ src/iface-mixer.c | 43 ++++++++++++++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/src/alsa-scarlett-gui.css b/src/alsa-scarlett-gui.css index 86dd6f2..c02ed64 100644 --- a/src/alsa-scarlett-gui.css +++ b/src/alsa-scarlett-gui.css @@ -210,6 +210,10 @@ button.toggle { text-shadow: 0 0 5px #00c000, 0 0 15px #00c000; } +.window-frame button.gain-switch:checked { + text-shadow: 0 0 5px #00c000, 0 0 15px #00c000; +} + .window-frame button.phantom:checked { text-shadow: 0 0 5px #ff0000, 0 0 15px #c00000; } diff --git a/src/iface-mixer.c b/src/iface-mixer.c index a9c3019..0e15b24 100644 --- a/src/iface-mixer.c +++ b/src/iface-mixer.c @@ -427,6 +427,25 @@ static void create_input_pad_control( gtk_grid_attach(GTK_GRID(grid), w, column_num, current_row, 1, 1); } +static void create_input_gain_switch_control( + struct alsa_elem *elem, + GtkWidget *grid, + int current_row, + int column_num +) { + GtkWidget *w = make_boolean_alsa_elem(elem, "Gain", NULL); + gtk_widget_add_css_class(w, "gain-switch"); + gtk_widget_set_hexpand(w, TRUE); + gtk_widget_set_tooltip_text( + w, + "Enabling Gain switches from Low gain input (0dBFS = +16dBu)\n" + "to High gain input (0dBFS = −10dBV, approx −6dBu)." + ); + + // ignore current_row, always put it in the first row + gtk_grid_attach(GTK_GRID(grid), w, column_num, 1, 1, 1); +} + static void create_input_phantom_control( struct alsa_elem *elem, GtkWidget *grid, @@ -483,13 +502,11 @@ static void create_input_controls_by_type( static void create_input_controls( struct alsa_card *card, GtkWidget *top, - int *x + int *x, + int input_count ) { GArray *elems = card->elems; - // find how many inputs have switches - int input_count = get_max_elem_by_name(elems, "Line", "Capture Switch"); - // Only the 18i20 Gen 2 has no input controls if (!input_count) return; @@ -574,6 +591,10 @@ static void create_input_controls( elems, input_grid, ¤t_row, "Level Capture Enum", create_input_level_control ); + create_input_controls_by_type( + elems, input_grid, ¤t_row, + "Impedance Switch", create_input_level_control + ); create_input_controls_by_type( elems, input_grid, ¤t_row, "Air Capture Switch", create_input_air_switch_control @@ -598,6 +619,14 @@ static void create_input_controls( elems, input_grid, ¤t_row, "Pad Capture Switch", create_input_pad_control ); + create_input_controls_by_type( + elems, input_grid, ¤t_row, + "Pad Switch", create_input_pad_control + ); + create_input_controls_by_type( + elems, input_grid, ¤t_row, + "Gain Switch", create_input_gain_switch_control + ); create_input_controls_by_type( elems, input_grid, ¤t_row, "Phantom Power Capture Switch", create_input_phantom_control @@ -838,12 +867,16 @@ static GtkWidget *create_main_window_controls(struct alsa_card *card) { int input_count = get_max_elem_by_name( card->elems, "Line", "Capture Switch" ); + if (!input_count) + input_count = + get_max_elem_by_name(card->elems, "Input", "Switch"); + int output_count = get_max_elem_by_name( card->elems, "Line", "Playback Volume" ); create_global_controls(card, top, &x); - create_input_controls(card, top, &x); + create_input_controls(card, top, &x, input_count); if (input_count + output_count >= 12) { x = 0;