Add meter/level display

This commit is contained in:
Geoffrey D. Bennett
2022-08-09 01:23:31 +09:30
parent 38edefb93e
commit d96ced2b45
4 changed files with 21 additions and 5 deletions

View File

@@ -8,6 +8,12 @@ Linux Kernel with the ALSA Scarlett2 Protocol Driver.
for the Gen 2 support.
- For Clarett+ 8Pre support, you need 6.1.
- For the other Clarett USB and Clarett+ models, you need 6.7.
- For the level meters to work, you need 6.7.
If you don't have 6.7, you can get the driver from here and build it
for your current kernel:
https://github.com/geoffreybennett/scarlett-gen2/releases/tag/v6.5.11c1
## Enabling the Driver

View File

@@ -354,8 +354,8 @@ menu option File → Interface Simulation to load.
- Cant select (focus) the gain/volume controls or use a keyboard to
adjust them.
- Level (monitoring) doesnt work yet and is disabled (needs kernel
driver update).
- Level meters dont work if you're not running the driver from Linux
6.7.
- Load/Save uses `alsactl` which will be confused if the ALSA
interface name (e.g. `USB`) changes.

View File

@@ -125,7 +125,7 @@ GMenu *create_app_menu(GtkApplication *app) {
g_menu_append_submenu(menu, "_View", G_MENU_MODEL(view_menu));
g_menu_append(view_menu, "_Routing", "win.routing");
g_menu_append(view_menu, "_Mixer", "win.mixer");
//g_menu_append(view_menu, "_Levels", "win.levels");
g_menu_append(view_menu, "_Levels", "win.levels");
g_menu_append(view_menu, "_Startup", "win.startup");
GMenu *help_menu = g_menu_new();

View File

@@ -24,7 +24,17 @@ static int update_levels_controls(void *user_data) {
// go through the ports in that category
for (int j = 0; j < card->routing_out_count[i]; j++) {
GtkWidget *meter = card->meters[meter_num];
gtk_dial_set_value(GTK_DIAL(meter), values[meter_num]);
double value = 20 * log10(values[meter_num] / 4095.0);
int int_value;
if (value < -80)
int_value = -80;
else if (value > 0)
int_value = 0;
else
int_value = round(value);
gtk_dial_set_value(GTK_DIAL(meter), int_value);
meter_num++;
}
}
@@ -93,7 +103,7 @@ GtkWidget *create_levels_controls(struct alsa_card *card) {
count_labels[j] = add_count_label(grid, j);
// create the meter widget and attach to the grid
GtkWidget *meter = gtk_dial_new_with_range(0, 4096, 1);
GtkWidget *meter = gtk_dial_new_with_range(-80, 0, 1);
card->meters[meter_num++] = meter;
gtk_grid_attach(GTK_GRID(grid), meter, j + 1, i + 1, 1, 1);
}