Skip to content

Commit

Permalink
Add meter/level display
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffreybennett committed Nov 13, 2023
1 parent 38edefb commit d96ced2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
6 changes: 6 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,8 @@ menu option File → Interface Simulation to load.
- Can’t select (focus) the gain/volume controls or use a keyboard to
adjust them.

- Level (monitoring) doesn’t work yet and is disabled (needs kernel
driver update).
- Level meters don’t 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.
Expand Down
2 changes: 1 addition & 1 deletion src/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
14 changes: 12 additions & 2 deletions src/window-levels.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit d96ced2

Please sign in to comment.