1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
/* pluginhost~ - A plugin host for Pd
*
* Copyright (C) 2012 Jamie Bullock and others
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*/
#include <stdbool.h>
#include <stdint.h>
#include "m_pd.h"
#include "dssi.h"
#define PH_NAME "pluginhost~"
#define PH_VERSION 1.1
#define EVENT_BUFSIZE 1024
#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
typedef struct _ph_instance {
unsigned int plugin_pgm_count;
bool ui_needs_pgm_update;
char *ui_osc_control_path;
char *ui_osc_configure_path;
char *ui_osc_program_path;
char *ui_osc_show_path;
char *ui_osc_hide_path;
char *ui_osc_quit_path;
char *osc_url_path;
long current_bank;
long current_pgm;
int pending_pgm_change;
int pending_bank_lsb;
int pending_bank_msb;
int ui_hidden;
int ui_show;
char * ui_target; /* TODO: should be host, port */
uint8_t perf_buffer[DX7_PERFORMANCE_SIZE];
pid_t gui_pid;
int *plugin_port_ctlin_numbers; /*not sure if this should go here?*/
DSSI_Program_Descriptor *plugin_pgms;
} ph_instance;
typedef struct ph_configure_pair {
struct ph_configure_pair *next;
unsigned int instance;
char *value;
char *key;
} ph_configure_pair;
typedef struct _port_info {
t_atom lower_bound;
t_atom upper_bound;
t_atom data_type;
t_atom p_default;
t_atom type;
t_atom name;
} ph_port_info;
typedef struct _ph {
t_object x_obj; /* gah, this has to be first element in the struct, WTF? */
int sr;
int blksize;
int time_ref;
int ports_in;
int ports_out;
int ports_control_in;
int ports_control_out;
int buf_write_index;
int buf_read_index;
bool is_dssi;
bool dsp;
bool dsp_loop;
char *plugin_basename;
char *plugin_label;
char *plugin_full_path;
char *project_dir;
void *plugin_handle;
char *osc_url_base;
float f;
float sr_inv;
float **plugin_input_buffers;
float **plugin_output_buffers;
float *plugin_control_input;
float *plugin_control_output;
unsigned int osc_port;
unsigned int n_instances;
unsigned int plugin_ins;
unsigned int plugin_outs;
unsigned int plugin_control_ins;
unsigned int plugin_control_outs;
unsigned long *instance_event_counts;
unsigned long *plugin_ctlin_port_numbers;
unsigned char channel_map[128];
DSSI_Descriptor *descriptor;
LADSPA_Handle *instance_handles;
t_inlet **inlets;
t_outlet **outlets;
t_outlet *message_out;
t_canvas *x_canvas;
ph_port_info *port_info;
ph_instance *instances;
ph_configure_pair *configure_buffer_head;
snd_seq_event_t **instance_event_buffers;
snd_seq_event_t midi_event_buf[EVENT_BUFSIZE];
} ph;
void ph_debug_post(const char *fmt, ...);
void ph_quit_plugin(ph *x);
void ph_init_plugin(ph *x);
void ph_free_plugin(ph *x);
void ph_load_gui(ph *x, unsigned int i);
void ph_query_programs(ph *x, unsigned int i);
void ph_program_change(ph *x, unsigned int i);
void ph_instance_send_osc(t_outlet *outlet, ph_instance *instance,
t_int argc, t_atom *argv);
void *ph_load_plugin(ph *x, t_int argc, t_atom *argv);
char *ph_send_configure(ph *x, const char *key, const char *value,
unsigned int i);
DSSI_Descriptor *ladspa_to_dssi(LADSPA_Descriptor *ladspaDesc);
#define HEADER_PH_COMMON
#endif
|