Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c067a43b27 | |||
| 17383c6a99 |
4
drmr2.c
4
drmr2.c
@@ -281,6 +281,10 @@ static inline void trigger_sample(DrMr *drmr, int nn, uint8_t* const data, uint3
|
||||
pthread_mutex_lock(&drmr->load_mutex);
|
||||
if (nn >= 0 && nn < drmr->num_samples) {
|
||||
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]));
|
||||
if (drmr->samples[nn].limit == 0)
|
||||
fprintf(stderr,"Failed to find layer at: %i for %f\n",nn,*drmr->gains[nn]);
|
||||
|
||||
@@ -87,6 +87,7 @@ struct kit_info {
|
||||
struct hp_info {
|
||||
char scan_only;
|
||||
char in_info;
|
||||
char in_component_list;
|
||||
char in_instrument_list;
|
||||
char in_instrument;
|
||||
char in_layer;
|
||||
@@ -105,22 +106,30 @@ startElement(void *userData, const char *name, const char **atts)
|
||||
struct hp_info* info = (struct hp_info*)userData;
|
||||
info->cur_off = 0;
|
||||
if (info->in_info) {
|
||||
if (info->in_instrument) {
|
||||
if (!strcmp(name,"layer") && !info->scan_only) {
|
||||
info->in_layer = 1;
|
||||
info->cur_layer = malloc(sizeof(struct instrument_layer));
|
||||
memset(info->cur_layer,0,sizeof(struct instrument_layer));
|
||||
if (!info->in_component_list) {
|
||||
if (!strcmp(name,"componentList")) {
|
||||
info->in_component_list = 1;
|
||||
}
|
||||
}
|
||||
if (info->in_instrument_list) {
|
||||
if (!strcmp(name,"instrument")) {
|
||||
info->in_instrument = 1;
|
||||
info->cur_instrument = malloc(sizeof(struct instrument_info));
|
||||
memset(info->cur_instrument,0,sizeof(struct instrument_info));
|
||||
else
|
||||
{
|
||||
if (info->in_instrument) {
|
||||
if (!strcmp(name,"layer") && !info->scan_only) {
|
||||
info->in_layer = 1;
|
||||
info->cur_layer = malloc(sizeof(struct instrument_layer));
|
||||
memset(info->cur_layer,0,sizeof(struct instrument_layer));
|
||||
}
|
||||
}
|
||||
if (info->in_instrument_list) {
|
||||
if (!strcmp(name,"instrument")) {
|
||||
info->in_instrument = 1;
|
||||
info->cur_instrument = malloc(sizeof(struct instrument_info));
|
||||
memset(info->cur_instrument,0,sizeof(struct instrument_info));
|
||||
}
|
||||
} else {
|
||||
if (!strcmp(name,"instrumentList"))
|
||||
info->in_instrument_list = 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!strcmp(name,"instrumentList"))
|
||||
info->in_instrument_list = 1;
|
||||
}
|
||||
} else {
|
||||
if (!strcmp(name,"drumkit_info"))
|
||||
@@ -135,7 +144,7 @@ endElement(void *userData, const char *name)
|
||||
if (info->cur_off == MAX_CHAR_DATA) info->cur_off--;
|
||||
info->cur_buf[info->cur_off]='\0';
|
||||
|
||||
if (info->in_info && !info->in_instrument_list && !strcmp(name,"name"))
|
||||
if (info->in_info && !info->in_component_list && !info->in_instrument_list && !strcmp(name,"name"))
|
||||
info->kit_info->name = strdup(info->cur_buf);
|
||||
if (info->scan_only && info->in_info && !info->in_instrument_list && !strcmp(name,"info"))
|
||||
info->kit_info->desc = strdup(info->cur_buf);
|
||||
@@ -187,6 +196,7 @@ endElement(void *userData, const char *name)
|
||||
info->cur_instrument = NULL;
|
||||
info->in_instrument = 0;
|
||||
}
|
||||
if (info->in_component_list && !strcmp(name,"componentList")) info->in_component_list = 0;
|
||||
if (info->in_instrument_list && !strcmp(name,"instrumentList")) info->in_instrument_list = 0;
|
||||
if (info->in_info && !strcmp(name,"drumkit_info")) info->in_info = 0;
|
||||
}
|
||||
@@ -232,9 +242,9 @@ static char* expand_path(char* path, char* buf) {
|
||||
|
||||
|
||||
|
||||
static int *compar_kit(const void *p1, const void *p2)
|
||||
static int compar_kit(const void *p1, const void *p2)
|
||||
{
|
||||
return (int) strcmp( (* (scanned_kit **) p1)->name, (* (scanned_kit **) p2)->name);
|
||||
return (int) strcmp( (* (scanned_kit **) p1)->name, (* (scanned_kit **) p2)->name);
|
||||
}
|
||||
|
||||
|
||||
@@ -339,7 +349,7 @@ kits* scan_kits() {
|
||||
cp = 0;
|
||||
struct kit_list * cur_k = scanned_kits;
|
||||
while(cur_k) {
|
||||
//printf("found kit: %s\nat:%s\n\n",cur_k->skit->name,cur_k->skit->path);
|
||||
// printf("found kit: %s\nat:%s\n\n",cur_k->skit->name,cur_k->skit->path);
|
||||
cur_k = cur_k->next;
|
||||
cp++;
|
||||
}
|
||||
|
||||
31
drmr2_ui.c
31
drmr2_ui.c
@@ -51,11 +51,13 @@ typedef struct {
|
||||
GtkListStore *kit_store;
|
||||
GtkWidget** gain_sliders;
|
||||
GtkWidget** pan_sliders;
|
||||
float *gain_vals,*pan_vals;
|
||||
|
||||
GtkWidget** notify_leds;
|
||||
GtkWidget *position_combo_box, *velocity_checkbox, *note_off_checkbox;
|
||||
GtkScrolledWindow *sample_view;
|
||||
|
||||
float *gain_vals,*pan_vals;
|
||||
|
||||
|
||||
gchar *bundle_path;
|
||||
|
||||
int cols;
|
||||
@@ -358,9 +360,7 @@ static gboolean kit_callback(gpointer data) {
|
||||
gain_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);
|
||||
gtk_box_pack_start(GTK_BOX(ui->drmr_widget),GTK_WIDGET(ui->sample_table),
|
||||
true,true,5);
|
||||
gtk_box_reorder_child(GTK_BOX(ui->drmr_widget),GTK_WIDGET(ui->sample_table),1);
|
||||
gtk_scrolled_window_add_with_viewport(ui->sample_view, GTK_WIDGET(ui->sample_table));
|
||||
gtk_widget_show_all(GTK_WIDGET(ui->sample_table));
|
||||
ui->samples = samples;
|
||||
ui->notify_leds = notify_leds;
|
||||
@@ -510,7 +510,7 @@ static void build_drmr_ui(DrMrUi* ui) {
|
||||
GtkWidget *drmr_ui_widget;
|
||||
GtkWidget *opts_hbox1, *opts_hbox2,
|
||||
*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;
|
||||
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),
|
||||
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,
|
||||
false,false,5);
|
||||
gtk_box_pack_start(GTK_BOX(drmr_ui_widget),opts_hbox2,
|
||||
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->sample_table = NULL;
|
||||
ui->kit_combo = GTK_COMBO_BOX(kit_combo_box);
|
||||
ui->base_label = GTK_LABEL(base_label);
|
||||
ui->base_spin = GTK_SPIN_BUTTON(base_spin);
|
||||
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(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);
|
||||
@@ -726,14 +733,18 @@ port_event(LV2UI_Handle handle,
|
||||
if (!strncmp(kitpath, "file://", 7))
|
||||
kitpath += 7;
|
||||
char *realp = realpath(kitpath,NULL);
|
||||
// fprintf(stderr, "KitPath: [%s] RealPath: [%s]\n", kitpath, realp);
|
||||
if (!realp) {
|
||||
fprintf(stderr,"Passed a path I can't resolve, bailing out\n");
|
||||
return;
|
||||
}
|
||||
int 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))
|
||||
break;
|
||||
}
|
||||
if (i < ui->kits->num_kits) {
|
||||
ui->kitReq = i;
|
||||
g_idle_add(kit_callback,ui);
|
||||
|
||||
Reference in New Issue
Block a user