diff options
author | Jamie Bullock <postlude@users.sourceforge.net> | 2011-09-07 11:49:06 +0000 |
---|---|---|
committer | Jamie Bullock <postlude@users.sourceforge.net> | 2011-09-07 11:49:06 +0000 |
commit | 4d30c976137b2bc4385990006d59b345f6640242 (patch) | |
tree | 0260996d4d77ef61ae249acae88fb13961189dfa /pluginhost~ | |
parent | b78ff2c5781fec8e1dc85fcc27ee26f5183d0488 (diff) |
- fixed debug print crash
- added a workaround for setting hexter pitch bend range, pressure sensitivity, mod wheel sensitivity, portamento time etc
svn path=/trunk/externals/postlude/; revision=15289
Diffstat (limited to 'pluginhost~')
-rw-r--r-- | pluginhost~/src/handlers_osc.c | 4 | ||||
-rw-r--r-- | pluginhost~/src/handlers_osc.h | 2 | ||||
-rw-r--r-- | pluginhost~/src/handlers_pd.c | 73 | ||||
-rw-r--r-- | pluginhost~/src/ph_common.c | 74 | ||||
-rw-r--r-- | pluginhost~/src/ph_common.h | 6 |
5 files changed, 122 insertions, 37 deletions
diff --git a/pluginhost~/src/handlers_osc.c b/pluginhost~/src/handlers_osc.c index 1b3288b..4114baf 100644 --- a/pluginhost~/src/handlers_osc.c +++ b/pluginhost~/src/handlers_osc.c @@ -91,7 +91,7 @@ void handle_osc_program(ph *x, t_atom *argv, unsigned int i) } if (!found) { - pd_error(x, "UI requested unknown program: bank %ul, program %ul: " + pd_error(x, "UI requested unknown program: bank %lu, program %lu: " "sending to plugin anyway (plugin should ignore it)\n", bank, program); } @@ -185,7 +185,7 @@ void handle_osc_exiting(ph *x, t_atom *argv, int i) } -void handle_osc_update(ph *x, t_atom *argv, int i) +void handle_osc_update(ph *x, t_atom *argv, unsigned int i) { const char *url; const char *path; diff --git a/pluginhost~/src/handlers_osc.h b/pluginhost~/src/handlers_osc.h index ad1526e..a45c56a 100644 --- a/pluginhost~/src/handlers_osc.h +++ b/pluginhost~/src/handlers_osc.h @@ -36,5 +36,5 @@ void handle_osc_control(ph *x, t_atom *argv, int i); void handle_osc_midi(ph *x, t_atom *argv, unsigned int i); void handle_osc_configure(ph *x, t_atom *argv, int i); void handle_osc_exiting(ph *x, t_atom *argv, int i); -void handle_osc_update(ph *x, t_atom *argv, int i); +void handle_osc_update(ph *x, t_atom *argv, unsigned int i); diff --git a/pluginhost~/src/handlers_pd.c b/pluginhost~/src/handlers_pd.c index cef3821..614c16f 100644 --- a/pluginhost~/src/handlers_pd.c +++ b/pluginhost~/src/handlers_pd.c @@ -36,7 +36,7 @@ #include "handlers_osc.h" #include "ph_common.h" -#define DX7_VOICE_SIZE_PACKED 28 /*From hexter_types.h by Sean Bolton */ +#define DX7_VOICE_SIZE_PACKED 128 /*From hexter_types.h by Sean Bolton */ #define DX7_DUMP_SIZE_BULK 4096+8 #define DX7_BANK_SIZE 32 #define DX7_MAX_PATCH_SIZE 16384 @@ -49,15 +49,19 @@ #define TYPE_STRING_SIZE 20 #define OSC_ADDR_MAX 8192 -#ifdef DEBUG +#if DEBUG == 1 #define CHECKSUM_PATCH_FILES_ON_LOAD 1 #endif +#define CLASS_NAME_STR "pluginhost~" + + /*From dx7_voice.h by Sean Bolton */ typedef struct _dx7_patch_t { uint8_t data[128]; } dx7_patch_t; + /*From dx7_voice_data.c by Sean Bolton */ static char base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; @@ -155,7 +159,9 @@ static void ph_midibuf_add(ph *x, int type, unsigned int chan, int param, int va t_int time_ref = x->time_ref; t_int mapped; - mapped = x->channel_map[chan + 1] - 1; + //mapped = x->channel_map[chan + 1] - 1; + /* FIX: get rid of mapping functionality */ + mapped = chan; x->midi_event_buf[x->buf_write_index].time.time.tv_sec = (t_int)(clock_gettimesince(time_ref) * .001); @@ -454,16 +460,16 @@ static t_int ph_configure_buffer(ph *x, char *key, static t_int *ph_perform(t_int *w) { unsigned int instance; - unsigned int timediff; - unsigned int framediff; unsigned int i; unsigned int N; + int timediff; + int framediff; t_float **inputs; t_float **outputs; ph *x; x = (ph *)(w[1]); - N = (t_int)(w[2]); + N = (unsigned int)(w[2]); inputs = (t_float **)(&w[3]); outputs = (t_float **)(&w[3] + x->plugin_ins); @@ -485,6 +491,7 @@ static t_int *ph_perform(t_int *w) if(instance > x->n_instances){ pd_error(x, "%s: %s: discarding spurious MIDI data, for instance %d", + CLASS_NAME_STR, x->descriptor->LADSPA_Plugin->Label, instance); ph_debug_post("n_instances = %d", x->n_instances); @@ -497,11 +504,11 @@ static t_int *ph_perform(t_int *w) continue; } - timediff = (t_int)(clock_gettimesince(x->time_ref) * 1000) - + timediff = (int)(clock_gettimesince(x->time_ref) * 1000) - x->midi_event_buf[x->buf_read_index].time.time.tv_nsec; - framediff = (t_int)((t_float)timediff * .000001 / x->sr_inv); + framediff = (int)((t_float)timediff * .000001 / x->sr_inv); - if (framediff >= N || framediff < 0) + if (framediff >= (int)N || framediff < 0) x->midi_event_buf[x->buf_read_index].time.tick = 0; else x->midi_event_buf[x->buf_read_index].time.tick = @@ -788,7 +795,7 @@ void handle_pd_dssi(ph *x, t_symbol *s, int argc, t_atom *argv) raw_patch_data[DX7_DUMP_SIZE_BULK - 2]) { pd_error(x, "DX7 32 voice dump with bad checksum!"); - count = 0; + count = 0; #endif @@ -835,7 +842,9 @@ void handle_pd_dssi(ph *x, t_symbol *s, int argc, t_atom *argv) key = DSSI_PROJECT_DIRECTORY_KEY; value = x->project_dir; } else if (!strcmp(msg_type, "dir")) { - pd_error(x, "%s: %s %s: operation not supported", msg_type, + pd_error(x, "%s: %s %s: operation not supported", + CLASS_NAME_STR, + msg_type, argv[1].a_w.w_symbol->s_name); } @@ -894,6 +903,7 @@ void handle_pd_dssi(ph *x, t_symbol *s, int argc, t_atom *argv) } if(key != NULL && value != NULL){ + if(instance == -1){ while(n_instances--){ debug = ph_send_configure(x, key, value, n_instances); @@ -901,9 +911,44 @@ void handle_pd_dssi(ph *x, t_symbol *s, int argc, t_atom *argv) } } /*TODO: Put some error checking in here to make sure instance is valid*/ + /* FIX: this is all a big hack (putting UI stuff in the host). Either + * hexter needs to expose these settings somehow (e.g. as configure + * key-value pairs), or we need a [hexter_ui] external/patch that + * mirrors the functionality of hexter_gtk */ else{ - - debug = ph_send_configure(x, key, value, instance); + if(!strcmp(key, "pitch_bend_range")){ + x->instances[instance].perf_buffer[3] = atoi(value); + char *p = encode_7in6(x->instances[instance].perf_buffer, + DX7_PERFORMANCE_SIZE); + debug = ph_send_configure(x, "performance", p, instance); + } else if (!strcmp(key, "portamento_time")) { + x->instances[instance].perf_buffer[5] = atoi(value); + char *p = encode_7in6(x->instances[instance].perf_buffer, + DX7_PERFORMANCE_SIZE); + debug = ph_send_configure(x, "performance", p, instance); + } else if (!strcmp(key, "mod_wheel_sensitivity")) { + x->instances[instance].perf_buffer[9] = atoi(value); + char *p = encode_7in6(x->instances[instance].perf_buffer, + DX7_PERFORMANCE_SIZE); + debug = ph_send_configure(x, "performance", p, instance); + } else if (!strcmp(key, "foot_sensitivity")) { + x->instances[instance].perf_buffer[11] = atoi(value); + char *p = encode_7in6(x->instances[instance].perf_buffer, + DX7_PERFORMANCE_SIZE); + debug = ph_send_configure(x, "performance", p, instance); + } else if (!strcmp(key, "pressure_sensitivity")) { + x->instances[instance].perf_buffer[13] = atoi(value); + char *p = encode_7in6(x->instances[instance].perf_buffer, + DX7_PERFORMANCE_SIZE); + debug = ph_send_configure(x, "performance", p, instance); + } else if (!strcmp(key, "breath_sensitivity")) { + x->instances[instance].perf_buffer[4] = atoi(value); + char *p = encode_7in6(x->instances[instance].perf_buffer, + DX7_PERFORMANCE_SIZE); + debug = ph_send_configure(x, "performance", p, instance); + } else { + debug = ph_send_configure(x, key, value, instance); + } ph_configure_buffer(x, key, value, instance); } } @@ -993,7 +1038,7 @@ void handle_pd_reset(ph *x, int i) ladspa = x->descriptor->LADSPA_Plugin; for(n = 0; n < x->n_instances; n++) { - if (i == -1 || n == i) { + if (i == -1 || (int)n == i) { if (ladspa->deactivate && ladspa->activate){ ladspa->deactivate(x->instance_handles[n]); ladspa->activate(x->instance_handles[n]); diff --git a/pluginhost~/src/ph_common.c b/pluginhost~/src/ph_common.c index 33ac9ec..2915b15 100644 --- a/pluginhost~/src/ph_common.c +++ b/pluginhost~/src/ph_common.c @@ -42,7 +42,18 @@ #include "jutils.h" #include "ph_common.h" -#define DEBUG_STRING_SIZE 1024 +#define DEBUG_STRING_SIZE 8192 + +/*From dx7_voice_data.c */ +uint8_t dx7_init_performance[DX7_PERFORMANCE_SIZE] = { 0, 0, 0, 2, 0, 0, 0, 0, + 0, 15, 1, 0, 4, 15, 2, 15, + 2, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 +}; static LADSPA_Data ph_get_port_default(ph *x, int port) { @@ -224,7 +235,7 @@ static void ph_assign_ports(ph *x) x->instances[i].plugin_port_ctlin_numbers = (int *)malloc(x->descriptor->LADSPA_Plugin->PortCount * - sizeof(int));/* hmmm... as we don't support instances of differing plugin types, we probably don't need to do this dynamically*/ + sizeof(int)); } x->plugin_ctlin_port_numbers = @@ -238,9 +249,27 @@ static void ph_assign_ports(ph *x) static void ph_init_instance(ph *x, unsigned int i) { - ph_instance zero = {0}; + x->instances[i].plugin_pgm_count = 0; + x->instances[i].ui_needs_pgm_update = 0; + x->instances[i].ui_osc_control_path = NULL; + x->instances[i].ui_osc_configure_path = NULL; + x->instances[i].ui_osc_program_path = NULL; + x->instances[i].ui_osc_show_path = NULL; + x->instances[i].ui_osc_hide_path = NULL; + x->instances[i].ui_osc_quit_path = NULL; + x->instances[i].osc_url_path = NULL; + x->instances[i].current_bank = 0; + x->instances[i].current_pgm = 0; + x->instances[i].pending_pgm_change = -1; + x->instances[i].pending_bank_lsb = -1; + x->instances[i].pending_bank_msb = -1; + x->instances[i].ui_hidden = 1; + x->instances[i].ui_show = 0; + memcpy(x->instances[i].perf_buffer, &dx7_init_performance, DX7_PERFORMANCE_SIZE); + + //x->instances[i].plugin_port_ctlin_numbers = NULL; + x->instances[i].plugin_pgms = NULL; - x->instances[i] = zero; ph_debug_post("Instance %d initialized!", i); } @@ -249,9 +278,6 @@ static void ph_connect_ports(ph *x, unsigned int i) { unsigned int n; - ph_instance *instance; - - instance = &x->instances[i]; for(n = 0; n < x->descriptor->LADSPA_Plugin->PortCount; n++){ ph_debug_post("PortCount: %d of %d", n, @@ -260,7 +286,7 @@ static void ph_connect_ports(ph *x, unsigned int i) LADSPA_PortDescriptor pod = x->descriptor->LADSPA_Plugin->PortDescriptors[n]; - instance->plugin_port_ctlin_numbers[n] = -1; + x->instances[i].plugin_port_ctlin_numbers[n] = -1; if (LADSPA_IS_PORT_AUDIO(pod)) { if (LADSPA_IS_PORT_INPUT(pod)) { @@ -280,7 +306,8 @@ static void ph_connect_ports(ph *x, unsigned int i) else if (LADSPA_IS_PORT_CONTROL(pod)) { if (LADSPA_IS_PORT_INPUT(pod)) { x->plugin_ctlin_port_numbers[x->ports_control_in] = (unsigned long) i; - instance->plugin_port_ctlin_numbers[n] = x->ports_control_in; + x->instances[i].plugin_port_ctlin_numbers[n] = + x->ports_control_in; x->plugin_control_input[x->ports_control_in] = (t_float) ph_get_port_default(x, n); ph_debug_post("default for port %d, control_in, %d is %.2f", n, @@ -554,7 +581,8 @@ static void osc_setup(ph *x, unsigned int i) instance->osc_url_path = malloc(sizeof(char) * (strlen(x->plugin_basename) + strlen(x->descriptor->LADSPA_Plugin->Label) + - strlen("chan00") + 3)); + //strlen("chan00") + 3)); + 6 + 3)); sprintf(instance->osc_url_path, "%s/%s/chan%02d", x->plugin_basename, x->descriptor->LADSPA_Plugin->Label, i); ph_debug_post("OSC Path is: %s", instance->osc_url_path); @@ -565,7 +593,7 @@ static void osc_setup(ph *x, unsigned int i) void ph_debug_post(const char *fmt, ...) { -#if DEBUG +#if DEBUG == 1 unsigned int currpos; char newfmt[DEBUG_STRING_SIZE]; char result[DEBUG_STRING_SIZE]; @@ -601,9 +629,11 @@ void ph_quit_plugin(ph *x) instance = &x->instances[i]; if(x->is_dssi){ argc = 2; - SETSYMBOL(argv, gensym(instance->ui_osc_quit_path)); - SETSYMBOL(argv+1, gensym("")); - ph_instance_send_osc(x->message_out, instance, argc, argv); + if(instance->ui_osc_quit_path != NULL) { + SETSYMBOL(argv, gensym(instance->ui_osc_quit_path)); + SETSYMBOL(argv+1, gensym("")); + ph_instance_send_osc(x->message_out, instance, argc, argv); + } } ph_deactivate_plugin(x, i); ph_cleanup_plugin(x, i); @@ -617,7 +647,7 @@ void ph_query_programs(ph *x, unsigned int i) ph_debug_post("querying programs"); /* free old lot */ - if (instance->plugin_pgms) { + if (instance->plugin_pgms != NULL) { for (n = 0; n < instance->plugin_pgm_count; n++) { free((void *)instance->plugin_pgms[n].Name); } @@ -696,10 +726,14 @@ void ph_program_change(ph *x, unsigned int i) /* TODO - this is a hack to make text ui work*/ if(x->is_dssi){ - SETSYMBOL(argv, gensym(instance->ui_osc_program_path)); - SETFLOAT(argv+1, instance->current_bank); - SETFLOAT(argv+2, instance->current_pgm); - ph_instance_send_osc(x->message_out, instance, argc, argv); + // FIX: need to check this because if we don't have a UI, + // update didn't get called + if (false) { + SETSYMBOL(argv, gensym(instance->ui_osc_program_path)); + SETFLOAT(argv+1, instance->current_bank); + SETFLOAT(argv+2, instance->current_pgm); + ph_instance_send_osc(x->message_out, instance, argc, argv); + } } } @@ -711,7 +745,7 @@ void ph_program_change(ph *x, unsigned int i) ph_get_current_pgm(x, i); } -char *ph_send_configure(ph *x, const char *key, const char *value, +char *ph_send_configure(ph *x, const char *key, const char *value, unsigned int i) { diff --git a/pluginhost~/src/ph_common.h b/pluginhost~/src/ph_common.h index de25e60..0e7be30 100644 --- a/pluginhost~/src/ph_common.h +++ b/pluginhost~/src/ph_common.h @@ -28,6 +28,7 @@ */ #include <stdbool.h> +#include <stdint.h> #include "m_pd.h" #include "dssi.h" @@ -38,6 +39,9 @@ #define OSC_PORT 9998 #define UI_TARGET_ELEMS 2 +/*From hexter_types.h by Sean Bolton */ +#define DX7_PERFORMANCE_SIZE 64 + #define MIN(a,b) ((a)<(b)?(a):(b)) #ifndef HEADER_PH_COMMON @@ -61,6 +65,8 @@ typedef struct _ph_instance { int ui_hidden; int ui_show; t_atom ui_target[UI_TARGET_ELEMS]; /* host, port */ + uint8_t perf_buffer[DX7_PERFORMANCE_SIZE]; + int *plugin_port_ctlin_numbers; /*not sure if this should go here?*/ DSSI_Program_Descriptor *plugin_pgms; |