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);
|
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]);
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ struct kit_info {
|
|||||||
struct hp_info {
|
struct hp_info {
|
||||||
char scan_only;
|
char scan_only;
|
||||||
char in_info;
|
char in_info;
|
||||||
|
char in_component_list;
|
||||||
char in_instrument_list;
|
char in_instrument_list;
|
||||||
char in_instrument;
|
char in_instrument;
|
||||||
char in_layer;
|
char in_layer;
|
||||||
@@ -105,6 +106,12 @@ startElement(void *userData, const char *name, const char **atts)
|
|||||||
struct hp_info* info = (struct hp_info*)userData;
|
struct hp_info* info = (struct hp_info*)userData;
|
||||||
info->cur_off = 0;
|
info->cur_off = 0;
|
||||||
if (info->in_info) {
|
if (info->in_info) {
|
||||||
|
if (!info->in_component_list) {
|
||||||
|
if (!strcmp(name,"componentList")) {
|
||||||
|
info->in_component_list = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (info->in_instrument) {
|
if (info->in_instrument) {
|
||||||
if (!strcmp(name,"layer") && !info->scan_only) {
|
if (!strcmp(name,"layer") && !info->scan_only) {
|
||||||
info->in_layer = 1;
|
info->in_layer = 1;
|
||||||
@@ -122,6 +129,8 @@ startElement(void *userData, const char *name, const char **atts)
|
|||||||
if (!strcmp(name,"instrumentList"))
|
if (!strcmp(name,"instrumentList"))
|
||||||
info->in_instrument_list = 1;
|
info->in_instrument_list = 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!strcmp(name,"drumkit_info"))
|
if (!strcmp(name,"drumkit_info"))
|
||||||
info->in_info = 1;
|
info->in_info = 1;
|
||||||
@@ -135,7 +144,7 @@ endElement(void *userData, const char *name)
|
|||||||
if (info->cur_off == MAX_CHAR_DATA) info->cur_off--;
|
if (info->cur_off == MAX_CHAR_DATA) info->cur_off--;
|
||||||
info->cur_buf[info->cur_off]='\0';
|
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);
|
info->kit_info->name = strdup(info->cur_buf);
|
||||||
if (info->scan_only && info->in_info && !info->in_instrument_list && !strcmp(name,"info"))
|
if (info->scan_only && info->in_info && !info->in_instrument_list && !strcmp(name,"info"))
|
||||||
info->kit_info->desc = strdup(info->cur_buf);
|
info->kit_info->desc = strdup(info->cur_buf);
|
||||||
@@ -187,6 +196,7 @@ endElement(void *userData, const char *name)
|
|||||||
info->cur_instrument = NULL;
|
info->cur_instrument = NULL;
|
||||||
info->in_instrument = 0;
|
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_instrument_list && !strcmp(name,"instrumentList")) info->in_instrument_list = 0;
|
||||||
if (info->in_info && !strcmp(name,"drumkit_info")) info->in_info = 0;
|
if (info->in_info && !strcmp(name,"drumkit_info")) info->in_info = 0;
|
||||||
}
|
}
|
||||||
@@ -232,7 +242,7 @@ 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;
|
cp = 0;
|
||||||
struct kit_list * cur_k = scanned_kits;
|
struct kit_list * cur_k = scanned_kits;
|
||||||
while(cur_k) {
|
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;
|
cur_k = cur_k->next;
|
||||||
cp++;
|
cp++;
|
||||||
}
|
}
|
||||||
|
|||||||
27
drmr2_ui.c
27
drmr2_ui.c
@@ -51,10 +51,12 @@ 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;
|
||||||
|
|
||||||
@@ -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,14 +579,20 @@ 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;
|
||||||
@@ -594,6 +600,7 @@ static void build_drmr_ui(DrMrUi* ui) {
|
|||||||
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);
|
||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user