├── makefile.dep ├── Makefile ├── ladspa_utils.h ├── README ├── pcm_equal.c ├── ctl_equal.c ├── ladspa_utils.c ├── COPYING └── ladspa.h /makefile.dep: -------------------------------------------------------------------------------- 1 | ctl_equal.o: ctl_equal.c ladspa.h ladspa_utils.h 2 | ladspa_utils.o: ladspa_utils.c ladspa.h ladspa_utils.h 3 | pcm_equal.o: pcm_equal.c ladspa.h ladspa_utils.h 4 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | # Quiet (set to @ for a quite compile) 3 | Q ?= @ 4 | #Q ?= 5 | 6 | # Build Tools 7 | CC := gcc 8 | CFLAGS := -I. -O2 -Wall -funroll-loops -ffast-math -fPIC -DPIC 9 | LD := gcc 10 | LDFLAGS := -O2 -Wall -shared -lasound 11 | 12 | SND_PCM_OBJECTS = pcm_equal.o ladspa_utils.o 13 | SND_PCM_LIBS = 14 | SND_PCM_BIN = libasound_module_pcm_equal.so 15 | 16 | SND_CTL_OBJECTS = ctl_equal.o ladspa_utils.o 17 | SND_CTL_LIBS = 18 | SND_CTL_BIN = libasound_module_ctl_equal.so 19 | 20 | .PHONY: all clean dep load_default 21 | 22 | all: Makefile $(SND_PCM_BIN) $(SND_CTL_BIN) 23 | 24 | dep: 25 | @echo DEP $@ 26 | $(Q)for i in *.c; do $(CC) -MM $(CFLAGS) "$${i}" ; done > makefile.dep 27 | 28 | -include makefile.dep 29 | 30 | $(SND_PCM_BIN): $(SND_PCM_OBJECTS) 31 | @echo LD $@ 32 | $(Q)$(LD) $(LDFLAGS) $(SND_PCM_LIBS) $(SND_PCM_OBJECTS) -o $(SND_PCM_BIN) 33 | 34 | $(SND_CTL_BIN): $(SND_CTL_OBJECTS) 35 | @echo LD $@ 36 | $(Q)$(LD) $(LDFLAGS) $(SND_CTL_LIBS) $(SND_CTL_OBJECTS) -o $(SND_CTL_BIN) 37 | 38 | %.o: %.c 39 | @echo GCC $< 40 | $(Q)$(CC) -c $(CFLAGS) $< 41 | 42 | clean: 43 | @echo Cleaning... 44 | $(Q)rm -vf *.o *.so 45 | 46 | install: all 47 | @echo Installing... 48 | $(Q)install -m 755 $(SND_PCM_BIN) ${DESTDIR}/usr/lib/alsa-lib/ 49 | $(Q)install -m 755 $(SND_CTL_BIN) ${DESTDIR}/usr/lib/alsa-lib/ 50 | 51 | uninstall: 52 | @echo Un-installing... 53 | $(Q)rm ${DESTDIR}/usr/lib/alsa-lib/$(SND_PCM_BIN) 54 | $(Q)rm ${DESTDIR}/usr/lib/alsa-lib/$(SND_CTL_BIN) 55 | 56 | -------------------------------------------------------------------------------- /ladspa_utils.h: -------------------------------------------------------------------------------- 1 | /* utils.h 2 | 3 | Free software by Richard W.E. Furse. Do with as you will. No 4 | warranty. */ 5 | 6 | #ifndef LADSPA_SDK_LOAD_PLUGIN_LIB 7 | #define LADSPA_SDK_LOAD_PLUGIN_LIB 8 | 9 | #include "ladspa.h" 10 | #include 11 | 12 | /* This function call takes a plugin library filename, searches for 13 | the library along the LADSPA_PATH, loads it with dlopen() and 14 | returns a plugin handle for use with findPluginDescriptor() or 15 | unloadLADSPAPluginLibrary(). Errors are handled by writing a 16 | message to stderr and calling exit(1). It is alright (although 17 | inefficient) to call this more than once for the same file. */ 18 | void * LADSPAload(const char * pcPluginFilename); 19 | 20 | /* This function unloads a LADSPA plugin library. */ 21 | void LADSPAunload(void * pvLADSPAPluginLibrary); 22 | 23 | /* This function locates a LADSPA plugin within a plugin library 24 | loaded with loadLADSPAPluginLibrary(). Errors are handled by 25 | writing a message to stderr and calling exit(1). Note that the 26 | plugin library filename is only included to help provide 27 | informative error messages. */ 28 | const LADSPA_Descriptor * 29 | LADSPAfind(void * pvLADSPAPluginLibrary, 30 | const char * pcPluginLibraryFilename, 31 | const char * pcPluginLabel); 32 | 33 | /* Find the default value for a port. Return 0 if a default is found 34 | and -1 if not. */ 35 | int LADSPADefault(const LADSPA_PortRangeHint * psPortRangeHint, 36 | const unsigned long lSampleRate, 37 | LADSPA_Data * pfResult); 38 | 39 | 40 | /* MMAP to a controls file */ 41 | #define LADSPA_CNTRL_INPUT 0 42 | #define LADSPA_CNTRL_OUTPUT 1 43 | typedef struct LADSPA_Control_Data_ { 44 | int32_t index; 45 | LADSPA_Data data[16]; /* Max number of channels, would be nicer if 46 | this wasn't a fixed number */ 47 | int32_t type; 48 | } LADSPA_Control_Data; 49 | typedef struct LADSPA_Control_ { 50 | uint32_t length; 51 | uint32_t id; 52 | uint32_t channels; 53 | uint32_t num_controls; 54 | int32_t input_index; 55 | int32_t output_index; 56 | LADSPA_Control_Data control[]; 57 | } LADSPA_Control; 58 | LADSPA_Control * LADSPAcontrolMMAP(const LADSPA_Descriptor *psDescriptor, 59 | const char *controls_filename, unsigned int channels); 60 | void LADSPAcontrolUnMMAP(LADSPA_Control *control); 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Alsaequal is a real-time adjustable equalizer plugin for ALSA. It can 2 | be adjusted using any ALSA compatible mixer, e.g. alsamixergui. 3 | 4 | Alsaequal uses the Eq CAPS LADSPA Plugin for audio processing, actually 5 | alsaequal is a generic LADSPA plugin interface with real-time access to 6 | the LADSPA controls (the LADSPA plugin included with alsa doesn't allow 7 | for real-time controls) but it was developed for and only tested with 8 | Eq CAPS LADSPA plugin. You are welcome to try it with other plugins, it 9 | may work. Let me know how it goes, you can reach me at 10 | . 11 | 12 | INSTALL: 13 | Download the latest version of the plugin and: 14 | 15 | tar xvjf alsaequal-x.x.tar.bz2 16 | cd alsaequal-x.x 17 | make 18 | sudo make install 19 | 20 | DEPENDANCIES: 21 | - CAPS LADSPA Package -- , it's 22 | available as a package in Ubuntu, i.e. "sudo apt-get install caps" 23 | - ALSA Development headers and alsa-lib -- you may already have it 24 | as part of your linux distro, you can install in Ubuntu with 25 | "sudo apt-get install libasound2-dev" 26 | 27 | 28 | USAGE: 29 | After installing you will have to modify your local .asoundrc alsa 30 | configuration file, adding something like this. If you're not using 31 | sound card 0 modify "plughw:0,0" accordingly. 32 | 33 | ctl.equal { 34 | type equal; 35 | } 36 | 37 | pcm.plugequal { 38 | type equal; 39 | slave.pcm "plughw:0,0"; 40 | } 41 | 42 | pcm.equal{ 43 | type plug; 44 | slave.pcm plugequal; 45 | } 46 | 47 | You can play audio through alsaequal by addressing the plugin by name, e.g.: 48 | mpg123 -a equal 06.Back_In_Black.mp3 49 | 50 | You can adjust the frequency response of the equalizer by using any alsa 51 | mixer, e.g.: alsamixer -D equal 52 | 53 | HELP: 54 | If you need any help just let me know, you can reach me at: 55 | . Please keep in mind that this is 56 | a development release and may have bugs. 57 | 58 | More Advanced Stuff: 59 | If you want to try out alsaequal with other plugins the configuration 60 | (asoundrd) structure follows: 61 | 62 | ctl. { 63 | type equal; 64 | controls -- filename used to store the equalizer settings, 65 | the default is $HOME/.alsaequal.bin 66 | library -- location of the LADSPA library, the default is 67 | "/usr/lib/ladspa/caps.so" 68 | module -- module name within the LADSPA library, the deafault 69 | is "Eq" 70 | channels -- number of channels, the default is 2 71 | } 72 | 73 | pcm. { 74 | type equal; 75 | slave.pcm -- sound card to output to, will probably have to 76 | be a plug since alsaequal only supports 77 | floating point numbers, a "plug" will convert 78 | the data type, outputig directly to hw won't; 79 | controls -- filename used to store the equalizer settings, 80 | the default is $HOME/.alsaequal.bin 81 | library -- location of the LADSPA library, the default is 82 | "/usr/lib/ladspa/caps.so" 83 | module -- module name within the LADSPA library, the deafault 84 | is "Eq" 85 | channels -- number of channels, the default is 2 86 | } 87 | 88 | You will also probably need to pump the data through a plug to change 89 | the format to float, which is all alsaequal supports. 90 | 91 | pcm.{ 92 | type plug; 93 | slave.pcm ; 94 | } 95 | -------------------------------------------------------------------------------- /pcm_equal.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Cooper Street Innovations 3 | * 4 | * 5 | * This library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "ladspa.h" 28 | #include "ladspa_utils.h" 29 | 30 | typedef struct snd_pcm_equal { 31 | snd_pcm_extplug_t ext; 32 | void *library; 33 | const LADSPA_Descriptor *klass; 34 | LADSPA_Control *control_data; 35 | LADSPA_Handle *channel[]; 36 | } snd_pcm_equal_t; 37 | 38 | static inline void interleave(float *src, float *dst, int n, int m) 39 | { 40 | int i, j; 41 | for(i = 0; i < n; i++){ 42 | for(j = 0; j < m; j++){ 43 | dst[i*m + j] = src[i + n*j]; 44 | } 45 | } 46 | } 47 | 48 | static inline void deinterleave(float *src, float *dst, int n, int m) 49 | { 50 | int i, j; 51 | for(i = 0; i < n; i++){ 52 | for(j = 0; j < m; j++){ 53 | dst[i + n*j] = src[i*m + j]; 54 | } 55 | } 56 | } 57 | 58 | static snd_pcm_sframes_t equal_transfer(snd_pcm_extplug_t *ext, 59 | const snd_pcm_channel_area_t *dst_areas, 60 | snd_pcm_uframes_t dst_offset, 61 | const snd_pcm_channel_area_t *src_areas, 62 | snd_pcm_uframes_t src_offset, 63 | snd_pcm_uframes_t size) 64 | { 65 | snd_pcm_equal_t *equal = (snd_pcm_equal_t *)ext; 66 | float *src, *dst; 67 | int j; 68 | 69 | /* Calculate buffer locations */ 70 | src = (float*)(src_areas->addr + 71 | (src_areas->first + src_areas->step * src_offset)/8); 72 | dst = (float*)(dst_areas->addr + 73 | (dst_areas->first + dst_areas->step * dst_offset)/8); 74 | 75 | /* NOTE: swap source and destination memory space when deinterleaved. 76 | then swap it back during the interleave call below */ 77 | deinterleave(src, dst, size, equal->control_data->channels); 78 | 79 | for(j = 0; j < equal->control_data->channels; j++) { 80 | equal->klass->connect_port(equal->channel[j], 81 | equal->control_data->input_index, 82 | dst + j*size); 83 | equal->klass->connect_port(equal->channel[j], 84 | equal->control_data->output_index, 85 | src + j*size); 86 | equal->klass->run(equal->channel[j], size); 87 | } 88 | 89 | interleave(src, dst, size, equal->control_data->channels); 90 | 91 | return size; 92 | } 93 | 94 | static int equal_close(snd_pcm_extplug_t *ext) { 95 | snd_pcm_equal_t *equal = ext->private_data; 96 | int i; 97 | for (i = 0; i < equal->control_data->channels; i++) { 98 | if(equal->klass->deactivate) { 99 | equal->klass->deactivate(equal->channel[i]); 100 | } 101 | /* TODO: Figure out why this segfaults */ 102 | /* if(equal->klass->cleanup) { 103 | equal->klass->cleanup(equal->channel[i]); 104 | } */ 105 | } 106 | LADSPAcontrolUnMMAP(equal->control_data); 107 | LADSPAunload(equal->library); 108 | free(equal); 109 | return 0; 110 | } 111 | 112 | static int equal_init(snd_pcm_extplug_t *ext) 113 | { 114 | snd_pcm_equal_t *equal = (snd_pcm_equal_t *)ext; 115 | int i, j; 116 | 117 | /* Instantiate a LADSPA Plugin for each channel */ 118 | for(i = 0; i < equal->control_data->channels; i++) { 119 | equal->channel[i] = equal->klass->instantiate( 120 | equal->klass, ext->rate); 121 | if(equal->channel[i] == NULL) { 122 | return -1; 123 | } 124 | if(equal->klass->activate) { 125 | equal->klass->activate(equal->channel[i]); 126 | } 127 | } 128 | 129 | /* Connect controls to the LADSPA Plugin */ 130 | for(j = 0; j < equal->control_data->channels; j++) { 131 | for(i = 0; i < equal->control_data->num_controls; i++) { 132 | equal->klass->connect_port(equal->channel[j], 133 | equal->control_data->control[i].index, 134 | &equal->control_data->control[i].data[j]); 135 | } 136 | } 137 | 138 | return 0; 139 | } 140 | 141 | static snd_pcm_extplug_callback_t equal_callback = { 142 | .transfer = equal_transfer, 143 | .init = equal_init, 144 | .close = equal_close, 145 | }; 146 | 147 | SND_PCM_PLUGIN_DEFINE_FUNC(equal) 148 | { 149 | snd_config_iterator_t i, next; 150 | snd_pcm_equal_t *equal; 151 | snd_config_t *sconf = NULL; 152 | const char *controls = ".alsaequal.bin"; 153 | const char *library = "caps.so"; 154 | const char *module = "Eq10"; 155 | long channels = 2; 156 | int err; 157 | 158 | /* Parse configuration options from asoundrc */ 159 | snd_config_for_each(i, next, conf) { 160 | snd_config_t *n = snd_config_iterator_entry(i); 161 | const char *id; 162 | if (snd_config_get_id(n, &id) < 0) 163 | continue; 164 | if (strcmp(id, "comment") == 0 || strcmp(id, "type") == 0 || strcmp(id, "hint") == 0) 165 | continue; 166 | if (strcmp(id, "slave") == 0) { 167 | sconf = n; 168 | continue; 169 | } 170 | if (strcmp(id, "controls") == 0) { 171 | snd_config_get_string(n, &controls); 172 | continue; 173 | } 174 | if (strcmp(id, "library") == 0) { 175 | snd_config_get_string(n, &library); 176 | continue; 177 | } 178 | if (strcmp(id, "module") == 0) { 179 | snd_config_get_string(n, &module); 180 | continue; 181 | } 182 | if (strcmp(id, "channels") == 0) { 183 | snd_config_get_integer(n, &channels); 184 | if(channels < 1) { 185 | SNDERR("channels < 1"); 186 | return -EINVAL; 187 | } 188 | continue; 189 | } 190 | SNDERR("Unknown field %s", id); 191 | return -EINVAL; 192 | } 193 | 194 | /* Make sure we have a slave and control devices defined */ 195 | if (! sconf) { 196 | SNDERR("No slave configuration for equal pcm"); 197 | return -EINVAL; 198 | } 199 | 200 | /* Intialize the local object data */ 201 | equal = calloc(1, sizeof(*equal) + channels*sizeof(LADSPA_Handle *)); 202 | if (equal == NULL) 203 | return -ENOMEM; 204 | 205 | equal->ext.version = SND_PCM_EXTPLUG_VERSION; 206 | equal->ext.name = "alsaequal"; 207 | equal->ext.callback = &equal_callback; 208 | equal->ext.private_data = equal; 209 | 210 | /* Open the LADSPA Plugin */ 211 | equal->library = LADSPAload(library); 212 | if(equal->library == NULL) { 213 | return -1; 214 | } 215 | 216 | equal->klass = LADSPAfind(equal->library, library, module); 217 | if(equal->klass == NULL) { 218 | return -1; 219 | } 220 | 221 | /* Create the ALSA External Plugin */ 222 | err = snd_pcm_extplug_create(&equal->ext, name, root, sconf, stream, mode); 223 | if (err < 0) { 224 | return err; 225 | } 226 | 227 | /* MMAP to the controls file */ 228 | equal->control_data = LADSPAcontrolMMAP(equal->klass, controls, channels); 229 | if(equal->control_data == NULL) { 230 | return -1; 231 | } 232 | 233 | /* Make sure that the control file makes sense */ 234 | if(equal->klass->PortDescriptors[equal->control_data->input_index] != 235 | (LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO)) { 236 | SNDERR("Problem with control file %s.", controls); 237 | return -1; 238 | } 239 | if(equal->klass->PortDescriptors[equal->control_data->output_index] != 240 | (LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO)) { 241 | SNDERR("Problem with control file %s.", controls); 242 | return -1; 243 | } 244 | 245 | /* Set PCM Contraints */ 246 | snd_pcm_extplug_set_param_minmax(&equal->ext, 247 | SND_PCM_EXTPLUG_HW_CHANNELS, 248 | equal->control_data->channels, 249 | equal->control_data->channels); 250 | snd_pcm_extplug_set_slave_param(&equal->ext, 251 | SND_PCM_EXTPLUG_HW_CHANNELS, 252 | equal->control_data->channels); 253 | snd_pcm_extplug_set_param(&equal->ext, 254 | SND_PCM_EXTPLUG_HW_FORMAT, SND_PCM_FORMAT_FLOAT); 255 | snd_pcm_extplug_set_slave_param(&equal->ext, 256 | SND_PCM_EXTPLUG_HW_FORMAT, SND_PCM_FORMAT_FLOAT); 257 | 258 | *pcmp = equal->ext.pcm; 259 | 260 | return 0; 261 | 262 | } 263 | 264 | SND_PCM_PLUGIN_SYMBOL(equal); 265 | 266 | -------------------------------------------------------------------------------- /ctl_equal.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Cooper Street Innovations 3 | * 4 | * 5 | * This library is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include "ladspa.h" 25 | #include "ladspa_utils.h" 26 | 27 | typedef struct snd_ctl_equal_control { 28 | long min; 29 | long max; 30 | char *name; 31 | } snd_ctl_equal_control_t; 32 | 33 | typedef struct snd_ctl_equal { 34 | snd_ctl_ext_t ext; 35 | void *library; 36 | const LADSPA_Descriptor *klass; 37 | int num_input_controls; 38 | LADSPA_Control *control_data; 39 | snd_ctl_equal_control_t *control_info; 40 | } snd_ctl_equal_t; 41 | 42 | static void equal_close(snd_ctl_ext_t *ext) 43 | { 44 | snd_ctl_equal_t *equal = ext->private_data; 45 | int i; 46 | for (i = 0; i < equal->num_input_controls; i++) { 47 | free(equal->control_info[i].name); 48 | } 49 | free(equal->control_info); 50 | LADSPAcontrolUnMMAP(equal->control_data); 51 | LADSPAunload(equal->library); 52 | free(equal); 53 | } 54 | 55 | static int equal_elem_count(snd_ctl_ext_t *ext) 56 | { 57 | snd_ctl_equal_t *equal = ext->private_data; 58 | return equal->num_input_controls; 59 | } 60 | 61 | static int equal_elem_list(snd_ctl_ext_t *ext, unsigned int offset, 62 | snd_ctl_elem_id_t *id) 63 | { 64 | snd_ctl_equal_t *equal = ext->private_data; 65 | snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER); 66 | snd_ctl_elem_id_set_name(id, equal->control_info[offset].name); 67 | snd_ctl_elem_id_set_device(id, offset); 68 | return 0; 69 | } 70 | 71 | static snd_ctl_ext_key_t equal_find_elem(snd_ctl_ext_t *ext, 72 | const snd_ctl_elem_id_t *id) 73 | { 74 | snd_ctl_equal_t *equal = ext->private_data; 75 | const char *name; 76 | unsigned int i, key; 77 | 78 | name = snd_ctl_elem_id_get_name(id); 79 | 80 | for (i = 0; i < equal->num_input_controls; i++) { 81 | key = i; 82 | if (!strcmp(name, equal->control_info[key].name)) { 83 | return key; 84 | } 85 | } 86 | 87 | return SND_CTL_EXT_KEY_NOT_FOUND; 88 | } 89 | 90 | static int equal_get_attribute(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, 91 | int *type, unsigned int *acc, unsigned int *count) 92 | { 93 | snd_ctl_equal_t *equal = ext->private_data; 94 | *type = SND_CTL_ELEM_TYPE_INTEGER; 95 | *acc = SND_CTL_EXT_ACCESS_READWRITE; 96 | *count = equal->control_data->channels; 97 | return 0; 98 | } 99 | 100 | static int equal_get_integer_info(snd_ctl_ext_t *ext, 101 | snd_ctl_ext_key_t key, long *imin, long *imax, long *istep) 102 | { 103 | *istep = 1; 104 | *imin = 0; 105 | *imax = 100; 106 | return 0; 107 | } 108 | 109 | static int equal_read_integer(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, 110 | long *value) 111 | { 112 | snd_ctl_equal_t *equal = ext->private_data; 113 | int i; 114 | 115 | for(i = 0; i < equal->control_data->channels; i++) { 116 | value[i] = ((equal->control_data->control[key].data[i] - 117 | equal->control_info[key].min)/ 118 | (equal->control_info[key].max- 119 | equal->control_info[key].min))*100; 120 | } 121 | 122 | return equal->control_data->channels*sizeof(long); 123 | } 124 | 125 | static int equal_write_integer(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, 126 | long *value) 127 | { 128 | snd_ctl_equal_t *equal = ext->private_data; 129 | int i; 130 | float setting; 131 | 132 | for(i = 0; i < equal->control_data->channels; i++) { 133 | setting = value[i]; 134 | equal->control_data->control[key].data[i] = (setting/100)* 135 | (equal->control_info[key].max- 136 | equal->control_info[key].min)+ 137 | equal->control_info[key].min; 138 | } 139 | 140 | return 1; 141 | } 142 | 143 | static int equal_read_event(snd_ctl_ext_t *ext ATTRIBUTE_UNUSED, 144 | snd_ctl_elem_id_t *id ATTRIBUTE_UNUSED, 145 | unsigned int *event_mask ATTRIBUTE_UNUSED) 146 | { 147 | return -EAGAIN; 148 | } 149 | 150 | static snd_ctl_ext_callback_t equal_ext_callback = { 151 | .close = equal_close, 152 | .elem_count = equal_elem_count, 153 | .elem_list = equal_elem_list, 154 | .find_elem = equal_find_elem, 155 | .get_attribute = equal_get_attribute, 156 | .get_integer_info = equal_get_integer_info, 157 | .read_integer = equal_read_integer, 158 | .write_integer = equal_write_integer, 159 | .read_event = equal_read_event, 160 | }; 161 | 162 | SND_CTL_PLUGIN_DEFINE_FUNC(equal) 163 | { 164 | /* TODO: Plug all of the memory leaks if these some initialization 165 | failure */ 166 | snd_config_iterator_t it, next; 167 | snd_ctl_equal_t *equal; 168 | const char *controls = ".alsaequal.bin"; 169 | const char *library = "caps.so"; 170 | const char *module = "Eq10"; 171 | long channels = 2; 172 | const char *sufix = " Playback Volume"; 173 | int err, i, index; 174 | 175 | /* Parse configuration options from asoundrc */ 176 | snd_config_for_each(it, next, conf) { 177 | snd_config_t *n = snd_config_iterator_entry(it); 178 | const char *id; 179 | if (snd_config_get_id(n, &id) < 0) 180 | continue; 181 | if (strcmp(id, "comment") == 0 || strcmp(id, "type") == 0) 182 | continue; 183 | if (strcmp(id, "controls") == 0) { 184 | snd_config_get_string(n, &controls); 185 | continue; 186 | } 187 | if (strcmp(id, "library") == 0) { 188 | snd_config_get_string(n, &library); 189 | continue; 190 | } 191 | if (strcmp(id, "module") == 0) { 192 | snd_config_get_string(n, &module); 193 | continue; 194 | } 195 | if (strcmp(id, "channels") == 0) { 196 | snd_config_get_integer(n, &channels); 197 | if(channels < 1) { 198 | SNDERR("channels < 1"); 199 | return -EINVAL; 200 | } 201 | continue; 202 | } 203 | SNDERR("Unknown field %s", id); 204 | return -EINVAL; 205 | } 206 | 207 | /* Intialize the local object data */ 208 | equal = calloc(1, sizeof(*equal)); 209 | if (equal == NULL) 210 | return -ENOMEM; 211 | 212 | equal->ext.version = SND_CTL_EXT_VERSION; 213 | equal->ext.card_idx = 0; 214 | equal->ext.poll_fd = -1; 215 | equal->ext.callback = &equal_ext_callback; 216 | equal->ext.private_data = equal; 217 | 218 | /* Open the LADSPA Plugin */ 219 | equal->library = LADSPAload(library); 220 | if(equal->library == NULL) { 221 | return -1; 222 | } 223 | 224 | equal->klass = LADSPAfind(equal->library, library, module); 225 | if(equal->klass == NULL) { 226 | return -1; 227 | } 228 | 229 | /* Import data from the LADSPA Plugin */ 230 | strncpy(equal->ext.id, equal->klass->Label, sizeof(equal->ext.id)); 231 | strncpy(equal->ext.driver, "LADSPA Plugin", sizeof(equal->ext.driver)); 232 | strncpy(equal->ext.name, equal->klass->Label, sizeof(equal->ext.name)); 233 | strncpy(equal->ext.longname, equal->klass->Name, 234 | sizeof(equal->ext.longname)); 235 | strncpy(equal->ext.mixername, "alsaequal", sizeof(equal->ext.mixername)); 236 | 237 | /* Create the ALSA External Plugin */ 238 | err = snd_ctl_ext_create(&equal->ext, name, SND_CTL_NONBLOCK); 239 | if (err < 0) { 240 | return -1; 241 | } 242 | 243 | /* MMAP to the controls file */ 244 | equal->control_data = LADSPAcontrolMMAP(equal->klass, controls, channels); 245 | if(equal->control_data == NULL) { 246 | return -1; 247 | } 248 | 249 | equal->num_input_controls = 0; 250 | for(i = 0; i < equal->control_data->num_controls; i++) { 251 | if(equal->control_data->control[i].type == LADSPA_CNTRL_INPUT) { 252 | equal->num_input_controls++; 253 | } 254 | } 255 | 256 | /* Pull in data from controls file */ 257 | equal->control_info = malloc( 258 | sizeof(snd_ctl_equal_control_t)*equal->num_input_controls); 259 | if(equal->control_info == NULL) { 260 | return -1; 261 | } 262 | 263 | for(i = 0; i < equal->num_input_controls; i++) { 264 | if(equal->control_data->control[i].type == LADSPA_CNTRL_INPUT) { 265 | index = equal->control_data->control[i].index; 266 | if(equal->klass->PortDescriptors[index] & 267 | (LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL) == 0) { 268 | SNDERR("Problem with control file %s, %d.", controls, index); 269 | return -1; 270 | } 271 | equal->control_info[i].min = 272 | equal->klass->PortRangeHints[index].LowerBound; 273 | equal->control_info[i].max = 274 | equal->klass->PortRangeHints[index].UpperBound; 275 | equal->control_info[i].name = malloc( 276 | strlen(equal->klass->PortNames[index]) + 277 | strlen(sufix) + 6); 278 | if(equal->control_info[i].name == NULL) { 279 | return -1; 280 | } 281 | sprintf(equal->control_info[i].name, "%02d. %s%s", 282 | index, equal->klass->PortNames[index], sufix); 283 | } 284 | } 285 | 286 | /* Make sure that the control file makes sense */ 287 | if(equal->klass->PortDescriptors[equal->control_data->input_index] != 288 | (LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO)) { 289 | SNDERR("Problem with control file %s.", controls); 290 | return -1; 291 | } 292 | if(equal->klass->PortDescriptors[equal->control_data->output_index] != 293 | (LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO)) { 294 | SNDERR("Problem with control file %s.", controls); 295 | return -1; 296 | } 297 | 298 | *handlep = equal->ext.handle; 299 | return 0; 300 | 301 | } 302 | 303 | SND_CTL_PLUGIN_SYMBOL(equal); 304 | -------------------------------------------------------------------------------- /ladspa_utils.c: -------------------------------------------------------------------------------- 1 | /* ------------------------------------------------------------------ 2 | Free software by Richard W.E. Furse. Do with as you will. No 3 | warranty. 4 | ------------------------------------------------------------------*/ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "ladspa.h" 18 | #include "ladspa_utils.h" 19 | 20 | /* ------------------------------------------------------------------ */ 21 | 22 | /* This function provides a wrapping of dlopen(). When the filename is 23 | not an absolute path (i.e. does not begin with / character), this 24 | routine will search the LADSPA_PATH for the file. */ 25 | static void * 26 | dlopenLADSPA(const char * pcFilename, int iFlag) { 27 | 28 | char * pcBuffer; 29 | const char * pcEnd; 30 | const char * pcLADSPAPath; 31 | const char * pcStart; 32 | int iEndsInSO; 33 | int iNeedSlash; 34 | size_t iFilenameLength; 35 | void * pvResult; 36 | 37 | iFilenameLength = strlen(pcFilename); 38 | pvResult = NULL; 39 | 40 | if (pcFilename[0] == '/') { 41 | 42 | /* The filename is absolute. Assume the user knows what he/she is 43 | doing and simply dlopen() it. */ 44 | 45 | pvResult = dlopen(pcFilename, iFlag); 46 | if (pvResult != NULL) 47 | return pvResult; 48 | 49 | } 50 | else { 51 | 52 | /* If the filename is not absolute then we wish to check along the 53 | LADSPA_PATH path to see if we can find the file there. We do 54 | NOT call dlopen() directly as this would find plugins on the 55 | LD_LIBRARY_PATH, whereas the LADSPA_PATH is the correct place 56 | to search. */ 57 | 58 | pcLADSPAPath = getenv("LADSPA_PATH"); 59 | 60 | if (pcLADSPAPath) { 61 | 62 | pcStart = pcLADSPAPath; 63 | while (*pcStart != '\0') { 64 | pcEnd = pcStart; 65 | while (*pcEnd != ':' && *pcEnd != '\0') 66 | pcEnd++; 67 | 68 | pcBuffer = malloc(iFilenameLength + 2 + (pcEnd - pcStart)); 69 | if (pcEnd > pcStart) 70 | strncpy(pcBuffer, pcStart, pcEnd - pcStart); 71 | iNeedSlash = 0; 72 | if (pcEnd > pcStart) 73 | if (*(pcEnd - 1) != '/') { 74 | iNeedSlash = 1; 75 | pcBuffer[pcEnd - pcStart] = '/'; 76 | } 77 | strcpy(pcBuffer + iNeedSlash + (pcEnd - pcStart), pcFilename); 78 | 79 | pvResult = dlopen(pcBuffer, iFlag); 80 | 81 | free(pcBuffer); 82 | if (pvResult != NULL) 83 | return pvResult; 84 | 85 | pcStart = pcEnd; 86 | if (*pcStart == ':') 87 | pcStart++; 88 | } 89 | } 90 | } 91 | 92 | /* As a last ditch effort, check if filename does not end with 93 | ".so". In this case, add this suffix and recurse. */ 94 | iEndsInSO = 0; 95 | if (iFilenameLength > 3) 96 | iEndsInSO = (strcmp(pcFilename + iFilenameLength - 3, ".so") == 0); 97 | if (!iEndsInSO) { 98 | pcBuffer = malloc(iFilenameLength + 4); 99 | strcpy(pcBuffer, pcFilename); 100 | strcat(pcBuffer, ".so"); 101 | pvResult = dlopenLADSPA(pcBuffer, iFlag); 102 | free(pcBuffer); 103 | } 104 | 105 | if (pvResult != NULL) 106 | return pvResult; 107 | 108 | /* If nothing has worked, then at least we can make sure we set the 109 | correct error message - and this should correspond to a call to 110 | dlopen() with the actual filename requested. The dlopen() manual 111 | page does not specify whether the first or last error message 112 | will be kept when multiple calls are made to dlopen(). We've 113 | covered the former case - now we can handle the latter by calling 114 | dlopen() again here. */ 115 | return dlopen(pcFilename, iFlag); 116 | } 117 | 118 | /* ------------------------------------------------------------------ */ 119 | 120 | void * LADSPAload(const char * pcPluginFilename) { 121 | 122 | void * pvPluginHandle; 123 | 124 | pvPluginHandle = dlopenLADSPA(pcPluginFilename, RTLD_NOW); 125 | if (!pvPluginHandle) { 126 | fprintf(stderr, 127 | "Failed to load plugin \"%s\": %s\n", 128 | pcPluginFilename, 129 | dlerror()); 130 | exit(1); 131 | } 132 | 133 | return pvPluginHandle; 134 | } 135 | 136 | 137 | void LADSPAunload(void * pvLADSPAPluginLibrary) { 138 | dlclose(pvLADSPAPluginLibrary); 139 | } 140 | 141 | const LADSPA_Descriptor * LADSPAfind(void * pvLADSPAPluginLibrary, 142 | const char * pcPluginLibraryFilename, 143 | const char * pcPluginLabel) { 144 | 145 | const LADSPA_Descriptor * psDescriptor; 146 | LADSPA_Descriptor_Function pfDescriptorFunction; 147 | unsigned long lPluginIndex; 148 | 149 | dlerror(); 150 | pfDescriptorFunction 151 | = (LADSPA_Descriptor_Function)dlsym(pvLADSPAPluginLibrary, 152 | "ladspa_descriptor"); 153 | if (!pfDescriptorFunction) { 154 | const char * pcError = dlerror(); 155 | if (pcError) { 156 | fprintf(stderr, 157 | "Unable to find ladspa_descriptor() function in plugin " 158 | "library file \"%s\": %s.\n" 159 | "Are you sure this is a LADSPA plugin file?\n", 160 | pcPluginLibraryFilename, 161 | pcError); 162 | exit(1); 163 | } 164 | } 165 | 166 | for (lPluginIndex = 0;; lPluginIndex++) { 167 | psDescriptor = pfDescriptorFunction(lPluginIndex); 168 | if (psDescriptor == NULL) { 169 | fprintf(stderr, 170 | "Unable to find label \"%s\" in plugin library file \"%s\".\n", 171 | pcPluginLabel, 172 | pcPluginLibraryFilename); 173 | exit(1); 174 | } 175 | if (strcmp(psDescriptor->Label, pcPluginLabel) == 0) 176 | return psDescriptor; 177 | } 178 | } 179 | 180 | /* ------------------------------------------------------------------ */ 181 | 182 | int LADSPADefault(const LADSPA_PortRangeHint * psPortRangeHint, 183 | const unsigned long lSampleRate, 184 | LADSPA_Data * pfResult) { 185 | 186 | int iHintDescriptor; 187 | 188 | iHintDescriptor = psPortRangeHint->HintDescriptor & LADSPA_HINT_DEFAULT_MASK; 189 | 190 | switch (iHintDescriptor & LADSPA_HINT_DEFAULT_MASK) { 191 | case LADSPA_HINT_DEFAULT_NONE: 192 | return -1; 193 | case LADSPA_HINT_DEFAULT_MINIMUM: 194 | *pfResult = psPortRangeHint->LowerBound; 195 | if (LADSPA_IS_HINT_SAMPLE_RATE(psPortRangeHint->HintDescriptor)) 196 | *pfResult *= lSampleRate; 197 | return 0; 198 | case LADSPA_HINT_DEFAULT_LOW: 199 | if (LADSPA_IS_HINT_LOGARITHMIC(iHintDescriptor)) { 200 | *pfResult = exp(log(psPortRangeHint->LowerBound) * 0.75 201 | + log(psPortRangeHint->UpperBound) * 0.25); 202 | } 203 | else { 204 | *pfResult = (psPortRangeHint->LowerBound * 0.75 205 | + psPortRangeHint->UpperBound * 0.25); 206 | } 207 | if (LADSPA_IS_HINT_SAMPLE_RATE(psPortRangeHint->HintDescriptor)) 208 | *pfResult *= lSampleRate; 209 | return 0; 210 | case LADSPA_HINT_DEFAULT_MIDDLE: 211 | if (LADSPA_IS_HINT_LOGARITHMIC(iHintDescriptor)) { 212 | *pfResult = sqrt(psPortRangeHint->LowerBound 213 | * psPortRangeHint->UpperBound); 214 | } 215 | else { 216 | *pfResult = 0.5 * (psPortRangeHint->LowerBound 217 | + psPortRangeHint->UpperBound); 218 | } 219 | if (LADSPA_IS_HINT_SAMPLE_RATE(psPortRangeHint->HintDescriptor)) 220 | *pfResult *= lSampleRate; 221 | return 0; 222 | case LADSPA_HINT_DEFAULT_HIGH: 223 | if (LADSPA_IS_HINT_LOGARITHMIC(iHintDescriptor)) { 224 | *pfResult = exp(log(psPortRangeHint->LowerBound) * 0.25 225 | + log(psPortRangeHint->UpperBound) * 0.75); 226 | } 227 | else { 228 | *pfResult = (psPortRangeHint->LowerBound * 0.25 229 | + psPortRangeHint->UpperBound * 0.75); 230 | } 231 | if (LADSPA_IS_HINT_SAMPLE_RATE(psPortRangeHint->HintDescriptor)) 232 | *pfResult *= lSampleRate; 233 | return 0; 234 | case LADSPA_HINT_DEFAULT_MAXIMUM: 235 | *pfResult = psPortRangeHint->UpperBound; 236 | if (LADSPA_IS_HINT_SAMPLE_RATE(psPortRangeHint->HintDescriptor)) 237 | *pfResult *= lSampleRate; 238 | return 0; 239 | case LADSPA_HINT_DEFAULT_0: 240 | *pfResult = 0; 241 | return 0; 242 | case LADSPA_HINT_DEFAULT_1: 243 | *pfResult = 1; 244 | return 0; 245 | case LADSPA_HINT_DEFAULT_100: 246 | *pfResult = 100; 247 | return 0; 248 | case LADSPA_HINT_DEFAULT_440: 249 | *pfResult = 440; 250 | return 0; 251 | } 252 | 253 | /* We don't recognise this default flag. It's probably from a more 254 | recent version of LADSPA. */ 255 | return -1; 256 | } 257 | 258 | /* ------------------------------------------------------------------ */ 259 | 260 | void LADSPAcontrolUnMMAP(LADSPA_Control *control) 261 | { 262 | munmap(control, control->length); 263 | } 264 | 265 | LADSPA_Control * LADSPAcontrolMMAP(const LADSPA_Descriptor *psDescriptor, 266 | const char *controls_filename, unsigned int channels) 267 | { 268 | const char * homePath; 269 | char *filename; 270 | unsigned long i, j, num_controls, index; 271 | LADSPA_Control *default_controls; 272 | LADSPA_Control *ptr; 273 | int fd; 274 | unsigned long length; 275 | 276 | if(channels > 16) { 277 | fprintf(stderr, "Can only control a maximum of 16 channels.\n"); 278 | return NULL; 279 | } 280 | 281 | /* Create config filename, if no path specified store in home directory */ 282 | if (controls_filename[0] == '/') { 283 | filename = malloc(strlen(controls_filename) + 1); 284 | if (filename==NULL) { 285 | return NULL; 286 | } 287 | sprintf(filename, "%s", controls_filename); 288 | } else { 289 | homePath = getenv("HOME"); 290 | if (homePath==NULL) { 291 | return NULL; 292 | } 293 | filename = malloc(strlen(controls_filename) + strlen(homePath) + 2); 294 | if (filename==NULL) { 295 | return NULL; 296 | } 297 | sprintf(filename, "%s/%s", homePath, controls_filename); 298 | } 299 | 300 | /* Count the number of controls */ 301 | num_controls = 0; 302 | for(i = 0; i < psDescriptor->PortCount; i++) { 303 | if(psDescriptor->PortDescriptors[i]&LADSPA_PORT_CONTROL) { 304 | num_controls++; 305 | } 306 | } 307 | 308 | if(num_controls == 0) { 309 | fprintf(stderr, "No Controls on LADSPA Module.\n"); 310 | return NULL; 311 | } 312 | 313 | /* Calculate the required file-size */ 314 | length = sizeof(LADSPA_Control) + 315 | num_controls*sizeof(LADSPA_Control_Data) + 316 | num_controls*sizeof(LADSPA_Data)*channels; 317 | 318 | /* Open config file */ 319 | fd = open(filename, O_RDWR); 320 | if(fd < 0) { 321 | if(errno == ENOENT){ 322 | /* If the file doesn't exist create it and populate 323 | it with default data. */ 324 | fd = open(filename, O_RDWR | O_CREAT, 0664); 325 | if(fd < 0) { 326 | fprintf(stderr, "Failed to open controls file:%s.\n", 327 | filename); 328 | free(filename); 329 | return NULL; 330 | } 331 | /* Create default controls stucture */ 332 | default_controls = malloc(length); 333 | if(default_controls == NULL) { 334 | free(filename); 335 | return NULL; 336 | } 337 | default_controls->length = length; 338 | default_controls->id = psDescriptor->UniqueID; 339 | default_controls->channels = channels; 340 | default_controls->num_controls = num_controls; 341 | default_controls->input_index = -1; 342 | default_controls->output_index = -1; 343 | for(i = 0, index=0; i < psDescriptor->PortCount; i++) { 344 | if(psDescriptor->PortDescriptors[i]&LADSPA_PORT_CONTROL) { 345 | default_controls->control[index].index = i; 346 | LADSPADefault(&psDescriptor->PortRangeHints[i], 44100, 347 | &default_controls->control[index].data[0]); 348 | for(j = 1; j < channels; j++) { 349 | default_controls->control[index].data[j] = 350 | default_controls->control[index].data[0]; 351 | } 352 | if(psDescriptor->PortDescriptors[i]&LADSPA_PORT_INPUT) { 353 | default_controls->control[index].type = LADSPA_CNTRL_INPUT; 354 | } else { 355 | default_controls->control[index].type = LADSPA_CNTRL_OUTPUT; 356 | } 357 | index++; 358 | } else if(psDescriptor->PortDescriptors[i] == 359 | (LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO)) { 360 | default_controls->input_index = i; 361 | } else if(psDescriptor->PortDescriptors[i] == 362 | (LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO)) { 363 | default_controls->output_index = i; 364 | } 365 | } 366 | if((default_controls->output_index == -1) || 367 | (default_controls->input_index == -1)) { 368 | fprintf(stderr, 369 | "LADSPA Plugin must have one audio channel\n"); 370 | free(default_controls); 371 | free(filename); 372 | return NULL; 373 | } 374 | /* Write the deafult data to the file. */ 375 | if(write(fd, default_controls, length) < 0) { 376 | free(default_controls); 377 | free(filename); 378 | return NULL; 379 | } 380 | free(default_controls); 381 | } else { 382 | free(filename); 383 | return NULL; 384 | } 385 | } 386 | 387 | /* MMap Configuration File */ 388 | ptr = (LADSPA_Control*)mmap(NULL, length, 389 | PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); 390 | close (fd); 391 | 392 | if(ptr == MAP_FAILED) { 393 | free(filename); 394 | return NULL; 395 | } 396 | 397 | /* Make sure we're mapped to the right file type. */ 398 | if(ptr->length != length) { 399 | fprintf(stderr, "%s is the wrong length.\n", 400 | filename); 401 | LADSPAcontrolUnMMAP(ptr); 402 | free(filename); 403 | return NULL; 404 | } 405 | 406 | if(ptr->id != psDescriptor->UniqueID) { 407 | fprintf(stderr, "%s is not a control file for ladspa id %" PRId32 ".\n", 408 | filename, ptr->id); 409 | LADSPAcontrolUnMMAP(ptr); 410 | free(filename); 411 | return NULL; 412 | } 413 | 414 | if(ptr->channels != channels) { 415 | fprintf(stderr, "%s is not a control file doesn't have %ud channels.\n", 416 | filename, channels); 417 | LADSPAcontrolUnMMAP(ptr); 418 | free(filename); 419 | return NULL; 420 | } 421 | 422 | free(filename); 423 | return ptr; 424 | } 425 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 2.1, February 1999 3 | 4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | [This is the first released version of the Lesser GPL. It also counts 10 | as the successor of the GNU Library Public License, version 2, hence 11 | the version number 2.1.] 12 | 13 | Preamble 14 | 15 | The licenses for most software are designed to take away your 16 | freedom to share and change it. By contrast, the GNU General Public 17 | Licenses are intended to guarantee your freedom to share and change 18 | free software--to make sure the software is free for all its users. 19 | 20 | This license, the Lesser General Public License, applies to some 21 | specially designated software packages--typically libraries--of the 22 | Free Software Foundation and other authors who decide to use it. You 23 | can use it too, but we suggest you first think carefully about whether 24 | this license or the ordinary General Public License is the better 25 | strategy to use in any particular case, based on the explanations below. 26 | 27 | When we speak of free software, we are referring to freedom of use, 28 | not price. Our General Public Licenses are designed to make sure that 29 | you have the freedom to distribute copies of free software (and charge 30 | for this service if you wish); that you receive source code or can get 31 | it if you want it; that you can change the software and use pieces of 32 | it in new free programs; and that you are informed that you can do 33 | these things. 34 | 35 | To protect your rights, we need to make restrictions that forbid 36 | distributors to deny you these rights or to ask you to surrender these 37 | rights. These restrictions translate to certain responsibilities for 38 | you if you distribute copies of the library or if you modify it. 39 | 40 | For example, if you distribute copies of the library, whether gratis 41 | or for a fee, you must give the recipients all the rights that we gave 42 | you. You must make sure that they, too, receive or can get the source 43 | code. If you link other code with the library, you must provide 44 | complete object files to the recipients, so that they can relink them 45 | with the library after making changes to the library and recompiling 46 | it. And you must show them these terms so they know their rights. 47 | 48 | We protect your rights with a two-step method: (1) we copyright the 49 | library, and (2) we offer you this license, which gives you legal 50 | permission to copy, distribute and/or modify the library. 51 | 52 | To protect each distributor, we want to make it very clear that 53 | there is no warranty for the free library. Also, if the library is 54 | modified by someone else and passed on, the recipients should know 55 | that what they have is not the original version, so that the original 56 | author's reputation will not be affected by problems that might be 57 | introduced by others. 58 | 59 | Finally, software patents pose a constant threat to the existence of 60 | any free program. We wish to make sure that a company cannot 61 | effectively restrict the users of a free program by obtaining a 62 | restrictive license from a patent holder. Therefore, we insist that 63 | any patent license obtained for a version of the library must be 64 | consistent with the full freedom of use specified in this license. 65 | 66 | Most GNU software, including some libraries, is covered by the 67 | ordinary GNU General Public License. This license, the GNU Lesser 68 | General Public License, applies to certain designated libraries, and 69 | is quite different from the ordinary General Public License. We use 70 | this license for certain libraries in order to permit linking those 71 | libraries into non-free programs. 72 | 73 | When a program is linked with a library, whether statically or using 74 | a shared library, the combination of the two is legally speaking a 75 | combined work, a derivative of the original library. The ordinary 76 | General Public License therefore permits such linking only if the 77 | entire combination fits its criteria of freedom. The Lesser General 78 | Public License permits more lax criteria for linking other code with 79 | the library. 80 | 81 | We call this license the "Lesser" General Public License because it 82 | does Less to protect the user's freedom than the ordinary General 83 | Public License. It also provides other free software developers Less 84 | of an advantage over competing non-free programs. These disadvantages 85 | are the reason we use the ordinary General Public License for many 86 | libraries. However, the Lesser license provides advantages in certain 87 | special circumstances. 88 | 89 | For example, on rare occasions, there may be a special need to 90 | encourage the widest possible use of a certain library, so that it becomes 91 | a de-facto standard. To achieve this, non-free programs must be 92 | allowed to use the library. A more frequent case is that a free 93 | library does the same job as widely used non-free libraries. In this 94 | case, there is little to gain by limiting the free library to free 95 | software only, so we use the Lesser General Public License. 96 | 97 | In other cases, permission to use a particular library in non-free 98 | programs enables a greater number of people to use a large body of 99 | free software. For example, permission to use the GNU C Library in 100 | non-free programs enables many more people to use the whole GNU 101 | operating system, as well as its variant, the GNU/Linux operating 102 | system. 103 | 104 | Although the Lesser General Public License is Less protective of the 105 | users' freedom, it does ensure that the user of a program that is 106 | linked with the Library has the freedom and the wherewithal to run 107 | that program using a modified version of the Library. 108 | 109 | The precise terms and conditions for copying, distribution and 110 | modification follow. Pay close attention to the difference between a 111 | "work based on the library" and a "work that uses the library". The 112 | former contains code derived from the library, whereas the latter must 113 | be combined with the library in order to run. 114 | 115 | GNU LESSER GENERAL PUBLIC LICENSE 116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 117 | 118 | 0. This License Agreement applies to any software library or other 119 | program which contains a notice placed by the copyright holder or 120 | other authorized party saying it may be distributed under the terms of 121 | this Lesser General Public License (also called "this License"). 122 | Each licensee is addressed as "you". 123 | 124 | A "library" means a collection of software functions and/or data 125 | prepared so as to be conveniently linked with application programs 126 | (which use some of those functions and data) to form executables. 127 | 128 | The "Library", below, refers to any such software library or work 129 | which has been distributed under these terms. A "work based on the 130 | Library" means either the Library or any derivative work under 131 | copyright law: that is to say, a work containing the Library or a 132 | portion of it, either verbatim or with modifications and/or translated 133 | straightforwardly into another language. (Hereinafter, translation is 134 | included without limitation in the term "modification".) 135 | 136 | "Source code" for a work means the preferred form of the work for 137 | making modifications to it. For a library, complete source code means 138 | all the source code for all modules it contains, plus any associated 139 | interface definition files, plus the scripts used to control compilation 140 | and installation of the library. 141 | 142 | Activities other than copying, distribution and modification are not 143 | covered by this License; they are outside its scope. The act of 144 | running a program using the Library is not restricted, and output from 145 | such a program is covered only if its contents constitute a work based 146 | on the Library (independent of the use of the Library in a tool for 147 | writing it). Whether that is true depends on what the Library does 148 | and what the program that uses the Library does. 149 | 150 | 1. You may copy and distribute verbatim copies of the Library's 151 | complete source code as you receive it, in any medium, provided that 152 | you conspicuously and appropriately publish on each copy an 153 | appropriate copyright notice and disclaimer of warranty; keep intact 154 | all the notices that refer to this License and to the absence of any 155 | warranty; and distribute a copy of this License along with the 156 | Library. 157 | 158 | You may charge a fee for the physical act of transferring a copy, 159 | and you may at your option offer warranty protection in exchange for a 160 | fee. 161 | 162 | 2. You may modify your copy or copies of the Library or any portion 163 | of it, thus forming a work based on the Library, and copy and 164 | distribute such modifications or work under the terms of Section 1 165 | above, provided that you also meet all of these conditions: 166 | 167 | a) The modified work must itself be a software library. 168 | 169 | b) You must cause the files modified to carry prominent notices 170 | stating that you changed the files and the date of any change. 171 | 172 | c) You must cause the whole of the work to be licensed at no 173 | charge to all third parties under the terms of this License. 174 | 175 | d) If a facility in the modified Library refers to a function or a 176 | table of data to be supplied by an application program that uses 177 | the facility, other than as an argument passed when the facility 178 | is invoked, then you must make a good faith effort to ensure that, 179 | in the event an application does not supply such function or 180 | table, the facility still operates, and performs whatever part of 181 | its purpose remains meaningful. 182 | 183 | (For example, a function in a library to compute square roots has 184 | a purpose that is entirely well-defined independent of the 185 | application. Therefore, Subsection 2d requires that any 186 | application-supplied function or table used by this function must 187 | be optional: if the application does not supply it, the square 188 | root function must still compute square roots.) 189 | 190 | These requirements apply to the modified work as a whole. If 191 | identifiable sections of that work are not derived from the Library, 192 | and can be reasonably considered independent and separate works in 193 | themselves, then this License, and its terms, do not apply to those 194 | sections when you distribute them as separate works. But when you 195 | distribute the same sections as part of a whole which is a work based 196 | on the Library, the distribution of the whole must be on the terms of 197 | this License, whose permissions for other licensees extend to the 198 | entire whole, and thus to each and every part regardless of who wrote 199 | it. 200 | 201 | Thus, it is not the intent of this section to claim rights or contest 202 | your rights to work written entirely by you; rather, the intent is to 203 | exercise the right to control the distribution of derivative or 204 | collective works based on the Library. 205 | 206 | In addition, mere aggregation of another work not based on the Library 207 | with the Library (or with a work based on the Library) on a volume of 208 | a storage or distribution medium does not bring the other work under 209 | the scope of this License. 210 | 211 | 3. You may opt to apply the terms of the ordinary GNU General Public 212 | License instead of this License to a given copy of the Library. To do 213 | this, you must alter all the notices that refer to this License, so 214 | that they refer to the ordinary GNU General Public License, version 2, 215 | instead of to this License. (If a newer version than version 2 of the 216 | ordinary GNU General Public License has appeared, then you can specify 217 | that version instead if you wish.) Do not make any other change in 218 | these notices. 219 | 220 | Once this change is made in a given copy, it is irreversible for 221 | that copy, so the ordinary GNU General Public License applies to all 222 | subsequent copies and derivative works made from that copy. 223 | 224 | This option is useful when you wish to copy part of the code of 225 | the Library into a program that is not a library. 226 | 227 | 4. You may copy and distribute the Library (or a portion or 228 | derivative of it, under Section 2) in object code or executable form 229 | under the terms of Sections 1 and 2 above provided that you accompany 230 | it with the complete corresponding machine-readable source code, which 231 | must be distributed under the terms of Sections 1 and 2 above on a 232 | medium customarily used for software interchange. 233 | 234 | If distribution of object code is made by offering access to copy 235 | from a designated place, then offering equivalent access to copy the 236 | source code from the same place satisfies the requirement to 237 | distribute the source code, even though third parties are not 238 | compelled to copy the source along with the object code. 239 | 240 | 5. A program that contains no derivative of any portion of the 241 | Library, but is designed to work with the Library by being compiled or 242 | linked with it, is called a "work that uses the Library". Such a 243 | work, in isolation, is not a derivative work of the Library, and 244 | therefore falls outside the scope of this License. 245 | 246 | However, linking a "work that uses the Library" with the Library 247 | creates an executable that is a derivative of the Library (because it 248 | contains portions of the Library), rather than a "work that uses the 249 | library". The executable is therefore covered by this License. 250 | Section 6 states terms for distribution of such executables. 251 | 252 | When a "work that uses the Library" uses material from a header file 253 | that is part of the Library, the object code for the work may be a 254 | derivative work of the Library even though the source code is not. 255 | Whether this is true is especially significant if the work can be 256 | linked without the Library, or if the work is itself a library. The 257 | threshold for this to be true is not precisely defined by law. 258 | 259 | If such an object file uses only numerical parameters, data 260 | structure layouts and accessors, and small macros and small inline 261 | functions (ten lines or less in length), then the use of the object 262 | file is unrestricted, regardless of whether it is legally a derivative 263 | work. (Executables containing this object code plus portions of the 264 | Library will still fall under Section 6.) 265 | 266 | Otherwise, if the work is a derivative of the Library, you may 267 | distribute the object code for the work under the terms of Section 6. 268 | Any executables containing that work also fall under Section 6, 269 | whether or not they are linked directly with the Library itself. 270 | 271 | 6. As an exception to the Sections above, you may also combine or 272 | link a "work that uses the Library" with the Library to produce a 273 | work containing portions of the Library, and distribute that work 274 | under terms of your choice, provided that the terms permit 275 | modification of the work for the customer's own use and reverse 276 | engineering for debugging such modifications. 277 | 278 | You must give prominent notice with each copy of the work that the 279 | Library is used in it and that the Library and its use are covered by 280 | this License. You must supply a copy of this License. If the work 281 | during execution displays copyright notices, you must include the 282 | copyright notice for the Library among them, as well as a reference 283 | directing the user to the copy of this License. Also, you must do one 284 | of these things: 285 | 286 | a) Accompany the work with the complete corresponding 287 | machine-readable source code for the Library including whatever 288 | changes were used in the work (which must be distributed under 289 | Sections 1 and 2 above); and, if the work is an executable linked 290 | with the Library, with the complete machine-readable "work that 291 | uses the Library", as object code and/or source code, so that the 292 | user can modify the Library and then relink to produce a modified 293 | executable containing the modified Library. (It is understood 294 | that the user who changes the contents of definitions files in the 295 | Library will not necessarily be able to recompile the application 296 | to use the modified definitions.) 297 | 298 | b) Use a suitable shared library mechanism for linking with the 299 | Library. A suitable mechanism is one that (1) uses at run time a 300 | copy of the library already present on the user's computer system, 301 | rather than copying library functions into the executable, and (2) 302 | will operate properly with a modified version of the library, if 303 | the user installs one, as long as the modified version is 304 | interface-compatible with the version that the work was made with. 305 | 306 | c) Accompany the work with a written offer, valid for at 307 | least three years, to give the same user the materials 308 | specified in Subsection 6a, above, for a charge no more 309 | than the cost of performing this distribution. 310 | 311 | d) If distribution of the work is made by offering access to copy 312 | from a designated place, offer equivalent access to copy the above 313 | specified materials from the same place. 314 | 315 | e) Verify that the user has already received a copy of these 316 | materials or that you have already sent this user a copy. 317 | 318 | For an executable, the required form of the "work that uses the 319 | Library" must include any data and utility programs needed for 320 | reproducing the executable from it. However, as a special exception, 321 | the materials to be distributed need not include anything that is 322 | normally distributed (in either source or binary form) with the major 323 | components (compiler, kernel, and so on) of the operating system on 324 | which the executable runs, unless that component itself accompanies 325 | the executable. 326 | 327 | It may happen that this requirement contradicts the license 328 | restrictions of other proprietary libraries that do not normally 329 | accompany the operating system. Such a contradiction means you cannot 330 | use both them and the Library together in an executable that you 331 | distribute. 332 | 333 | 7. You may place library facilities that are a work based on the 334 | Library side-by-side in a single library together with other library 335 | facilities not covered by this License, and distribute such a combined 336 | library, provided that the separate distribution of the work based on 337 | the Library and of the other library facilities is otherwise 338 | permitted, and provided that you do these two things: 339 | 340 | a) Accompany the combined library with a copy of the same work 341 | based on the Library, uncombined with any other library 342 | facilities. This must be distributed under the terms of the 343 | Sections above. 344 | 345 | b) Give prominent notice with the combined library of the fact 346 | that part of it is a work based on the Library, and explaining 347 | where to find the accompanying uncombined form of the same work. 348 | 349 | 8. You may not copy, modify, sublicense, link with, or distribute 350 | the Library except as expressly provided under this License. Any 351 | attempt otherwise to copy, modify, sublicense, link with, or 352 | distribute the Library is void, and will automatically terminate your 353 | rights under this License. However, parties who have received copies, 354 | or rights, from you under this License will not have their licenses 355 | terminated so long as such parties remain in full compliance. 356 | 357 | 9. You are not required to accept this License, since you have not 358 | signed it. However, nothing else grants you permission to modify or 359 | distribute the Library or its derivative works. These actions are 360 | prohibited by law if you do not accept this License. Therefore, by 361 | modifying or distributing the Library (or any work based on the 362 | Library), you indicate your acceptance of this License to do so, and 363 | all its terms and conditions for copying, distributing or modifying 364 | the Library or works based on it. 365 | 366 | 10. Each time you redistribute the Library (or any work based on the 367 | Library), the recipient automatically receives a license from the 368 | original licensor to copy, distribute, link with or modify the Library 369 | subject to these terms and conditions. You may not impose any further 370 | restrictions on the recipients' exercise of the rights granted herein. 371 | You are not responsible for enforcing compliance by third parties with 372 | this License. 373 | 374 | 11. If, as a consequence of a court judgment or allegation of patent 375 | infringement or for any other reason (not limited to patent issues), 376 | conditions are imposed on you (whether by court order, agreement or 377 | otherwise) that contradict the conditions of this License, they do not 378 | excuse you from the conditions of this License. If you cannot 379 | distribute so as to satisfy simultaneously your obligations under this 380 | License and any other pertinent obligations, then as a consequence you 381 | may not distribute the Library at all. For example, if a patent 382 | license would not permit royalty-free redistribution of the Library by 383 | all those who receive copies directly or indirectly through you, then 384 | the only way you could satisfy both it and this License would be to 385 | refrain entirely from distribution of the Library. 386 | 387 | If any portion of this section is held invalid or unenforceable under any 388 | particular circumstance, the balance of the section is intended to apply, 389 | and the section as a whole is intended to apply in other circumstances. 390 | 391 | It is not the purpose of this section to induce you to infringe any 392 | patents or other property right claims or to contest validity of any 393 | such claims; this section has the sole purpose of protecting the 394 | integrity of the free software distribution system which is 395 | implemented by public license practices. Many people have made 396 | generous contributions to the wide range of software distributed 397 | through that system in reliance on consistent application of that 398 | system; it is up to the author/donor to decide if he or she is willing 399 | to distribute software through any other system and a licensee cannot 400 | impose that choice. 401 | 402 | This section is intended to make thoroughly clear what is believed to 403 | be a consequence of the rest of this License. 404 | 405 | 12. If the distribution and/or use of the Library is restricted in 406 | certain countries either by patents or by copyrighted interfaces, the 407 | original copyright holder who places the Library under this License may add 408 | an explicit geographical distribution limitation excluding those countries, 409 | so that distribution is permitted only in or among countries not thus 410 | excluded. In such case, this License incorporates the limitation as if 411 | written in the body of this License. 412 | 413 | 13. The Free Software Foundation may publish revised and/or new 414 | versions of the Lesser General Public License from time to time. 415 | Such new versions will be similar in spirit to the present version, 416 | but may differ in detail to address new problems or concerns. 417 | 418 | Each version is given a distinguishing version number. If the Library 419 | specifies a version number of this License which applies to it and 420 | "any later version", you have the option of following the terms and 421 | conditions either of that version or of any later version published by 422 | the Free Software Foundation. If the Library does not specify a 423 | license version number, you may choose any version ever published by 424 | the Free Software Foundation. 425 | 426 | 14. If you wish to incorporate parts of the Library into other free 427 | programs whose distribution conditions are incompatible with these, 428 | write to the author to ask for permission. For software which is 429 | copyrighted by the Free Software Foundation, write to the Free 430 | Software Foundation; we sometimes make exceptions for this. Our 431 | decision will be guided by the two goals of preserving the free status 432 | of all derivatives of our free software and of promoting the sharing 433 | and reuse of software generally. 434 | 435 | NO WARRANTY 436 | 437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 446 | 447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 456 | DAMAGES. 457 | 458 | END OF TERMS AND CONDITIONS 459 | 460 | How to Apply These Terms to Your New Libraries 461 | 462 | If you develop a new library, and you want it to be of the greatest 463 | possible use to the public, we recommend making it free software that 464 | everyone can redistribute and change. You can do so by permitting 465 | redistribution under these terms (or, alternatively, under the terms of the 466 | ordinary General Public License). 467 | 468 | To apply these terms, attach the following notices to the library. It is 469 | safest to attach them to the start of each source file to most effectively 470 | convey the exclusion of warranty; and each file should have at least the 471 | "copyright" line and a pointer to where the full notice is found. 472 | 473 | 474 | Copyright (C) 475 | 476 | This library is free software; you can redistribute it and/or 477 | modify it under the terms of the GNU Lesser General Public 478 | License as published by the Free Software Foundation; either 479 | version 2.1 of the License, or (at your option) any later version. 480 | 481 | This library is distributed in the hope that it will be useful, 482 | but WITHOUT ANY WARRANTY; without even the implied warranty of 483 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 484 | Lesser General Public License for more details. 485 | 486 | You should have received a copy of the GNU Lesser General Public 487 | License along with this library; if not, write to the Free Software 488 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 489 | 490 | Also add information on how to contact you by electronic and paper mail. 491 | 492 | You should also get your employer (if you work as a programmer) or your 493 | school, if any, to sign a "copyright disclaimer" for the library, if 494 | necessary. Here is a sample; alter the names: 495 | 496 | Yoyodyne, Inc., hereby disclaims all copyright interest in the 497 | library `Frob' (a library for tweaking knobs) written by James Random Hacker. 498 | 499 | , 1 April 1990 500 | Ty Coon, President of Vice 501 | 502 | That's all there is to it! 503 | 504 | 505 | -------------------------------------------------------------------------------- /ladspa.h: -------------------------------------------------------------------------------- 1 | /* ladspa.h 2 | 3 | Linux Audio Developer's Simple Plugin API Version 1.1[provisional, 4 | LGPL]. Copyright (C) 2000-2002 Richard W.E. Furse, Paul 5 | Barton-Davis, Stefan Westerfeld. 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public License 9 | as published by the Free Software Foundation; either version 2.1 of 10 | the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | USA. */ 21 | 22 | #ifndef LADSPA_INCLUDED 23 | #define LADSPA_INCLUDED 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /*****************************************************************************/ 30 | 31 | /* Overview: 32 | 33 | There is a large number of synthesis packages in use or development 34 | on the Linux platform at this time. This API (`The Linux Audio 35 | Developer's Simple Plugin API') attempts to give programmers the 36 | ability to write simple `plugin' audio processors in C/C++ and link 37 | them dynamically (`plug') into a range of these packages (`hosts'). 38 | It should be possible for any host and any plugin to communicate 39 | completely through this interface. 40 | 41 | This API is deliberately short and simple. To achieve compatibility 42 | with a range of promising Linux sound synthesis packages it 43 | attempts to find the `greatest common divisor' in their logical 44 | behaviour. Having said this, certain limiting decisions are 45 | implicit, notably the use of a fixed type (LADSPA_Data) for all 46 | data transfer and absence of a parameterised `initialisation' 47 | phase. See below for the LADSPA_Data typedef. 48 | 49 | Plugins are expected to distinguish between control and audio 50 | data. Plugins have `ports' that are inputs or outputs for audio or 51 | control data and each plugin is `run' for a `block' corresponding 52 | to a short time interval measured in samples. Audio data is 53 | communicated using arrays of LADSPA_Data, allowing a block of audio 54 | to be processed by the plugin in a single pass. Control data is 55 | communicated using single LADSPA_Data values. Control data has a 56 | single value at the start of a call to the `run()' or `run_adding()' 57 | function, and may be considered to remain this value for its 58 | duration. The plugin may assume that all its input and output ports 59 | have been connected to the relevant data location (see the 60 | `connect_port()' function below) before it is asked to run. 61 | 62 | Plugins will reside in shared object files suitable for dynamic 63 | linking by dlopen() and family. The file will provide a number of 64 | `plugin types' that can be used to instantiate actual plugins 65 | (sometimes known as `plugin instances') that can be connected 66 | together to perform tasks. 67 | 68 | This API contains very limited error-handling. */ 69 | 70 | /*****************************************************************************/ 71 | 72 | /* Fundamental data type passed in and out of plugin. This data type 73 | is used to communicate audio samples and control values. It is 74 | assumed that the plugin will work sensibly given any numeric input 75 | value although it may have a preferred range (see hints below). 76 | 77 | For audio it is generally assumed that 1.0f is the `0dB' reference 78 | amplitude and is a `normal' signal level. */ 79 | 80 | typedef float LADSPA_Data; 81 | 82 | /*****************************************************************************/ 83 | 84 | /* Special Plugin Properties: 85 | 86 | Optional features of the plugin type are encapsulated in the 87 | LADSPA_Properties type. This is assembled by ORing individual 88 | properties together. */ 89 | 90 | typedef int LADSPA_Properties; 91 | 92 | /* Property LADSPA_PROPERTY_REALTIME indicates that the plugin has a 93 | real-time dependency (e.g. listens to a MIDI device) and so its 94 | output must not be cached or subject to significant latency. */ 95 | #define LADSPA_PROPERTY_REALTIME 0x1 96 | 97 | /* Property LADSPA_PROPERTY_INPLACE_BROKEN indicates that the plugin 98 | may cease to work correctly if the host elects to use the same data 99 | location for both input and output (see connect_port()). This 100 | should be avoided as enabling this flag makes it impossible for 101 | hosts to use the plugin to process audio `in-place.' */ 102 | #define LADSPA_PROPERTY_INPLACE_BROKEN 0x2 103 | 104 | /* Property LADSPA_PROPERTY_HARD_RT_CAPABLE indicates that the plugin 105 | is capable of running not only in a conventional host but also in a 106 | `hard real-time' environment. To qualify for this the plugin must 107 | satisfy all of the following: 108 | 109 | (1) The plugin must not use malloc(), free() or other heap memory 110 | management within its run() or run_adding() functions. All new 111 | memory used in run() must be managed via the stack. These 112 | restrictions only apply to the run() function. 113 | 114 | (2) The plugin will not attempt to make use of any library 115 | functions with the exceptions of functions in the ANSI standard C 116 | and C maths libraries, which the host is expected to provide. 117 | 118 | (3) The plugin will not access files, devices, pipes, sockets, IPC 119 | or any other mechanism that might result in process or thread 120 | blocking. 121 | 122 | (4) The plugin will take an amount of time to execute a run() or 123 | run_adding() call approximately of form (A+B*SampleCount) where A 124 | and B depend on the machine and host in use. This amount of time 125 | may not depend on input signals or plugin state. The host is left 126 | the responsibility to perform timings to estimate upper bounds for 127 | A and B. */ 128 | #define LADSPA_PROPERTY_HARD_RT_CAPABLE 0x4 129 | 130 | #define LADSPA_IS_REALTIME(x) ((x) & LADSPA_PROPERTY_REALTIME) 131 | #define LADSPA_IS_INPLACE_BROKEN(x) ((x) & LADSPA_PROPERTY_INPLACE_BROKEN) 132 | #define LADSPA_IS_HARD_RT_CAPABLE(x) ((x) & LADSPA_PROPERTY_HARD_RT_CAPABLE) 133 | 134 | /*****************************************************************************/ 135 | 136 | /* Plugin Ports: 137 | 138 | Plugins have `ports' that are inputs or outputs for audio or 139 | data. Ports can communicate arrays of LADSPA_Data (for audio 140 | inputs/outputs) or single LADSPA_Data values (for control 141 | input/outputs). This information is encapsulated in the 142 | LADSPA_PortDescriptor type which is assembled by ORing individual 143 | properties together. 144 | 145 | Note that a port must be an input or an output port but not both 146 | and that a port must be a control or audio port but not both. */ 147 | 148 | typedef int LADSPA_PortDescriptor; 149 | 150 | /* Property LADSPA_PORT_INPUT indicates that the port is an input. */ 151 | #define LADSPA_PORT_INPUT 0x1 152 | 153 | /* Property LADSPA_PORT_OUTPUT indicates that the port is an output. */ 154 | #define LADSPA_PORT_OUTPUT 0x2 155 | 156 | /* Property LADSPA_PORT_CONTROL indicates that the port is a control 157 | port. */ 158 | #define LADSPA_PORT_CONTROL 0x4 159 | 160 | /* Property LADSPA_PORT_AUDIO indicates that the port is a audio 161 | port. */ 162 | #define LADSPA_PORT_AUDIO 0x8 163 | 164 | #define LADSPA_IS_PORT_INPUT(x) ((x) & LADSPA_PORT_INPUT) 165 | #define LADSPA_IS_PORT_OUTPUT(x) ((x) & LADSPA_PORT_OUTPUT) 166 | #define LADSPA_IS_PORT_CONTROL(x) ((x) & LADSPA_PORT_CONTROL) 167 | #define LADSPA_IS_PORT_AUDIO(x) ((x) & LADSPA_PORT_AUDIO) 168 | 169 | /*****************************************************************************/ 170 | 171 | /* Plugin Port Range Hints: 172 | 173 | The host may wish to provide a representation of data entering or 174 | leaving a plugin (e.g. to generate a GUI automatically). To make 175 | this more meaningful, the plugin should provide `hints' to the host 176 | describing the usual values taken by the data. 177 | 178 | Note that these are only hints. The host may ignore them and the 179 | plugin must not assume that data supplied to it is meaningful. If 180 | the plugin receives invalid input data it is expected to continue 181 | to run without failure and, where possible, produce a sensible 182 | output (e.g. a high-pass filter given a negative cutoff frequency 183 | might switch to an all-pass mode). 184 | 185 | Hints are meaningful for all input and output ports but hints for 186 | input control ports are expected to be particularly useful. 187 | 188 | More hint information is encapsulated in the 189 | LADSPA_PortRangeHintDescriptor type which is assembled by ORing 190 | individual hint types together. Hints may require further 191 | LowerBound and UpperBound information. 192 | 193 | All the hint information for a particular port is aggregated in the 194 | LADSPA_PortRangeHint structure. */ 195 | 196 | typedef int LADSPA_PortRangeHintDescriptor; 197 | 198 | /* Hint LADSPA_HINT_BOUNDED_BELOW indicates that the LowerBound field 199 | of the LADSPA_PortRangeHint should be considered meaningful. The 200 | value in this field should be considered the (inclusive) lower 201 | bound of the valid range. If LADSPA_HINT_SAMPLE_RATE is also 202 | specified then the value of LowerBound should be multiplied by the 203 | sample rate. */ 204 | #define LADSPA_HINT_BOUNDED_BELOW 0x1 205 | 206 | /* Hint LADSPA_HINT_BOUNDED_ABOVE indicates that the UpperBound field 207 | of the LADSPA_PortRangeHint should be considered meaningful. The 208 | value in this field should be considered the (inclusive) upper 209 | bound of the valid range. If LADSPA_HINT_SAMPLE_RATE is also 210 | specified then the value of UpperBound should be multiplied by the 211 | sample rate. */ 212 | #define LADSPA_HINT_BOUNDED_ABOVE 0x2 213 | 214 | /* Hint LADSPA_HINT_TOGGLED indicates that the data item should be 215 | considered a Boolean toggle. Data less than or equal to zero should 216 | be considered `off' or `false,' and data above zero should be 217 | considered `on' or `true.' LADSPA_HINT_TOGGLED may not be used in 218 | conjunction with any other hint except LADSPA_HINT_DEFAULT_0 or 219 | LADSPA_HINT_DEFAULT_1. */ 220 | #define LADSPA_HINT_TOGGLED 0x4 221 | 222 | /* Hint LADSPA_HINT_SAMPLE_RATE indicates that any bounds specified 223 | should be interpreted as multiples of the sample rate. For 224 | instance, a frequency range from 0Hz to the Nyquist frequency (half 225 | the sample rate) could be requested by this hint in conjunction 226 | with LowerBound = 0 and UpperBound = 0.5. Hosts that support bounds 227 | at all must support this hint to retain meaning. */ 228 | #define LADSPA_HINT_SAMPLE_RATE 0x8 229 | 230 | /* Hint LADSPA_HINT_LOGARITHMIC indicates that it is likely that the 231 | user will find it more intuitive to view values using a logarithmic 232 | scale. This is particularly useful for frequencies and gains. */ 233 | #define LADSPA_HINT_LOGARITHMIC 0x10 234 | 235 | /* Hint LADSPA_HINT_INTEGER indicates that a user interface would 236 | probably wish to provide a stepped control taking only integer 237 | values. Any bounds set should be slightly wider than the actual 238 | integer range required to avoid floating point rounding errors. For 239 | instance, the integer set {0,1,2,3} might be described as [-0.1, 240 | 3.1]. */ 241 | #define LADSPA_HINT_INTEGER 0x20 242 | 243 | /* The various LADSPA_HINT_HAS_DEFAULT_* hints indicate a `normal' 244 | value for the port that is sensible as a default. For instance, 245 | this value is suitable for use as an initial value in a user 246 | interface or as a value the host might assign to a control port 247 | when the user has not provided one. Defaults are encoded using a 248 | mask so only one default may be specified for a port. Some of the 249 | hints make use of lower and upper bounds, in which case the 250 | relevant bound or bounds must be available and 251 | LADSPA_HINT_SAMPLE_RATE must be applied as usual. The resulting 252 | default must be rounded if LADSPA_HINT_INTEGER is present. Default 253 | values were introduced in LADSPA v1.1. */ 254 | #define LADSPA_HINT_DEFAULT_MASK 0x3C0 255 | 256 | /* This default values indicates that no default is provided. */ 257 | #define LADSPA_HINT_DEFAULT_NONE 0x0 258 | 259 | /* This default hint indicates that the suggested lower bound for the 260 | port should be used. */ 261 | #define LADSPA_HINT_DEFAULT_MINIMUM 0x40 262 | 263 | /* This default hint indicates that a low value between the suggested 264 | lower and upper bounds should be chosen. For ports with 265 | LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.75 + 266 | log(upper) * 0.25). Otherwise, this should be (lower * 0.75 + upper 267 | * 0.25). */ 268 | #define LADSPA_HINT_DEFAULT_LOW 0x80 269 | 270 | /* This default hint indicates that a middle value between the 271 | suggested lower and upper bounds should be chosen. For ports with 272 | LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.5 + 273 | log(upper) * 0.5). Otherwise, this should be (lower * 0.5 + upper * 274 | 0.5). */ 275 | #define LADSPA_HINT_DEFAULT_MIDDLE 0xC0 276 | 277 | /* This default hint indicates that a high value between the suggested 278 | lower and upper bounds should be chosen. For ports with 279 | LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.25 + 280 | log(upper) * 0.75). Otherwise, this should be (lower * 0.25 + upper 281 | * 0.75). */ 282 | #define LADSPA_HINT_DEFAULT_HIGH 0x100 283 | 284 | /* This default hint indicates that the suggested upper bound for the 285 | port should be used. */ 286 | #define LADSPA_HINT_DEFAULT_MAXIMUM 0x140 287 | 288 | /* This default hint indicates that the number 0 should be used. Note 289 | that this default may be used in conjunction with 290 | LADSPA_HINT_TOGGLED. */ 291 | #define LADSPA_HINT_DEFAULT_0 0x200 292 | 293 | /* This default hint indicates that the number 1 should be used. Note 294 | that this default may be used in conjunction with 295 | LADSPA_HINT_TOGGLED. */ 296 | #define LADSPA_HINT_DEFAULT_1 0x240 297 | 298 | /* This default hint indicates that the number 100 should be used. */ 299 | #define LADSPA_HINT_DEFAULT_100 0x280 300 | 301 | /* This default hint indicates that the Hz frequency of `concert A' 302 | should be used. This will be 440 unless the host uses an unusual 303 | tuning convention, in which case it may be within a few Hz. */ 304 | #define LADSPA_HINT_DEFAULT_440 0x2C0 305 | 306 | #define LADSPA_IS_HINT_BOUNDED_BELOW(x) ((x) & LADSPA_HINT_BOUNDED_BELOW) 307 | #define LADSPA_IS_HINT_BOUNDED_ABOVE(x) ((x) & LADSPA_HINT_BOUNDED_ABOVE) 308 | #define LADSPA_IS_HINT_TOGGLED(x) ((x) & LADSPA_HINT_TOGGLED) 309 | #define LADSPA_IS_HINT_SAMPLE_RATE(x) ((x) & LADSPA_HINT_SAMPLE_RATE) 310 | #define LADSPA_IS_HINT_LOGARITHMIC(x) ((x) & LADSPA_HINT_LOGARITHMIC) 311 | #define LADSPA_IS_HINT_INTEGER(x) ((x) & LADSPA_HINT_INTEGER) 312 | 313 | #define LADSPA_IS_HINT_HAS_DEFAULT(x) ((x) & LADSPA_HINT_DEFAULT_MASK) 314 | #define LADSPA_IS_HINT_DEFAULT_MINIMUM(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ 315 | == LADSPA_HINT_DEFAULT_MINIMUM) 316 | #define LADSPA_IS_HINT_DEFAULT_LOW(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ 317 | == LADSPA_HINT_DEFAULT_LOW) 318 | #define LADSPA_IS_HINT_DEFAULT_MIDDLE(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ 319 | == LADSPA_HINT_DEFAULT_MIDDLE) 320 | #define LADSPA_IS_HINT_DEFAULT_HIGH(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ 321 | == LADSPA_HINT_DEFAULT_HIGH) 322 | #define LADSPA_IS_HINT_DEFAULT_MAXIMUM(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ 323 | == LADSPA_HINT_DEFAULT_MAXIMUM) 324 | #define LADSPA_IS_HINT_DEFAULT_0(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ 325 | == LADSPA_HINT_DEFAULT_0) 326 | #define LADSPA_IS_HINT_DEFAULT_1(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ 327 | == LADSPA_HINT_DEFAULT_1) 328 | #define LADSPA_IS_HINT_DEFAULT_100(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ 329 | == LADSPA_HINT_DEFAULT_100) 330 | #define LADSPA_IS_HINT_DEFAULT_440(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ 331 | == LADSPA_HINT_DEFAULT_440) 332 | 333 | typedef struct _LADSPA_PortRangeHint { 334 | 335 | /* Hints about the port. */ 336 | LADSPA_PortRangeHintDescriptor HintDescriptor; 337 | 338 | /* Meaningful when hint LADSPA_HINT_BOUNDED_BELOW is active. When 339 | LADSPA_HINT_SAMPLE_RATE is also active then this value should be 340 | multiplied by the relevant sample rate. */ 341 | LADSPA_Data LowerBound; 342 | 343 | /* Meaningful when hint LADSPA_HINT_BOUNDED_ABOVE is active. When 344 | LADSPA_HINT_SAMPLE_RATE is also active then this value should be 345 | multiplied by the relevant sample rate. */ 346 | LADSPA_Data UpperBound; 347 | 348 | } LADSPA_PortRangeHint; 349 | 350 | /*****************************************************************************/ 351 | 352 | /* Plugin Handles: 353 | 354 | This plugin handle indicates a particular instance of the plugin 355 | concerned. It is valid to compare this to NULL (0 for C++) but 356 | otherwise the host should not attempt to interpret it. The plugin 357 | may use it to reference internal instance data. */ 358 | 359 | typedef void * LADSPA_Handle; 360 | 361 | /*****************************************************************************/ 362 | 363 | /* Descriptor for a Type of Plugin: 364 | 365 | This structure is used to describe a plugin type. It provides a 366 | number of functions to examine the type, instantiate it, link it to 367 | buffers and workspaces and to run it. */ 368 | 369 | typedef struct _LADSPA_Descriptor { 370 | 371 | /* This numeric identifier indicates the plugin type 372 | uniquely. Plugin programmers may reserve ranges of IDs from a 373 | central body to avoid clashes. Hosts may assume that IDs are 374 | below 0x1000000. */ 375 | unsigned long UniqueID; 376 | 377 | /* This identifier can be used as a unique, case-sensitive 378 | identifier for the plugin type within the plugin file. Plugin 379 | types should be identified by file and label rather than by index 380 | or plugin name, which may be changed in new plugin 381 | versions. Labels must not contain white-space characters. */ 382 | const char * Label; 383 | 384 | /* This indicates a number of properties of the plugin. */ 385 | LADSPA_Properties Properties; 386 | 387 | /* This member points to the null-terminated name of the plugin 388 | (e.g. "Sine Oscillator"). */ 389 | const char * Name; 390 | 391 | /* This member points to the null-terminated string indicating the 392 | maker of the plugin. This can be an empty string but not NULL. */ 393 | const char * Maker; 394 | 395 | /* This member points to the null-terminated string indicating any 396 | copyright applying to the plugin. If no Copyright applies the 397 | string "None" should be used. */ 398 | const char * Copyright; 399 | 400 | /* This indicates the number of ports (input AND output) present on 401 | the plugin. */ 402 | unsigned long PortCount; 403 | 404 | /* This member indicates an array of port descriptors. Valid indices 405 | vary from 0 to PortCount-1. */ 406 | const LADSPA_PortDescriptor * PortDescriptors; 407 | 408 | /* This member indicates an array of null-terminated strings 409 | describing ports (e.g. "Frequency (Hz)"). Valid indices vary from 410 | 0 to PortCount-1. */ 411 | const char * const * PortNames; 412 | 413 | /* This member indicates an array of range hints for each port (see 414 | above). Valid indices vary from 0 to PortCount-1. */ 415 | const LADSPA_PortRangeHint * PortRangeHints; 416 | 417 | /* This may be used by the plugin developer to pass any custom 418 | implementation data into an instantiate call. It must not be used 419 | or interpreted by the host. It is expected that most plugin 420 | writers will not use this facility as LADSPA_Handle should be 421 | used to hold instance data. */ 422 | void * ImplementationData; 423 | 424 | /* This member is a function pointer that instantiates a plugin. A 425 | handle is returned indicating the new plugin instance. The 426 | instantiation function accepts a sample rate as a parameter. The 427 | plugin descriptor from which this instantiate function was found 428 | must also be passed. This function must return NULL if 429 | instantiation fails. 430 | 431 | Note that instance initialisation should generally occur in 432 | activate() rather than here. */ 433 | LADSPA_Handle (*instantiate)(const struct _LADSPA_Descriptor * Descriptor, 434 | unsigned long SampleRate); 435 | 436 | /* This member is a function pointer that connects a port on an 437 | instantiated plugin to a memory location at which a block of data 438 | for the port will be read/written. The data location is expected 439 | to be an array of LADSPA_Data for audio ports or a single 440 | LADSPA_Data value for control ports. Memory issues will be 441 | managed by the host. The plugin must read/write the data at these 442 | locations every time run() or run_adding() is called and the data 443 | present at the time of this connection call should not be 444 | considered meaningful. 445 | 446 | connect_port() may be called more than once for a plugin instance 447 | to allow the host to change the buffers that the plugin is 448 | reading or writing. These calls may be made before or after 449 | activate() or deactivate() calls. 450 | 451 | connect_port() must be called at least once for each port before 452 | run() or run_adding() is called. When working with blocks of 453 | LADSPA_Data the plugin should pay careful attention to the block 454 | size passed to the run function as the block allocated may only 455 | just be large enough to contain the block of samples. 456 | 457 | Plugin writers should be aware that the host may elect to use the 458 | same buffer for more than one port and even use the same buffer 459 | for both input and output (see LADSPA_PROPERTY_INPLACE_BROKEN). 460 | However, overlapped buffers or use of a single buffer for both 461 | audio and control data may result in unexpected behaviour. */ 462 | void (*connect_port)(LADSPA_Handle Instance, 463 | unsigned long Port, 464 | LADSPA_Data * DataLocation); 465 | 466 | /* This member is a function pointer that initialises a plugin 467 | instance and activates it for use. This is separated from 468 | instantiate() to aid real-time support and so that hosts can 469 | reinitialise a plugin instance by calling deactivate() and then 470 | activate(). In this case the plugin instance must reset all state 471 | information dependent on the history of the plugin instance 472 | except for any data locations provided by connect_port() and any 473 | gain set by set_run_adding_gain(). If there is nothing for 474 | activate() to do then the plugin writer may provide a NULL rather 475 | than an empty function. 476 | 477 | When present, hosts must call this function once before run() (or 478 | run_adding()) is called for the first time. This call should be 479 | made as close to the run() call as possible and indicates to 480 | real-time plugins that they are now live. Plugins should not rely 481 | on a prompt call to run() after activate(). activate() may not be 482 | called again unless deactivate() is called first. Note that 483 | connect_port() may be called before or after a call to 484 | activate(). */ 485 | void (*activate)(LADSPA_Handle Instance); 486 | 487 | /* This method is a function pointer that runs an instance of a 488 | plugin for a block. Two parameters are required: the first is a 489 | handle to the particular instance to be run and the second 490 | indicates the block size (in samples) for which the plugin 491 | instance may run. 492 | 493 | Note that if an activate() function exists then it must be called 494 | before run() or run_adding(). If deactivate() is called for a 495 | plugin instance then the plugin instance may not be reused until 496 | activate() has been called again. 497 | 498 | If the plugin has the property LADSPA_PROPERTY_HARD_RT_CAPABLE 499 | then there are various things that the plugin should not do 500 | within the run() or run_adding() functions (see above). */ 501 | void (*run)(LADSPA_Handle Instance, 502 | unsigned long SampleCount); 503 | 504 | /* This method is a function pointer that runs an instance of a 505 | plugin for a block. This has identical behaviour to run() except 506 | in the way data is output from the plugin. When run() is used, 507 | values are written directly to the memory areas associated with 508 | the output ports. However when run_adding() is called, values 509 | must be added to the values already present in the memory 510 | areas. Furthermore, output values written must be scaled by the 511 | current gain set by set_run_adding_gain() (see below) before 512 | addition. 513 | 514 | run_adding() is optional. When it is not provided by a plugin, 515 | this function pointer must be set to NULL. When it is provided, 516 | the function set_run_adding_gain() must be provided also. */ 517 | void (*run_adding)(LADSPA_Handle Instance, 518 | unsigned long SampleCount); 519 | 520 | /* This method is a function pointer that sets the output gain for 521 | use when run_adding() is called (see above). If this function is 522 | never called the gain is assumed to default to 1. Gain 523 | information should be retained when activate() or deactivate() 524 | are called. 525 | 526 | This function should be provided by the plugin if and only if the 527 | run_adding() function is provided. When it is absent this 528 | function pointer must be set to NULL. */ 529 | void (*set_run_adding_gain)(LADSPA_Handle Instance, 530 | LADSPA_Data Gain); 531 | 532 | /* This is the counterpart to activate() (see above). If there is 533 | nothing for deactivate() to do then the plugin writer may provide 534 | a NULL rather than an empty function. 535 | 536 | Hosts must deactivate all activated units after they have been 537 | run() (or run_adding()) for the last time. This call should be 538 | made as close to the last run() call as possible and indicates to 539 | real-time plugins that they are no longer live. Plugins should 540 | not rely on prompt deactivation. Note that connect_port() may be 541 | called before or after a call to deactivate(). 542 | 543 | Deactivation is not similar to pausing as the plugin instance 544 | will be reinitialised when activate() is called to reuse it. */ 545 | void (*deactivate)(LADSPA_Handle Instance); 546 | 547 | /* Once an instance of a plugin has been finished with it can be 548 | deleted using the following function. The instance handle passed 549 | ceases to be valid after this call. 550 | 551 | If activate() was called for a plugin instance then a 552 | corresponding call to deactivate() must be made before cleanup() 553 | is called. */ 554 | void (*cleanup)(LADSPA_Handle Instance); 555 | 556 | } LADSPA_Descriptor; 557 | 558 | /**********************************************************************/ 559 | 560 | /* Accessing a Plugin: */ 561 | 562 | /* The exact mechanism by which plugins are loaded is host-dependent, 563 | however all most hosts will need to know is the name of shared 564 | object file containing the plugin types. To allow multiple hosts to 565 | share plugin types, hosts may wish to check for environment 566 | variable LADSPA_PATH. If present, this should contain a 567 | colon-separated path indicating directories that should be searched 568 | (in order) when loading plugin types. 569 | 570 | A plugin programmer must include a function called 571 | "ladspa_descriptor" with the following function prototype within 572 | the shared object file. This function will have C-style linkage (if 573 | you are using C++ this is taken care of by the `extern "C"' clause 574 | at the top of the file). 575 | 576 | A host will find the plugin shared object file by one means or 577 | another, find the ladspa_descriptor() function, call it, and 578 | proceed from there. 579 | 580 | Plugin types are accessed by index (not ID) using values from 0 581 | upwards. Out of range indexes must result in this function 582 | returning NULL, so the plugin count can be determined by checking 583 | for the least index that results in NULL being returned. */ 584 | 585 | const LADSPA_Descriptor * ladspa_descriptor(unsigned long Index); 586 | 587 | /* Datatype corresponding to the ladspa_descriptor() function. */ 588 | typedef const LADSPA_Descriptor * 589 | (*LADSPA_Descriptor_Function)(unsigned long Index); 590 | 591 | /**********************************************************************/ 592 | 593 | #ifdef __cplusplus 594 | } 595 | #endif 596 | 597 | #endif /* LADSPA_INCLUDED */ 598 | 599 | /* EOF */ 600 | --------------------------------------------------------------------------------