Merge bsdf changes:

- fix segfault
- move options to top of gui
- make sample_table scrollable
This commit is contained in:
Arnaud G. GIBERT 2022-01-10 14:37:34 +01:00
parent 17383c6a99
commit c067a43b27
2 changed files with 25 additions and 10 deletions

View File

@ -281,6 +281,10 @@ static inline void trigger_sample(DrMr *drmr, int nn, uint8_t* const data, uint3
pthread_mutex_lock(&drmr->load_mutex); pthread_mutex_lock(&drmr->load_mutex);
if (nn >= 0 && nn < drmr->num_samples) { if (nn >= 0 && nn < drmr->num_samples) {
if (drmr->samples[nn].layer_count > 0) { if (drmr->samples[nn].layer_count > 0) {
// drmr currently has 32 hard-coded gains so just use the last gain
// to prevent a segfault
int gain_idx = nn < 32 ? nn : 31;
layer_to_sample(drmr->samples+nn,*(drmr->gains[gain_idx]));
layer_to_sample(drmr->samples+nn,*(drmr->gains[nn])); layer_to_sample(drmr->samples+nn,*(drmr->gains[nn]));
if (drmr->samples[nn].limit == 0) if (drmr->samples[nn].limit == 0)
fprintf(stderr,"Failed to find layer at: %i for %f\n",nn,*drmr->gains[nn]); fprintf(stderr,"Failed to find layer at: %i for %f\n",nn,*drmr->gains[nn]);

View File

@ -51,11 +51,13 @@ typedef struct {
GtkListStore *kit_store; GtkListStore *kit_store;
GtkWidget** gain_sliders; GtkWidget** gain_sliders;
GtkWidget** pan_sliders; GtkWidget** pan_sliders;
float *gain_vals,*pan_vals;
GtkWidget** notify_leds; GtkWidget** notify_leds;
GtkWidget *position_combo_box, *velocity_checkbox, *note_off_checkbox; GtkWidget *position_combo_box, *velocity_checkbox, *note_off_checkbox;
GtkScrolledWindow *sample_view;
float *gain_vals,*pan_vals;
gchar *bundle_path; gchar *bundle_path;
int cols; int cols;
@ -358,9 +360,7 @@ static gboolean kit_callback(gpointer data) {
gain_sliders = malloc(samples*sizeof(GtkWidget*)); gain_sliders = malloc(samples*sizeof(GtkWidget*));
pan_sliders = malloc(samples*sizeof(GtkWidget*)); pan_sliders = malloc(samples*sizeof(GtkWidget*));
fill_sample_table(ui,samples,ui->kits->kits[ui->kitReq].sample_names,notify_leds,gain_sliders,pan_sliders); fill_sample_table(ui,samples,ui->kits->kits[ui->kitReq].sample_names,notify_leds,gain_sliders,pan_sliders);
gtk_box_pack_start(GTK_BOX(ui->drmr_widget),GTK_WIDGET(ui->sample_table), gtk_scrolled_window_add_with_viewport(ui->sample_view, GTK_WIDGET(ui->sample_table));
true,true,5);
gtk_box_reorder_child(GTK_BOX(ui->drmr_widget),GTK_WIDGET(ui->sample_table),1);
gtk_widget_show_all(GTK_WIDGET(ui->sample_table)); gtk_widget_show_all(GTK_WIDGET(ui->sample_table));
ui->samples = samples; ui->samples = samples;
ui->notify_leds = notify_leds; ui->notify_leds = notify_leds;
@ -510,7 +510,7 @@ static void build_drmr_ui(DrMrUi* ui) {
GtkWidget *drmr_ui_widget; GtkWidget *drmr_ui_widget;
GtkWidget *opts_hbox1, *opts_hbox2, GtkWidget *opts_hbox1, *opts_hbox2,
*kit_combo_box, *kit_label, *no_kit_label, *kit_combo_box, *kit_label, *no_kit_label,
*base_label, *base_spin, *position_label; *base_label, *base_spin, *position_label, *sample_view;
GtkCellRenderer *cell_rend; GtkCellRenderer *cell_rend;
GtkAdjustment *base_adj; GtkAdjustment *base_adj;
@ -579,22 +579,29 @@ static void build_drmr_ui(DrMrUi* ui) {
gtk_box_pack_start(GTK_BOX(drmr_ui_widget),GTK_WIDGET(ui->current_kit_label), gtk_box_pack_start(GTK_BOX(drmr_ui_widget),GTK_WIDGET(ui->current_kit_label),
false,false,5); false,false,5);
gtk_box_pack_start(GTK_BOX(drmr_ui_widget),gtk_hseparator_new(),
false,false,5);
gtk_box_pack_start(GTK_BOX(drmr_ui_widget),opts_hbox1, gtk_box_pack_start(GTK_BOX(drmr_ui_widget),opts_hbox1,
false,false,5); false,false,5);
gtk_box_pack_start(GTK_BOX(drmr_ui_widget),opts_hbox2, gtk_box_pack_start(GTK_BOX(drmr_ui_widget),opts_hbox2,
false,false,5); false,false,5);
gtk_box_pack_start(GTK_BOX(drmr_ui_widget),gtk_hseparator_new(),
false,false,5);
sample_view = gtk_scrolled_window_new(NULL, NULL);
gtk_widget_set_size_request(sample_view, -1, 300);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(sample_view),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_box_pack_start(GTK_BOX(drmr_ui_widget), sample_view,
true, true, 5);
ui->drmr_widget = drmr_ui_widget; ui->drmr_widget = drmr_ui_widget;
ui->sample_table = NULL; ui->sample_table = NULL;
ui->kit_combo = GTK_COMBO_BOX(kit_combo_box); ui->kit_combo = GTK_COMBO_BOX(kit_combo_box);
ui->base_label = GTK_LABEL(base_label); ui->base_label = GTK_LABEL(base_label);
ui->base_spin = GTK_SPIN_BUTTON(base_spin); ui->base_spin = GTK_SPIN_BUTTON(base_spin);
ui->no_kit_label = no_kit_label; ui->no_kit_label = no_kit_label;
ui->sample_view = GTK_SCROLLED_WINDOW(sample_view);
g_signal_connect(G_OBJECT(kit_combo_box),"changed",G_CALLBACK(kit_combobox_changed),ui); g_signal_connect(G_OBJECT(kit_combo_box),"changed",G_CALLBACK(kit_combobox_changed),ui);
g_signal_connect(G_OBJECT(base_spin),"value-changed",G_CALLBACK(base_changed),ui); g_signal_connect(G_OBJECT(base_spin),"value-changed",G_CALLBACK(base_changed),ui);
g_signal_connect(G_OBJECT(ui->position_combo_box),"changed",G_CALLBACK(position_combobox_changed),ui); g_signal_connect(G_OBJECT(ui->position_combo_box),"changed",G_CALLBACK(position_combobox_changed),ui);
@ -726,14 +733,18 @@ port_event(LV2UI_Handle handle,
if (!strncmp(kitpath, "file://", 7)) if (!strncmp(kitpath, "file://", 7))
kitpath += 7; kitpath += 7;
char *realp = realpath(kitpath,NULL); char *realp = realpath(kitpath,NULL);
// fprintf(stderr, "KitPath: [%s] RealPath: [%s]\n", kitpath, realp);
if (!realp) { if (!realp) {
fprintf(stderr,"Passed a path I can't resolve, bailing out\n"); fprintf(stderr,"Passed a path I can't resolve, bailing out\n");
return; return;
} }
int i; int i;
for(i = 0;i < ui->kits->num_kits;i++) for(i = 0;i < ui->kits->num_kits;i++)
{
// fprintf(stderr, "CheckPath: [%s] / [%s]\n", ui->kits->kits[i].path, realp);
if (!strcmp(ui->kits->kits[i].path,realp)) if (!strcmp(ui->kits->kits[i].path,realp))
break; break;
}
if (i < ui->kits->num_kits) { if (i < ui->kits->num_kits) {
ui->kitReq = i; ui->kitReq = i;
g_idle_add(kit_callback,ui); g_idle_add(kit_callback,ui);