Add 4th Gen input controls

This commit is contained in:
Geoffrey D. Bennett
2023-12-03 00:28:20 +10:30
parent 63068ed9c7
commit d56a1d34ff
3 changed files with 126 additions and 0 deletions

View File

@@ -9,6 +9,7 @@
#include "widget-combo.h"
#include "widget-dual.h"
#include "widget-gain.h"
#include "widget-label.h"
#include "window-helper.h"
#include "window-levels.h"
#include "window-mixer.h"
@@ -148,6 +149,77 @@ static GtkWidget *create_global_box(GtkWidget *grid, int *x, int orient) {
return controls;
}
static void create_input_link_control(
struct alsa_elem *elem,
GtkWidget *grid,
int current_row,
int line_num
) {
GtkWidget *w = make_boolean_alsa_elem(elem, "Off", "On");
int from, to;
get_two_num_from_string(elem->name, &from, &to);
if (to == -1)
to = from;
gtk_grid_attach(GTK_GRID(grid), w, from, current_row, to - from + 1, 1);
}
static void create_input_gain_control(
struct alsa_elem *elem,
GtkWidget *grid,
int current_row,
int line_num
) {
GtkWidget *w = make_gain_alsa_elem(elem);
gtk_grid_attach(GTK_GRID(grid), w, line_num, current_row, 1, 1);
}
static void create_input_autogain_control(
struct alsa_elem *elem,
GtkWidget *grid,
int current_row,
int line_num
) {
GtkWidget *w = make_boolean_alsa_elem(elem, "Off", "On");
gtk_widget_set_tooltip_text(
w,
"Autogain will listen to the input signal for 10 seconds and "
"automatically set the gain of the input channel to get the "
"best signal level."
);
gtk_grid_attach(GTK_GRID(grid), w, line_num, current_row, 1, 1);
}
static void create_input_autogain_status_control(
struct alsa_elem *elem,
GtkWidget *grid,
int current_row,
int line_num
) {
GtkWidget *w = make_label_alsa_elem(elem);
gtk_grid_attach(GTK_GRID(grid), w, line_num, current_row, 1, 1);
}
static void create_input_safe_control(
struct alsa_elem *elem,
GtkWidget *grid,
int current_row,
int line_num
) {
GtkWidget *w = make_boolean_alsa_elem(elem, "Off", "On");
gtk_widget_set_tooltip_text(
w,
"Enabling Safe Mode prevents the input from clipping by "
"automatically reducing the gain if the signal is too hot."
);
gtk_grid_attach(GTK_GRID(grid), w, line_num, current_row, 1, 1);
}
static void create_input_level_control(
struct alsa_elem *elem,
GtkWidget *grid,
@@ -287,6 +359,27 @@ static void create_input_controls(
}
int current_row = 1;
create_input_controls_by_type(
elems, input_grid, &current_row,
"Link", "Link Capture Switch", create_input_link_control
);
create_input_controls_by_type(
elems, input_grid, &current_row,
"Gain", "Gain Capture Volume", create_input_gain_control
);
create_input_controls_by_type(
elems, input_grid, &current_row,
"Autogain", "Autogain Capture Switch", create_input_autogain_control
);
create_input_controls_by_type(
elems, input_grid, &current_row,
"Autogain Status", "Autogain Status Capture Enum",
create_input_autogain_status_control
);
create_input_controls_by_type(
elems, input_grid, &current_row,
"Safe", "Safe Capture Switch", create_input_safe_control
);
create_input_controls_by_type(
elems, input_grid, &current_row,
"Level", "Level Capture Enum", create_input_level_control

23
src/widget-label.c Normal file
View File

@@ -0,0 +1,23 @@
// SPDX-FileCopyrightText: 2022 Geoffrey D. Bennett <g@b4.vu>
// SPDX-License-Identifier: GPL-3.0-or-later
#include "widget-label.h"
static void label_updated(struct alsa_elem *elem) {
const char *text = alsa_get_item_name(elem, alsa_get_elem_value(elem));
gtk_label_set_text(GTK_LABEL(elem->widget), text);
}
GtkWidget *make_label_alsa_elem(struct alsa_elem *elem) {
GtkWidget *label = gtk_label_new(NULL);
gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
elem->widget = label;
elem->widget_callback = label_updated;
label_updated(elem);
return label;
}

10
src/widget-label.h Normal file
View File

@@ -0,0 +1,10 @@
// SPDX-FileCopyrightText: 2022 Geoffrey D. Bennett <g@b4.vu>
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <gtk/gtk.h>
#include "alsa.h"
GtkWidget *make_label_alsa_elem(struct alsa_elem *elem);