From 6a34f67a66eee984d72393ad41c3bdf9b6f10279 Mon Sep 17 00:00:00 2001 From: Guenter Geiger Date: Thu, 23 Jan 2003 12:32:04 +0000 Subject: included patch from Jesse Chappell svn path=/trunk/externals/plugin~/; revision=359 --- plugin~.c | 13 ++++++++----- plugin~.h | 8 ++++++-- plugin~_ladspa.c | 34 +++++++++++++++++++++++++++++----- plugin~_ladspa.h | 3 ++- plugin~_vst.c | 4 ++-- 5 files changed, 47 insertions(+), 15 deletions(-) diff --git a/plugin~.c b/plugin~.c index ca1bda1..b9d3a8d 100644 --- a/plugin~.c +++ b/plugin~.c @@ -1,6 +1,6 @@ /* plugin~, a Pd tilde object for hosting LADSPA/VST plug-ins Copyright (C) 2000 Jarno Seppänen - $Id: plugin~.c,v 1.1 2002-11-19 09:51:40 ggeiger Exp $ + $Id: plugin~.c,v 1.2 2003-01-23 12:32:04 ggeiger Exp $ This file is part of plugin~. @@ -328,15 +328,18 @@ plugin_tilde_perform (t_int* w) void plugin_tilde_emit_control_output (Pd_Plugin_Tilde* x, const char* name, - float new_value) + float new_value, + int output_port_index) { - /* Construct and outlet a "control" message with two Pd atoms */ - t_atom anything_atoms[2]; + /* Construct and outlet a "control" message with three Pd atoms */ + t_atom anything_atoms[3]; anything_atoms[0].a_type = A_SYMBOL; anything_atoms[0].a_w.w_symbol = gensym ((char*)name); anything_atoms[1].a_type = A_FLOAT; anything_atoms[1].a_w.w_float = new_value; - outlet_anything (x->control_outlet, gensym ("control"), 2, anything_atoms); + anything_atoms[2].a_type = A_FLOAT; + anything_atoms[2].a_w.w_float = output_port_index; + outlet_anything (x->control_outlet, gensym ("control"), 3, anything_atoms); } static void diff --git a/plugin~.h b/plugin~.h index 69ca96a..54deb41 100644 --- a/plugin~.h +++ b/plugin~.h @@ -1,6 +1,6 @@ /* plugin~, a Pd tilde object for hosting LADSPA/VST plug-ins Copyright (C) 2000 Jarno Seppänen - $Id: plugin~.h,v 1.1 2002-11-19 09:51:40 ggeiger Exp $ + $Id: plugin~.h,v 1.2 2003-01-23 12:32:04 ggeiger Exp $ This file is part of plugin~. @@ -54,7 +54,10 @@ typedef struct /* Memory to pass async control data to/from the plugin */ float* control_input_values; + int * control_input_ports; /* port indexes */ float* control_output_values; + int * control_output_ports; /* port indexes */ + /* Used for monitoring changes in the values */ float* prev_control_output_values; int prev_control_output_values_invalid; @@ -133,7 +136,8 @@ static t_int* plugin_tilde_perform (t_int* w); /* Plugin callback for sending control output messages */ void plugin_tilde_emit_control_output (Pd_Plugin_Tilde* x, const char* name, - float new_value); + float new_value, + int output_port_index); /* First inlet message callback for "control" messages */ static void plugin_tilde_control (Pd_Plugin_Tilde* x, diff --git a/plugin~_ladspa.c b/plugin~_ladspa.c index 1f214fe..9e7c8f3 100644 --- a/plugin~_ladspa.c +++ b/plugin~_ladspa.c @@ -1,6 +1,6 @@ /* plugin~, a Pd tilde object for hosting LADSPA/VST plug-ins Copyright (C) 2000 Jarno Seppänen - $Id: plugin~_ladspa.c,v 1.1 2002-11-19 09:51:40 ggeiger Exp $ + $Id: plugin~_ladspa.c,v 1.2 2003-01-23 12:32:04 ggeiger Exp $ This file is part of plugin~. @@ -121,6 +121,8 @@ plugin_tilde_ladspa_open_plugin (Pd_Plugin_Tilde* x, x->plugin.ladspa.instance = NULL; x->plugin.ladspa.control_input_values = NULL; x->plugin.ladspa.control_output_values = NULL; + x->plugin.ladspa.control_input_ports = NULL; + x->plugin.ladspa.control_output_ports = NULL; x->plugin.ladspa.prev_control_output_values = NULL; x->plugin.ladspa.prev_control_output_values_invalid = 1; x->plugin.ladspa.outofplace_audio_outputs = NULL; @@ -253,8 +255,9 @@ plugin_tilde_ladspa_apply_plugin (Pd_Plugin_Tilde* x) { /* Emit a control message */ plugin_tilde_emit_control_output (x, - x->plugin.ladspa.type->PortNames[i], - x->plugin.ladspa.control_output_values[i]); + x->plugin.ladspa.type->PortNames[x->plugin.ladspa.control_output_ports[i]], + x->plugin.ladspa.control_output_values[i], + i); /* Update the corresponding control monitoring value */ x->plugin.ladspa.prev_control_output_values[i] = x->plugin.ladspa.control_output_values[i]; } @@ -619,6 +622,7 @@ plugin_tilde_ladspa_connect_control_ports (Pd_Plugin_Tilde* x) x->plugin.ladspa.type->connect_port (x->plugin.ladspa.instance, port_index, &x->plugin.ladspa.control_input_values[input_count]); + x->plugin.ladspa.control_input_ports[input_count] = port_index; input_count++; } else if (LADSPA_IS_PORT_OUTPUT (port_type)) @@ -626,6 +630,8 @@ plugin_tilde_ladspa_connect_control_ports (Pd_Plugin_Tilde* x) x->plugin.ladspa.type->connect_port (x->plugin.ladspa.instance, port_index, &x->plugin.ladspa.control_output_values[output_count]); + x->plugin.ladspa.control_output_ports[output_count] = port_index; + output_count++; } } @@ -684,24 +690,32 @@ static int plugin_tilde_ladspa_alloc_control_memory (Pd_Plugin_Tilde* x) { x->plugin.ladspa.control_input_values = NULL; + x->plugin.ladspa.control_input_ports = NULL; if (x->num_control_inputs > 0) { x->plugin.ladspa.control_input_values = (float*)calloc (x->num_control_inputs, sizeof (float)); - if (x->plugin.ladspa.control_input_values == NULL) { + x->plugin.ladspa.control_input_ports = (int*)calloc + (x->num_control_inputs, sizeof (int)); + if (x->plugin.ladspa.control_input_values == NULL + || x->plugin.ladspa.control_input_ports == NULL) { return 1; /* error */ } } x->plugin.ladspa.control_output_values = NULL; + x->plugin.ladspa.control_output_ports = NULL; x->plugin.ladspa.prev_control_output_values = NULL; if (x->num_control_outputs > 0) { x->plugin.ladspa.control_output_values = (float*)calloc (x->num_control_outputs, sizeof (float)); + x->plugin.ladspa.control_output_ports = (int*)calloc + (x->num_control_outputs, sizeof (int)); x->plugin.ladspa.prev_control_output_values = (float*)calloc (x->num_control_outputs, sizeof (float)); if (x->plugin.ladspa.control_output_values == NULL - || x->plugin.ladspa.prev_control_output_values == NULL) { + || x->plugin.ladspa.prev_control_output_values == NULL + || x->plugin.ladspa.control_output_ports == NULL) { return 1; /* error */ } } @@ -728,6 +742,16 @@ plugin_tilde_ladspa_free_control_memory (Pd_Plugin_Tilde* x) free (x->plugin.ladspa.prev_control_output_values); x->plugin.ladspa.prev_control_output_values = NULL; } + if (x->plugin.ladspa.control_input_ports != NULL) + { + free (x->plugin.ladspa.control_input_ports); + x->plugin.ladspa.control_input_ports = NULL; + } + if (x->plugin.ladspa.control_output_ports != NULL) + { + free (x->plugin.ladspa.control_output_ports); + x->plugin.ladspa.control_output_ports = NULL; + } } #endif /* PLUGIN_TILDE_USE_LADSPA */ diff --git a/plugin~_ladspa.h b/plugin~_ladspa.h index 7aff82f..ce94e43 100644 --- a/plugin~_ladspa.h +++ b/plugin~_ladspa.h @@ -1,6 +1,6 @@ /* plugin~, a Pd tilde object for hosting LADSPA/VST plug-ins Copyright (C) 2000 Jarno Seppänen - $Id: plugin~_ladspa.h,v 1.1 2002-11-19 09:51:40 ggeiger Exp $ + $Id: plugin~_ladspa.h,v 1.2 2003-01-23 12:32:04 ggeiger Exp $ This file is part of plugin~. @@ -43,6 +43,7 @@ typedef struct /* Memory to pass async control data to/from the plugin */ float* control_input_values; float* control_output_values; + /* Used for monitoring changes in the values */ float* prev_control_output_values; int prev_control_output_values_invalid; diff --git a/plugin~_vst.c b/plugin~_vst.c index c8427e5..ed05a00 100644 --- a/plugin~_vst.c +++ b/plugin~_vst.c @@ -1,6 +1,6 @@ /* plugin~, a Pd tilde object for hosting LADSPA/VST plug-ins Copyright (C) 2000 Jarno Seppänen - $Id: plugin~_vst.c,v 1.1 2002-11-19 09:51:40 ggeiger Exp $ + $Id: plugin~_vst.c,v 1.2 2003-01-23 12:32:04 ggeiger Exp $ This file is part of plugin~. @@ -381,7 +381,7 @@ plugin_tilde_vst_audioMaster (AEffect* effect, /* Send "control" messages from here */ memset (param_name, 0, 9); effect->dispatcher (effect, effGetParamName, index, 0, param_name, 0); - plugin_tilde_emit_control_output (effect->user, param_name, opt); + plugin_tilde_emit_control_output (effect->user, param_name, opt, index); return 0; break; case audioMasterVersion: -- cgit v1.2.1