naspro
changeset 163:d7568c8379c1 trunk
Initiial DSSI support + reorganization
line diff
1.1 --- a/COPYING Sun Jul 19 18:42:36 2009 +0200 1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 1.3 @@ -1,24 +0,0 @@ 1.4 -Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 1.5 -All rights reserved. 1.6 - 1.7 -Redistribution and use in source and binary forms, with or without 1.8 -modification, are permitted provided that the following conditions 1.9 -are met: 1.10 - 1. Redistributions of source code must retain the above copyright 1.11 - notice, this list of conditions and the following disclaimer. 1.12 - 2. Redistributions in binary form must reproduce the above copyright 1.13 - notice, this list of conditions and the following disclaimer in the 1.14 - documentation and/or other materials provided with the distribution. 1.15 - 3. The name of the author may not be used to endorse or promote products 1.16 - derived from this software without specific prior written permission. 1.17 - 1.18 -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1.19 -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1.20 -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1.21 -IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 1.22 -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 1.23 -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1.24 -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 1.25 -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1.26 -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 1.27 -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2.1 --- a/Makefile Sun Jul 19 18:42:36 2009 +0200 2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 2.3 @@ -1,84 +0,0 @@ 2.4 -.POSIX: 2.5 - 2.6 -.SUFFIXES: 2.7 - 2.8 -### Change this... 2.9 - 2.10 -PREFIX = /usr/local 2.11 -LIB_DIR = $(PREFIX)/lib 2.12 -INCLUDE_DIR = $(PREFIX)/include 2.13 - 2.14 -LV2_DIR = $(LIB_DIR)/lv2 2.15 - 2.16 -LADSPA_BRIDGE_BUNDLE_DIR = $(LV2_DIR)/naspro-ladspa.lv2 2.17 - 2.18 -CC = gcc 2.19 -CFLAGS = -O2 -ansi -pedantic -Wall -fPIC 2.20 - 2.21 -DL_LDFLAGS = -ldl 2.22 -LDFLAGS = -shared $(DL_LDFLAGS) 2.23 - 2.24 -SO_FILE_EXT = .so 2.25 - 2.26 -### ... but not this 2.27 - 2.28 -TARGETS = src/core/libnacore.so src/ladspa/ladspa.so 2.29 - 2.30 -LIBNACORE_SOURCES = src/core/avl.c \ 2.31 - src/core/dl.h \ 2.32 - src/core/init.c \ 2.33 - src/core/lv2api.c \ 2.34 - src/core/manifest.c \ 2.35 - src/core/path.h \ 2.36 - src/core/posix/dl.c \ 2.37 - src/core/posix/env.c \ 2.38 - src/core/posix/path.c 2.39 - 2.40 -LADSPA_BRIDGE_SOURCES = src/ladspa/descriptor.h \ 2.41 - src/ladspa/lrdf.h \ 2.42 - src/ladspa/lv2api.h \ 2.43 - src/ladspa/pluglib.h \ 2.44 - src/ladspa/descriptor.c \ 2.45 - src/ladspa/lrdf.c \ 2.46 - src/ladspa/lv2api.c \ 2.47 - src/ladspa/manifest.c \ 2.48 - src/ladspa/pluglib.c 2.49 -LADSPA_BRIDGE_LD_PATHS = -Lsrc/core 2.50 -LADSPA_BRIDGE_LIBS = -lnacore -lrdf 2.51 - 2.52 -INCLUDE_PATHS = -I. -Iinclude 2.53 - 2.54 -HEADERS = include/NASPRO/core/avl.h \ 2.55 - include/NASPRO/core/bridge.h \ 2.56 - include/NASPRO/core/dl.h \ 2.57 - include/NASPRO/core/env.h \ 2.58 - include/NASPRO/core/lib.h \ 2.59 - include/NASPRO/core/lv2api.h \ 2.60 - include/NASPRO/core/manifest.h \ 2.61 - include/NASPRO/core/path.h \ 2.62 - include/NASPRO/core/string.h 2.63 - 2.64 -DEFS = -DSO_FILE_EXT="\"$(SO_FILE_EXT)\"" 2.65 - 2.66 -all: $(TARGETS) 2.67 - 2.68 -src/core/libnacore.so: $(LIBNACORE_SOURCES) $(HEADERS) 2.69 - $(CC) $(CFLAGS) $(LDFLAGS) $(DEFS) $(INCLUDE_PATHS) \ 2.70 - $(LIBNACORE_SOURCES) -o $@ 2.71 - 2.72 -src/ladspa/ladspa.so: src/core/libnacore.so $(LADSPA_BRIDGE_SOURCES) \ 2.73 - $(HEADERS) 2.74 - $(CC) $(CFLAGS) $(LDFLAGS) $(DEFS) $(INCLUDE_PATHS) \ 2.75 - $(LADSPA_BRIDGE_LD_PATHS) $(LADSPA_BRIDGE_SOURCES) \ 2.76 - $(LADSPA_BRIDGE_LIBS) -o $@ 2.77 - 2.78 -install: $(TARGETS) $(HEADERS) src/ladspa/manifest.ttl 2.79 - cp src/core/libnacore.so $(LIB_DIR) 2.80 - mkdir -p $(LADSPA_BRIDGE_BUNDLE_DIR) 2.81 - cp src/ladspa/ladspa.so src/ladspa/manifest.ttl \ 2.82 - $(LADSPA_BRIDGE_BUNDLE_DIR) 2.83 - mkdir -p $(INCLUDE_DIR) 2.84 - cp -R include/NASPRO $(INCLUDE_DIR) 2.85 - 2.86 -clean: 2.87 - rm -f $(TARGETS)
3.1 --- a/include/NASPRO/core/avl.h Sun Jul 19 18:42:36 2009 +0200 3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 3.3 @@ -1,30 +0,0 @@ 3.4 -/* 3.5 - * NASPRO - NASPRO Architecture for Sound Processing 3.6 - * Core library 3.7 - * 3.8 - * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 3.9 - * 3.10 - * See the COPYING file for license conditions. 3.11 - */ 3.12 - 3.13 -#ifndef _NACORE_AVL_H 3.14 -#define _NACORE_AVL_H 3.15 - 3.16 -#include <stdlib.h> 3.17 - 3.18 -typedef struct _nacore_avl_tree * nacore_avl_tree_t; 3.19 - 3.20 -nacore_avl_tree_t nacore_avl_tree_new(int (*content_cmp)(void *c1, void *c2), 3.21 - int (*key_cmp)(void *content, void *key)); 3.22 -void nacore_avl_tree_add(nacore_avl_tree_t tree, void *content); 3.23 -void nacore_avl_tree_for_each(nacore_avl_tree_t tree, 3.24 - void (*callback)(void *content, void *data), 3.25 - void *data); 3.26 -void *nacore_avl_tree_find(nacore_avl_tree_t tree, void *key); 3.27 -size_t nacore_avl_tree_get_nodes_count(nacore_avl_tree_t tree); 3.28 -void nacore_avl_tree_free(nacore_avl_tree_t tree); 3.29 - 3.30 -int nacore_content_cmp_descriptor_by_uri(void *c1, void *c2); 3.31 -int nacore_key_cmp_descriptor_by_uri(void *content, void *data); 3.32 - 3.33 -#endif /* !_NACORE_AVL_H */
4.1 --- a/include/NASPRO/core/bridge.h Sun Jul 19 18:42:36 2009 +0200 4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 4.3 @@ -1,168 +0,0 @@ 4.4 -/* 4.5 - * NASPRO - NASPRO Architecture for Sound Processing 4.6 - * Core library 4.7 - * 4.8 - * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 4.9 - * 4.10 - * See the COPYING file for license conditions. 4.11 - */ 4.12 - 4.13 -#ifndef _NACORE_BRIDGE_H 4.14 -#define _NACORE_BRIDGE_H 4.15 - 4.16 -#include <stdlib.h> 4.17 -#include <stdio.h> 4.18 -#include <stdint.h> 4.19 - 4.20 -#include <lv2.h> 4.21 - 4.22 -#ifdef __cplusplus 4.23 -extern "C" { 4.24 -#endif 4.25 - 4.26 -/* Plugins beloging to a subclass should have the superclass disabled: 4.27 - * e.g. if NACORE_DESCRIPTOR_CLASS_INSTRUMENT is on, then 4.28 - * NACORE_DESCRIPTOR_CLASS_GENERATOR must be off. */ 4.29 - 4.30 -/* descriptor.classes_1 */ 4.31 -#define NACORE_DESCRIPTOR_CLASS_GENERATOR (1) 4.32 -#define NACORE_DESCRIPTOR_CLASS_INSTRUMENT (1 << 1) 4.33 -#define NACORE_DESCRIPTOR_CLASS_OSCILLATOR (1 << 2) 4.34 -#define NACORE_DESCRIPTOR_CLASS_UTILITY (1 << 3) 4.35 -#define NACORE_DESCRIPTOR_CLASS_CONVERTER (1 << 4) 4.36 -#define NACORE_DESCRIPTOR_CLASS_ANALYSER (1 << 5) 4.37 -#define NACORE_DESCRIPTOR_CLASS_MIXER (1 << 6) 4.38 -#define NACORE_DESCRIPTOR_CLASS_SIMULATOR (1 << 7) 4.39 -#define NACORE_DESCRIPTOR_CLASS_DELAY (1 << 8) 4.40 -#define NACORE_DESCRIPTOR_CLASS_MODULATOR (1 << 9) 4.41 -#define NACORE_DESCRIPTOR_CLASS_REVERB (1 << 10) 4.42 -#define NACORE_DESCRIPTOR_CLASS_PHASER (1 << 11) 4.43 -#define NACORE_DESCRIPTOR_CLASS_FLANGER (1 << 12) 4.44 -#define NACORE_DESCRIPTOR_CLASS_CHORUS (1 << 13) 4.45 -#define NACORE_DESCRIPTOR_CLASS_FILTER (1 << 14) 4.46 -#define NACORE_DESCRIPTOR_CLASS_LOWPASS (1 << 15) 4.47 -#define NACORE_DESCRIPTOR_CLASS_BANDPASS (1 << 16) 4.48 -#define NACORE_DESCRIPTOR_CLASS_HIGHPASS (1 << 17) 4.49 -#define NACORE_DESCRIPTOR_CLASS_COMB (1 << 18) 4.50 -#define NACORE_DESCRIPTOR_CLASS_ALLPASS (1 << 19) 4.51 -#define NACORE_DESCRIPTOR_CLASS_EQ (1 << 20) 4.52 -#define NACORE_DESCRIPTOR_CLASS_PARAEQ (1 << 21) 4.53 -#define NACORE_DESCRIPTOR_CLASS_MULTIEQ (1 << 22) 4.54 -#define NACORE_DESCRIPTOR_CLASS_SPECTRAL (1 << 23) 4.55 -#define NACORE_DESCRIPTOR_CLASS_PITCH (1 << 24) 4.56 -#define NACORE_DESCRIPTOR_CLASS_AMPLIFIER (1 << 25) 4.57 -#define NACORE_DESCRIPTOR_CLASS_DISTORTION (1 << 26) 4.58 -#define NACORE_DESCRIPTOR_CLASS_WAVESHAPER (1 << 27) 4.59 - 4.60 -/* descriptor.classes_2 */ 4.61 -#define NACORE_DESCRIPTOR_CLASS_DYNAMICS (1) 4.62 -#define NACORE_DESCRIPTOR_CLASS_COMPRESSOR (1 << 1) 4.63 -#define NACORE_DESCRIPTOR_CLASS_EXPANDER (1 << 2) 4.64 -#define NACORE_DESCRIPTOR_CLASS_LIMITER (1 << 3) 4.65 -#define NACORE_DESCRIPTOR_CLASS_GATE (1 << 4) 4.66 - 4.67 -/* descriptor.properties */ 4.68 -#define NACORE_DESCRIPTOR_HAS_LIVE_DEP (1) 4.69 -#define NACORE_DESCRIPTOR_INPLACE_BROKEN (1 << 1) 4.70 -#define NACORE_DESCRIPTOR_HARD_RT_CAPABLE (1 << 2) 4.71 - 4.72 -/* port_descriptor.properties */ 4.73 -#define NACORE_PORT_IS_OUTPUT (1) 4.74 -#define NACORE_PORT_IS_AUDIO (1 << 1) 4.75 -#define NACORE_PORT_CONNECTION_OPTIONAL (1 << 2) 4.76 -#define NACORE_PORT_REPORTS_LATENCY (1 << 3) 4.77 -#define NACORE_PORT_TOGGLED (1 << 4) 4.78 -#define NACORE_PORT_SAMPLE_RATE (1 << 5) 4.79 -#define NACORE_PORT_INTEGER (1 << 6) 4.80 -#define NACORE_PORT_LOGARITHMIC (1 << 7) 4.81 - 4.82 -/* port_descriptor.scale.properties */ 4.83 -#define NACORE_SCALE_HAS_MIN (1) 4.84 -#define NACORE_SCALE_HAS_MAX (1 << 1) 4.85 -#define NACORE_SCALE_HAS_DEFAULT (1 << 2) 4.86 - 4.87 -enum nacore_scale_unit 4.88 - { 4.89 - nacore_scale_unit_none = 0, 4.90 - nacore_scale_unit_bar, 4.91 - nacore_scale_unit_beat, 4.92 - nacore_scale_unit_bpm, 4.93 - nacore_scale_unit_cent, 4.94 - nacore_scale_unit_cm, 4.95 - nacore_scale_unit_coeff, 4.96 - nacore_scale_unit_db, 4.97 - nacore_scale_unit_deg, 4.98 - nacore_scale_unit_hz, 4.99 - nacore_scale_unit_inch, 4.100 - nacore_scale_unit_khz, 4.101 - nacore_scale_unit_km, 4.102 - nacore_scale_unit_m, 4.103 - nacore_scale_unit_mhz, 4.104 - nacore_scale_unit_midi_note, 4.105 - nacore_scale_unit_mi, 4.106 - nacore_scale_unit_min, 4.107 - nacore_scale_unit_mm, 4.108 - nacore_scale_unit_ms, 4.109 - nacore_scale_unit_oct, 4.110 - nacore_scale_unit_pc, 4.111 - nacore_scale_unit_s, 4.112 - nacore_scale_unit_semitone 4.113 - }; 4.114 - 4.115 -struct nacore_scale_point 4.116 - { 4.117 - char *label; 4.118 - float value; 4.119 - }; 4.120 - 4.121 -struct nacore_port_scale 4.122 - { 4.123 - uint32_t properties; 4.124 - float min; 4.125 - float max; 4.126 - float defaultv; 4.127 - enum nacore_scale_unit unit; 4.128 - struct nacore_scale_point *points; 4.129 - size_t points_count; 4.130 - }; 4.131 - 4.132 -struct nacore_port_descriptor 4.133 - { 4.134 - char *name; 4.135 - uint32_t properties; 4.136 - struct nacore_port_scale scale; 4.137 - void *data; 4.138 - }; 4.139 - 4.140 -struct nacore_descriptor 4.141 - { 4.142 - char *name; 4.143 - char *uri; 4.144 - char *creator; 4.145 - char *rights; 4.146 - struct nacore_port_descriptor *port_descs; 4.147 - size_t port_descs_count; 4.148 - uint32_t properties; 4.149 - uint32_t classes_1; 4.150 - uint32_t classes_2; 4.151 - void *data; 4.152 - 4.153 - LV2_Handle (*instantiate) (const LV2_Descriptor *descriptor, 4.154 - double sample_rate, 4.155 - const char *bundle_path, 4.156 - const LV2_Feature * const *features); 4.157 - void (*connect_port) (LV2_Handle instance, uint32_t port, 4.158 - void *data_location); 4.159 - void (*activate) (LV2_Handle instance); 4.160 - void (*run) (LV2_Handle instance, 4.161 - uint32_t sample_count); 4.162 - void (*deactivate) (LV2_Handle instance); 4.163 - void (*cleanup) (LV2_Handle instance); 4.164 - const void * (*extension_data)(const char *uri); 4.165 - }; 4.166 - 4.167 -#ifdef __cplusplus 4.168 -} 4.169 -#endif 4.170 - 4.171 -#endif /* !_NACORE_BRIDGE_H */
5.1 --- a/include/NASPRO/core/dl.h Sun Jul 19 18:42:36 2009 +0200 5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 5.3 @@ -1,28 +0,0 @@ 5.4 -/* 5.5 - * NASPRO - NASPRO Architecture for Sound Processing 5.6 - * Core library 5.7 - * 5.8 - * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 5.9 - * 5.10 - * See the COPYING file for license conditions. 5.11 - */ 5.12 - 5.13 -#ifndef _NACORE_DL_H 5.14 -#define _NACORE_DL_H 5.15 - 5.16 -#ifdef __cplusplus 5.17 -extern "C" { 5.18 -#endif 5.19 - 5.20 -typedef struct _nacore_dl_module * nacore_dl_module_t; 5.21 - 5.22 -nacore_dl_module_t nacore_dl_open(const char *file); 5.23 -void * nacore_dl_sym(nacore_dl_module_t handle, const char *symbol); 5.24 -void nacore_dl_close(nacore_dl_module_t handle); 5.25 -char nacore_dl_filename_filter(const char *file); 5.26 - 5.27 -#ifdef __cplusplus 5.28 -} 5.29 -#endif 5.30 - 5.31 -#endif /* !_NACORE_DL_H */
6.1 --- a/include/NASPRO/core/env.h Sun Jul 19 18:42:36 2009 +0200 6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 6.3 @@ -1,16 +0,0 @@ 6.4 -/* 6.5 - * NASPRO - NASPRO Architecture for Sound Processing 6.6 - * Core library 6.7 - * 6.8 - * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 6.9 - * 6.10 - * See the COPYING file for license conditions. 6.11 - */ 6.12 - 6.13 -#ifndef _NACORE_ENV_H 6.14 -#define _NACORE_ENV_H 6.15 - 6.16 -char * nacore_env_get_var(const char *name); 6.17 -void nacore_env_free_var_value(char *value); 6.18 - 6.19 -#endif /* !_NACORE_ENV_H */
7.1 --- a/include/NASPRO/core/lib.h Sun Jul 19 18:42:36 2009 +0200 7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 7.3 @@ -1,22 +0,0 @@ 7.4 -/* 7.5 - * NASPRO - NASPRO Architecture for Sound Processing 7.6 - * Core library 7.7 - * 7.8 - * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 7.9 - * 7.10 - * See the COPYING file for license conditions. 7.11 - */ 7.12 - 7.13 -#ifndef _NACORE_LIB_H 7.14 -#define _NACORE_LIB_H 7.15 - 7.16 -#include <NASPRO/core/string.h> 7.17 -#include <NASPRO/core/env.h> 7.18 -#include <NASPRO/core/path.h> 7.19 -#include <NASPRO/core/dl.h> 7.20 -#include <NASPRO/core/bridge.h> 7.21 -#include <NASPRO/core/lv2api.h> 7.22 -#include <NASPRO/core/avl.h> 7.23 -#include <NASPRO/core/manifest.h> 7.24 - 7.25 -#endif /* !_NACORE_LIB_H */
8.1 --- a/include/NASPRO/core/lv2api.h Sun Jul 19 18:42:36 2009 +0200 8.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 8.3 @@ -1,20 +0,0 @@ 8.4 -/* 8.5 - * NASPRO - NASPRO Architecture for Sound Processing 8.6 - * Core library 8.7 - * 8.8 - * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 8.9 - * 8.10 - * See the COPYING file for license conditions. 8.11 - */ 8.12 - 8.13 -#ifndef _NACORE_LV2API_H 8.14 -#define _NACORE_LV2API_H 8.15 - 8.16 -#include <lv2.h> 8.17 - 8.18 -#include <NASPRO/core/bridge.h> 8.19 - 8.20 -void nacore_lv2api_fill_desc(LV2_Descriptor *lv2_desc, 8.21 - struct nacore_descriptor *n_desc); 8.22 - 8.23 -#endif /* !_NACORE_LV2API_H */
9.1 --- a/include/NASPRO/core/manifest.h Sun Jul 19 18:42:36 2009 +0200 9.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 9.3 @@ -1,21 +0,0 @@ 9.4 -/* 9.5 - * NASPRO - NASPRO Architecture for Sound Processing 9.6 - * Core library 9.7 - * 9.8 - * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 9.9 - * 9.10 - * See the COPYING file for license conditions. 9.11 - */ 9.12 - 9.13 -#ifndef _NACORE_MANIFEST_H 9.14 -#define _NACORE_MANIFEST_H 9.15 - 9.16 -#include <stdio.h> 9.17 - 9.18 -void nacore_manifest_print_subject_prefixes(FILE *fp); 9.19 -void nacore_manifest_print_subject_triple(struct nacore_descriptor *desc, 9.20 - FILE *fp); 9.21 -void nacore_manifest_print_data(struct nacore_descriptor *desc, FILE *fp, 9.22 - const char *binary); 9.23 - 9.24 -#endif /* !_NACORE_MANIFEST_H */
10.1 --- a/include/NASPRO/core/path.h Sun Jul 19 18:42:36 2009 +0200 10.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 10.3 @@ -1,30 +0,0 @@ 10.4 -/* 10.5 - * NASPRO - NASPRO Architecture for Sound Processing 10.6 - * Core library 10.7 - * 10.8 - * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 10.9 - * 10.10 - * See the COPYING file for license conditions. 10.11 - */ 10.12 - 10.13 -#ifndef _NACORE_PATH_H 10.14 -#define _NACORE_PATH_H 10.15 - 10.16 -#ifdef __cplusplus 10.17 -extern "C" { 10.18 -#endif 10.19 - 10.20 -void nacore_path_for_each(const char *path, 10.21 - void (*callback)(const char *file, void *data), 10.22 - char (*filter)(const char *file), 10.23 - void *data); 10.24 -void nacore_path_home_for_each(const char *dir, 10.25 - void (*callback)(const char *file, void *data), 10.26 - char (*filter)(const char *file), 10.27 - void *data); 10.28 - 10.29 -#ifdef __cplusplus 10.30 -} 10.31 -#endif 10.32 - 10.33 -#endif /* !_NACORE_PATH_H */
11.1 --- a/include/NASPRO/core/string.h Sun Jul 19 18:42:36 2009 +0200 11.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 11.3 @@ -1,15 +0,0 @@ 11.4 -/* 11.5 - * NASPRO - NASPRO Architecture for Sound Processing 11.6 - * Core library 11.7 - * 11.8 - * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 11.9 - * 11.10 - * See the COPYING file for license conditions. 11.11 - */ 11.12 - 11.13 -#ifndef _NACORE_STRING_H 11.14 -#define _NACORE_STRING_H 11.15 - 11.16 -#define NACORE_STRING_IS_NULL_OR_EMPTY(s) ((s == NULL) ? 1 : (*s == '\0')) 11.17 - 11.18 -#endif /* !_NACORE_STRING_H */
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/naspro-bridges-bad/Makefile Fri Sep 11 13:31:52 2009 +0200 12.3 @@ -0,0 +1,45 @@ 12.4 +.POSIX: 12.5 + 12.6 +.SUFFIXES: 12.7 + 12.8 +all: 12.9 + $(MAKE) ladspa-bridge 12.10 + $(MAKE) dssi-bridge 12.11 + $(MAKE) ndf-bridge 12.12 + 12.13 +install: 12.14 + $(MAKE) ladspa-bridge-install 12.15 + $(MAKE) dssi-bridge-install 12.16 + $(MAKE) ndf-bridge-install 12.17 + 12.18 +clean: 12.19 + $(MAKE) ladspa-bridge-clean 12.20 + $(MAKE) dssi-bridge-clean 12.21 + $(MAKE) ndf-bridge-clean 12.22 + 12.23 +ladspa-bridge: 12.24 + cd ladspa && $(MAKE) && cd .. 12.25 + 12.26 +ladspa-bridge-install: 12.27 + cd ladspa && $(MAKE) install && cd .. 12.28 + 12.29 +ladspa-bridge-clean: 12.30 + cd ladspa && $(MAKE) clean && cd .. 12.31 + 12.32 +dssi-bridge: 12.33 + cd dssi && $(MAKE) && cd .. 12.34 + 12.35 +dssi-bridge-install: 12.36 + cd dssi && $(MAKE) install && cd .. 12.37 + 12.38 +dssi-bridge-clean: 12.39 + cd dssi && $(MAKE) clean && cd .. 12.40 + 12.41 +ndf-bridge: 12.42 + cd ndf && $(MAKE) && cd .. 12.43 + 12.44 +ndf-bridge-install: 12.45 + cd ndf && $(MAKE) install && cd .. 12.46 + 12.47 +ndf-bridge-clean: 12.48 + cd ndf && $(MAKE) clean && cd ..
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 13.2 +++ b/naspro-bridges-bad/dssi/Makefile Fri Sep 11 13:31:52 2009 +0200 13.3 @@ -0,0 +1,46 @@ 13.4 +.POSIX: 13.5 + 13.6 +.SUFFIXES: 13.7 + 13.8 +### Change this... 13.9 + 13.10 +PREFIX = /usr/local 13.11 +LIB_DIR = $(PREFIX)/lib 13.12 + 13.13 +LV2_DIR = $(LIB_DIR)/lv2 13.14 + 13.15 +DSSI_BRIDGE_BUNDLE_DIR = $(LV2_DIR)/naspro-dssi.lv2 13.16 + 13.17 +CC = gcc 13.18 +CFLAGS = -O2 -ansi -pedantic -Wall -fPIC 13.19 + 13.20 +DL_LDFLAGS = -ldl 13.21 +LDFLAGS = -shared $(DL_LDFLAGS) 13.22 + 13.23 +SO_FILE_EXT = .so 13.24 + 13.25 +### ... but not this 13.26 + 13.27 +TARGETS = dssi.so 13.28 + 13.29 +DSSI_BRIDGE_SOURCES = descriptor.c \ 13.30 + descriptor.h \ 13.31 + lv2api.c \ 13.32 + lv2api.h \ 13.33 + manifest.c \ 13.34 + pluglib.c \ 13.35 + pluglib.h 13.36 +DSSI_BRIDGE_LIBS = -lnacore -lasound 13.37 + 13.38 +all: $(TARGETS) 13.39 + 13.40 +dssi.so: $(DSSI_BRIDGE_SOURCES) 13.41 + $(CC) $(CFLAGS) $(LDFLAGS) $(DSSI_BRIDGE_SOURCES) \ 13.42 + $(DSSI_BRIDGE_LIBS) -o $@ 13.43 + 13.44 +install: $(TARGETS) manifest.ttl 13.45 + mkdir -p $(DSSI_BRIDGE_BUNDLE_DIR) 13.46 + cp dssi.so manifest.ttl $(DSSI_BRIDGE_BUNDLE_DIR) 13.47 + 13.48 +clean: 13.49 + rm -f $(TARGETS)
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 14.2 +++ b/naspro-bridges-bad/dssi/descriptor.c Fri Sep 11 13:31:52 2009 +0200 14.3 @@ -0,0 +1,177 @@ 14.4 +/* 14.5 + * NASPRO - NASPRO Architecture for Sound Processing 14.6 + * DSSI bridge 14.7 + * 14.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 14.9 + * 14.10 + * See the COPYING file for license conditions. 14.11 + */ 14.12 + 14.13 +#include <stddef.h> 14.14 +#include <string.h> 14.15 + 14.16 +#include <math.h> 14.17 + 14.18 +#include <dssi.h> 14.19 +#include <ladspa.h> 14.20 + 14.21 +#include <NASPRO/core/lib.h> 14.22 + 14.23 +#include "descriptor.h" 14.24 +#include "lv2api.h" 14.25 + 14.26 +void 14.27 +_nadssi_descriptor_fill(struct nacore_descriptor *desc, 14.28 + const DSSI_Descriptor *ddesc) 14.29 +{ 14.30 + const LADSPA_Descriptor *ldesc; 14.31 + size_t i; 14.32 + char is_synth; 14.33 + 14.34 + ldesc = ddesc->LADSPA_Plugin; 14.35 + 14.36 + desc->data = (void *)ddesc; 14.37 + 14.38 + desc->name = (char *)ldesc->Name; 14.39 + desc->creator = (*ldesc->Maker != '\0') ? NULL : (char *)ldesc->Maker; 14.40 + desc->rights = strcmp(ldesc->Copyright, "None") 14.41 + ? (char *)ldesc->Copyright : NULL; 14.42 + 14.43 + desc->instantiate = _nadssi_lv2api_instantiate; 14.44 + desc->connect_port = _nadssi_lv2api_connect_port; 14.45 + desc->activate = ldesc->activate != NULL ? _nadssi_lv2api_activate 14.46 + : NULL; 14.47 + desc->run = _nadssi_lv2api_run; 14.48 + desc->deactivate = ldesc->deactivate != NULL 14.49 + ? _nadssi_lv2api_deactivate : NULL; 14.50 + desc->cleanup = _nadssi_lv2api_cleanup; 14.51 + desc->extension_data = NULL; 14.52 + 14.53 + desc->properties = 0; 14.54 + if (LADSPA_IS_REALTIME(ldesc->Properties)) 14.55 + desc->properties |= NACORE_DESCRIPTOR_HAS_LIVE_DEP; 14.56 + if (LADSPA_IS_INPLACE_BROKEN(ldesc->Properties)) 14.57 + desc->properties |= NACORE_DESCRIPTOR_INPLACE_BROKEN; 14.58 + if (LADSPA_IS_HARD_RT_CAPABLE(ldesc->Properties)) 14.59 + desc->properties |= NACORE_DESCRIPTOR_HARD_RT_CAPABLE; 14.60 + 14.61 + desc->classes_1 = 0; 14.62 + desc->classes_2 = 0; 14.63 + 14.64 + is_synth = ((ddesc->run_synth != NULL) 14.65 + || (ddesc->run_multiple_synths != NULL)) ? 1 : 0; 14.66 + for (i = 0; i < desc->port_descs_count - is_synth; i++) 14.67 + { 14.68 + /* This check is due to Josh Green's broken vocoder plugin */ 14.69 + if (ldesc->PortNames[i] == NULL) 14.70 + desc->port_descs[i].name = "(null)"; 14.71 + else 14.72 + desc->port_descs[i].name = (char *)ldesc->PortNames[i]; 14.73 + 14.74 + desc->port_descs[i].data = NULL; 14.75 + desc->port_descs[i].scale.unit = nacore_scale_unit_none; 14.76 + desc->port_descs[i].scale.points = NULL; 14.77 + desc->port_descs[i].scale.points_count = 0; 14.78 + 14.79 + desc->port_descs[i].properties = 0; 14.80 + if (LADSPA_IS_PORT_OUTPUT(ldesc->PortDescriptors[i])) 14.81 + desc->port_descs[i].properties |= NACORE_PORT_IS_OUTPUT; 14.82 + if (LADSPA_IS_PORT_AUDIO(ldesc->PortDescriptors[i])) 14.83 + desc->port_descs[i].properties |= NACORE_PORT_IS_AUDIO; 14.84 + 14.85 + if (desc->port_descs[i].properties & NACORE_PORT_IS_AUDIO) 14.86 + continue; 14.87 + 14.88 + if (!strcmp(ldesc->PortNames[i], "latency") 14.89 + || !strcmp(ldesc->PortNames[i], "_latency")) 14.90 + desc->port_descs[i].properties |= 14.91 + NACORE_PORT_REPORTS_LATENCY; 14.92 + if (LADSPA_IS_HINT_TOGGLED( 14.93 + ldesc->PortRangeHints[i].HintDescriptor)) 14.94 + desc->port_descs[i].properties |= NACORE_PORT_TOGGLED; 14.95 + if (LADSPA_IS_HINT_SAMPLE_RATE( 14.96 + ldesc->PortRangeHints[i].HintDescriptor)) 14.97 + desc->port_descs[i].properties |= 14.98 + NACORE_PORT_SAMPLE_RATE; 14.99 + if (LADSPA_IS_HINT_INTEGER( 14.100 + ldesc->PortRangeHints[i].HintDescriptor)) 14.101 + desc->port_descs[i].properties |= NACORE_PORT_INTEGER; 14.102 + if (LADSPA_IS_HINT_LOGARITHMIC( 14.103 + ldesc->PortRangeHints[i].HintDescriptor)) 14.104 + desc->port_descs[i].properties |= 14.105 + NACORE_PORT_LOGARITHMIC; 14.106 + 14.107 + desc->port_descs[i].scale.properties = 0; 14.108 + if (LADSPA_IS_HINT_BOUNDED_BELOW( 14.109 + ldesc->PortRangeHints[i].HintDescriptor)) 14.110 + { 14.111 + desc->port_descs[i].scale.properties |= 14.112 + NACORE_SCALE_HAS_MIN; 14.113 + desc->port_descs[i].scale.min = 14.114 + ldesc->PortRangeHints[i].LowerBound; 14.115 + } 14.116 + if (LADSPA_IS_HINT_BOUNDED_ABOVE( 14.117 + ldesc->PortRangeHints[i].HintDescriptor)) 14.118 + { 14.119 + desc->port_descs[i].scale.properties |= 14.120 + NACORE_SCALE_HAS_MAX; 14.121 + desc->port_descs[i].scale.max = 14.122 + ldesc->PortRangeHints[i].UpperBound; 14.123 + } 14.124 + if (LADSPA_IS_HINT_HAS_DEFAULT( 14.125 + ldesc->PortRangeHints[i].HintDescriptor)) 14.126 + { 14.127 + desc->port_descs[i].scale.properties |= 14.128 + NACORE_SCALE_HAS_DEFAULT; 14.129 + if (LADSPA_IS_HINT_DEFAULT_MINIMUM( 14.130 + ldesc->PortRangeHints[i].HintDescriptor)) 14.131 + desc->port_descs[i].scale.defaultv = 14.132 + desc->port_descs[i].scale.min; 14.133 + else if (LADSPA_IS_HINT_DEFAULT_LOW( 14.134 + ldesc->PortRangeHints[i].HintDescriptor)) 14.135 + desc->port_descs[i].scale.defaultv = 14.136 + (desc->port_descs[i].properties & NACORE_PORT_LOGARITHMIC) 14.137 + ? exp(log(desc->port_descs[i].scale.min) * 0.75 + log(desc->port_descs[i].scale.max) * 0.25) 14.138 + : desc->port_descs[i].scale.min * 0.75 + desc->port_descs[i].scale.max * 0.25; 14.139 + else if (LADSPA_IS_HINT_DEFAULT_MIDDLE( 14.140 + ldesc->PortRangeHints[i].HintDescriptor)) 14.141 + desc->port_descs[i].scale.defaultv = 14.142 + (desc->port_descs[i].properties & NACORE_PORT_LOGARITHMIC) 14.143 + ? exp(log(desc->port_descs[i].scale.min) * 0.5 + log(desc->port_descs[i].scale.max) * 0.5) 14.144 + : desc->port_descs[i].scale.min * 0.5 + desc->port_descs[i].scale.max * 0.5; 14.145 + else if (LADSPA_IS_HINT_DEFAULT_HIGH( 14.146 + ldesc->PortRangeHints[i].HintDescriptor)) 14.147 + desc->port_descs[i].scale.defaultv = 14.148 + (desc->port_descs[i].properties & NACORE_PORT_LOGARITHMIC) 14.149 + ? exp(log(desc->port_descs[i].scale.min) * 0.25 + log(desc->port_descs[i].scale.max) * 0.75) 14.150 + : desc->port_descs[i].scale.min * 0.25 + desc->port_descs[i].scale.max * 0.75; 14.151 + else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM( 14.152 + ldesc->PortRangeHints[i].HintDescriptor)) 14.153 + desc->port_descs[i].scale.defaultv = 14.154 + desc->port_descs[i].scale.max; 14.155 + else if (LADSPA_IS_HINT_DEFAULT_0( 14.156 + ldesc->PortRangeHints[i].HintDescriptor)) 14.157 + desc->port_descs[i].scale.defaultv = 0.0; 14.158 + else if (LADSPA_IS_HINT_DEFAULT_1( 14.159 + ldesc->PortRangeHints[i].HintDescriptor)) 14.160 + desc->port_descs[i].scale.defaultv = 1.0; 14.161 + else if (LADSPA_IS_HINT_DEFAULT_100( 14.162 + ldesc->PortRangeHints[i].HintDescriptor)) 14.163 + desc->port_descs[i].scale.defaultv = 100.0; 14.164 + else /* LADSPA_IS_HINT_DEFAULT_440 */ 14.165 + desc->port_descs[i].scale.defaultv = 440.0; 14.166 + } 14.167 + } 14.168 + 14.169 + if ((ddesc->run_synth != NULL) || (ddesc->run_multiple_synths != NULL)) 14.170 + { 14.171 + desc->port_descs[i].name = "MIDI in"; 14.172 + 14.173 + desc->port_descs[i].data = NULL; 14.174 + desc->port_descs[i].scale.unit = nacore_scale_unit_none; 14.175 + desc->port_descs[i].scale.points = NULL; 14.176 + desc->port_descs[i].scale.points_count = 0; 14.177 + 14.178 + desc->port_descs[i].properties = NACORE_PORT_IS_MIDI; 14.179 + } 14.180 +}
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 15.2 +++ b/naspro-bridges-bad/dssi/descriptor.h Fri Sep 11 13:31:52 2009 +0200 15.3 @@ -0,0 +1,20 @@ 15.4 +/* 15.5 + * NASPRO - NASPRO Architecture for Sound Processing 15.6 + * DSSI bridge 15.7 + * 15.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 15.9 + * 15.10 + * See the COPYING file for license conditions. 15.11 + */ 15.12 + 15.13 +#ifndef _NADSSI_DESCRIPTOR_H 15.14 +#define _NADSSI_DESCRIPTOR_H 15.15 + 15.16 +#include <dssi.h> 15.17 + 15.18 +#include <NASPRO/core/lib.h> 15.19 + 15.20 +void _nadssi_descriptor_fill(struct nacore_descriptor *desc, 15.21 + const DSSI_Descriptor *ddesc); 15.22 + 15.23 +#endif /* !_NADSSI_DESCRIPTOR_H */
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 16.2 +++ b/naspro-bridges-bad/dssi/lv2api.c Fri Sep 11 13:31:52 2009 +0200 16.3 @@ -0,0 +1,322 @@ 16.4 +/* 16.5 + * NASPRO - NASPRO Architecture for Sound Processing 16.6 + * LADSPA bridge 16.7 + * 16.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 16.9 + * 16.10 + * See the COPYING file for license conditions. 16.11 + */ 16.12 + 16.13 +#include <stdlib.h> 16.14 +#include <string.h> 16.15 + 16.16 +#include <alsa/seq_event.h> 16.17 +#include <alsa/seq_midi_event.h> 16.18 + 16.19 +#include <dssi.h> 16.20 +#include <ladspa.h> 16.21 + 16.22 +#include <lv2.h> 16.23 +#include <lv2_uri_map.h> 16.24 +#include <lv2_event.h> 16.25 + 16.26 +#include <NASPRO/core/lib.h> 16.27 + 16.28 +#include "pluglib.h" 16.29 +#include "lv2api.h" 16.30 + 16.31 +#define ALSA_EV_BUF_SIZE 128 16.32 +#define DSSI_MAX_EVS 4096 16.33 + 16.34 +struct ld_desc 16.35 + { 16.36 + LV2_Descriptor lv2_desc; 16.37 + DSSI_Descriptor *d_desc; 16.38 + }; 16.39 + 16.40 +struct instance 16.41 + { 16.42 + struct ld_desc *ld_desc; 16.43 + LADSPA_Handle l_handle; 16.44 + uint16_t midi_ev_id; 16.45 + LV2_Event_Feature *lv2_ev_feat; 16.46 + snd_midi_event_t *alsa_ev_parser; 16.47 + LV2_Event_Buffer *lv2_ev_buf; 16.48 + snd_seq_event_t dssi_evs[DSSI_MAX_EVS]; 16.49 + }; 16.50 + 16.51 +static struct ld_desc *descs = NULL; 16.52 +static size_t descs_count = 0; 16.53 + 16.54 +LV2_Handle 16.55 +_nadssi_lv2api_instantiate(const LV2_Descriptor *descriptor, 16.56 + double sample_rate, const char *bundle_path, 16.57 + const LV2_Feature * const *features) 16.58 +{ 16.59 + const LADSPA_Descriptor *ldesc; 16.60 + LADSPA_Handle *handle; 16.61 + struct instance *instance; 16.62 + LV2_URI_Map_Feature *lv2_uri_map_feat; 16.63 + size_t i; 16.64 + 16.65 + instance = malloc(sizeof(struct instance)); 16.66 + if (instance == NULL) 16.67 + return NULL; 16.68 + 16.69 + lv2_uri_map_feat = NULL; 16.70 + instance->lv2_ev_feat = NULL; 16.71 + for (i = 0; features[i] != NULL; i++) 16.72 + { 16.73 + if (!strcmp(features[i]->URI, 16.74 + "http://lv2plug.in/ns/ext/uri-map")) 16.75 + { 16.76 + lv2_uri_map_feat = features[i]->data; 16.77 + continue; 16.78 + } 16.79 + if (!strcmp(features[i]->URI, "http://lv2plug.in/ns/ext/event")) 16.80 + { 16.81 + instance->lv2_ev_feat = features[i]->data; 16.82 + continue; 16.83 + } 16.84 + } 16.85 + 16.86 + if ((lv2_uri_map_feat == NULL) || (instance->lv2_ev_feat == NULL)) 16.87 + { 16.88 + free(instance); 16.89 + return NULL; 16.90 + } 16.91 + 16.92 + instance->midi_ev_id = 16.93 + lv2_uri_map_feat->uri_to_id(lv2_uri_map_feat->callback_data, 16.94 + "http://lv2plug.in/ns/ext/event", 16.95 + "http://lv2plug.in/ns/ext/midi#MidiEvent"); 16.96 + if (instance->midi_ev_id == 0) 16.97 + { 16.98 + free(instance); 16.99 + return NULL; 16.100 + } 16.101 + 16.102 + if (snd_midi_event_new(ALSA_EV_BUF_SIZE, &instance->alsa_ev_parser) < 0) 16.103 + { 16.104 + free(instance); 16.105 + return NULL; 16.106 + } 16.107 + snd_midi_event_init(instance->alsa_ev_parser); 16.108 + 16.109 + /* This should work correctly according to the ANSI C standard. */ 16.110 + ldesc = ((struct ld_desc *)descriptor)->d_desc->LADSPA_Plugin; 16.111 + 16.112 + handle = ldesc->instantiate(ldesc, sample_rate); 16.113 + if (handle == NULL) 16.114 + { 16.115 + snd_midi_event_free(instance->alsa_ev_parser); 16.116 + free(instance); 16.117 + return NULL; 16.118 + } 16.119 + 16.120 + instance->ld_desc = (struct ld_desc *)descriptor; 16.121 + instance->l_handle = handle; 16.122 + 16.123 + return (LV2_Handle)instance; 16.124 +} 16.125 + 16.126 +void 16.127 +_nadssi_lv2api_connect_port(LV2_Handle instance, uint32_t port, 16.128 + void *data_location) 16.129 +{ 16.130 + struct instance *i; 16.131 + 16.132 + /* This is needed to avoid a little incompatibility beetween LADSPA and 16.133 + * LV2. LADSPA's connect_port() does not specify whether data_location 16.134 + * is valid at the time it is being run, while LV2 mandates the plugin 16.135 + * not to trust the memory location indicated by the pointer at the time 16.136 + * connect_port() is run. */ 16.137 + if (data_location == NULL) 16.138 + return; 16.139 + 16.140 + i = ((struct instance *)instance); 16.141 + 16.142 + if (port == i->ld_desc->d_desc->LADSPA_Plugin->PortCount) 16.143 + i->lv2_ev_buf = (LV2_Event_Buffer *)data_location; 16.144 + else 16.145 + i->ld_desc->d_desc->LADSPA_Plugin->connect_port(i->l_handle, 16.146 + port, data_location); 16.147 +} 16.148 + 16.149 +void 16.150 +_nadssi_lv2api_activate(LV2_Handle instance) 16.151 +{ 16.152 + struct instance *i; 16.153 + 16.154 + i = (struct instance *)instance; 16.155 + 16.156 + i->ld_desc->d_desc->LADSPA_Plugin->activate(i->l_handle); 16.157 +} 16.158 + 16.159 +static int 16.160 +cmp_timestamp(const void *e1, const void *e2) 16.161 +{ 16.162 + if (((snd_seq_event_t *)e1)->time.tick 16.163 + < ((snd_seq_event_t *)e2)->time.tick) 16.164 + return -1; 16.165 + else if (((snd_seq_event_t *)e1)->time.tick 16.166 + > ((snd_seq_event_t *)e2)->time.tick) 16.167 + return 1; 16.168 + else 16.169 + return 0; 16.170 +} 16.171 + 16.172 +void 16.173 +_nadssi_lv2api_run(LV2_Handle instance, uint32_t sample_count) 16.174 +{ 16.175 + struct instance *i; 16.176 + size_t j; 16.177 + unsigned char *p, *data; 16.178 + LV2_Event *lv2_ev; 16.179 + snd_seq_event_t alsa_ev; 16.180 + snd_seq_event_t *dssi_ev_p; 16.181 + unsigned long cnt; 16.182 + long err; 16.183 + 16.184 + i = (struct instance *)instance; 16.185 + 16.186 + if ((i->ld_desc->d_desc->run_synth != NULL) 16.187 + || (i->ld_desc->d_desc->run_multiple_synths != NULL)) 16.188 + { 16.189 + /* Convert LV2 MIDI events to ALSA sequencer events */ 16.190 + p = i->lv2_ev_buf->data; 16.191 + dssi_ev_p = i->dssi_evs; 16.192 + cnt = 0; 16.193 + for (j = 0; j < (i->lv2_ev_buf->event_count) 16.194 + && ((dssi_ev_p - i->dssi_evs) < DSSI_MAX_EVS); j++) 16.195 + { 16.196 + lv2_ev = (LV2_Event *)p; 16.197 + p += sizeof(LV2_Event); 16.198 + data = p; 16.199 + p += lv2_ev->size 16.200 + + ((lv2_ev->size % 8) ? (8 - lv2_ev->size % 8) 16.201 + : 0); 16.202 + 16.203 + if (lv2_ev->type == 0) 16.204 + { 16.205 + i->lv2_ev_feat->lv2_event_unref( 16.206 + i->lv2_ev_feat->callback_data, lv2_ev); 16.207 + continue; 16.208 + } 16.209 + else if (lv2_ev->type != i->midi_ev_id) 16.210 + continue; 16.211 + 16.212 + err = snd_midi_event_encode(i->alsa_ev_parser, data, 16.213 + lv2_ev->size, &alsa_ev); 16.214 + if (err < 0) 16.215 + { 16.216 + snd_midi_event_reset_encode(i->alsa_ev_parser); 16.217 + break; 16.218 + } 16.219 + 16.220 +#if 0 16.221 + if ((alsa_ev.type == SND_SEQ_EVENT_NONE) 16.222 + || (alsa_ev.type == SND_SEQ_EVENT_CONTROLLER) 16.223 + || (alsa_ev.type == SND_SEQ_EVENT_PGMCHANGE) 16.224 + || (alsa_ev.type == SND_SEQ_EVENT_CHANPRESS)) 16.225 + continue; 16.226 +#endif 16.227 + 16.228 + alsa_ev.time.tick = lv2_ev->frames; 16.229 + 16.230 + *dssi_ev_p = alsa_ev; 16.231 + dssi_ev_p++; 16.232 + cnt++; 16.233 + } 16.234 + 16.235 + /* Order ALSA sequencer events by timestamp */ 16.236 + qsort(i->dssi_evs, cnt, sizeof(snd_seq_event_t), cmp_timestamp); 16.237 + } 16.238 + 16.239 + if (i->ld_desc->d_desc->run_synth != NULL) 16.240 + i->ld_desc->d_desc->run_synth(i->l_handle, sample_count, 16.241 + i->dssi_evs, cnt); 16.242 + else if (i->ld_desc->d_desc->run_multiple_synths != NULL) 16.243 + i->ld_desc->d_desc->run_multiple_synths( 16.244 + 1, &i->l_handle, sample_count, &i->dssi_evs, &cnt); 16.245 + else 16.246 + i->ld_desc->d_desc->LADSPA_Plugin->run(i->l_handle, 16.247 + sample_count); 16.248 +} 16.249 + 16.250 +void 16.251 +_nadssi_lv2api_deactivate(LV2_Handle instance) 16.252 +{ 16.253 + struct instance *i; 16.254 + 16.255 + i = (struct instance *)instance; 16.256 + 16.257 + i->ld_desc->d_desc->LADSPA_Plugin->deactivate(i->l_handle); 16.258 +} 16.259 + 16.260 +void 16.261 +_nadssi_lv2api_cleanup(LV2_Handle instance) 16.262 +{ 16.263 + struct instance *i; 16.264 + 16.265 + i = (struct instance *)instance; 16.266 + 16.267 + i->ld_desc->d_desc->LADSPA_Plugin->cleanup(i->l_handle); 16.268 + snd_midi_event_free(i->alsa_ev_parser); 16.269 + free(i); 16.270 +} 16.271 + 16.272 +static void 16.273 +generate_desc(void *content, void *data) 16.274 +{ 16.275 + struct nacore_descriptor *ndesc; 16.276 + DSSI_Descriptor *ddesc; 16.277 + struct ld_desc *lddesc; 16.278 + size_t *n; 16.279 + 16.280 + n = (size_t *)data; 16.281 + lddesc = descs + *n; 16.282 + ndesc = (struct nacore_descriptor *)content; 16.283 + ddesc = (DSSI_Descriptor *)ndesc->data; 16.284 + 16.285 + nacore_lv2api_fill_desc(&lddesc->lv2_desc, ndesc); 16.286 + lddesc->d_desc = ddesc; 16.287 + 16.288 + (*n)++; 16.289 +} 16.290 + 16.291 +int 16.292 +_nadssi_lv2api_generate_descs() 16.293 +{ 16.294 + size_t n; 16.295 + 16.296 + n = nacore_avl_tree_get_nodes_count(_nadssi_pluglib_desc_tree); 16.297 + descs = malloc(n * sizeof(struct ld_desc)); 16.298 + if (descs == NULL) 16.299 + return -1; 16.300 + 16.301 + descs_count = n; 16.302 + 16.303 + n = 0; 16.304 + nacore_avl_tree_for_each(_nadssi_pluglib_desc_tree, generate_desc, 16.305 + &n); 16.306 + 16.307 + return 0; 16.308 +} 16.309 + 16.310 +void 16.311 +_nadssi_lv2api_free_descs() 16.312 +{ 16.313 + free(descs); 16.314 + descs = NULL; 16.315 + descs_count = 0; 16.316 +} 16.317 + 16.318 +const LV2_Descriptor * 16.319 +lv2_descriptor(uint32_t index) 16.320 +{ 16.321 + if (index >= descs_count) 16.322 + return NULL; 16.323 + 16.324 + return &descs[index].lv2_desc; 16.325 +}
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 17.2 +++ b/naspro-bridges-bad/dssi/lv2api.h Fri Sep 11 13:31:52 2009 +0200 17.3 @@ -0,0 +1,31 @@ 17.4 +/* 17.5 + * NASPRO - NASPRO Architecture for Sound Processing 17.6 + * DSSI bridge 17.7 + * 17.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 17.9 + * 17.10 + * See the COPYING file for license conditions. 17.11 + */ 17.12 + 17.13 +#ifndef _NADSSI_LV2API_H 17.14 +#define _NADSSI_LV2API_H 17.15 + 17.16 +#include <stdlib.h> 17.17 + 17.18 +#include <lv2.h> 17.19 + 17.20 +LV2_Handle _nadssi_lv2api_instantiate(const LV2_Descriptor *descriptor, 17.21 + double sample_rate, 17.22 + const char *bundle_path, 17.23 + const LV2_Feature * const *features); 17.24 +void _nadssi_lv2api_connect_port(LV2_Handle instance, uint32_t port, 17.25 + void *data_location); 17.26 +void _nadssi_lv2api_activate(LV2_Handle instance); 17.27 +void _nadssi_lv2api_run(LV2_Handle instance, uint32_t sample_count); 17.28 +void _nadssi_lv2api_deactivate(LV2_Handle instance); 17.29 +void _nadssi_lv2api_cleanup(LV2_Handle instance); 17.30 + 17.31 +int _nadssi_lv2api_generate_descs(); 17.32 +void _nadssi_lv2api_free_descs(); 17.33 + 17.34 +#endif /* !_NADSSI_LV2API_H */
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 18.2 +++ b/naspro-bridges-bad/dssi/manifest.c Fri Sep 11 13:31:52 2009 +0200 18.3 @@ -0,0 +1,102 @@ 18.4 +/* 18.5 + * NASPRO - NASPRO Architecture for Sound Processing 18.6 + * DSSI bridge 18.7 + * 18.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 18.9 + * 18.10 + * See the COPYING file for license conditions. 18.11 + */ 18.12 + 18.13 +#include <stdio.h> 18.14 + 18.15 +#include <lv2_dyn_manifest.h> 18.16 + 18.17 +#include <NASPRO/core/lib.h> 18.18 + 18.19 +#include "pluglib.h" 18.20 +#include "lv2api.h" 18.21 + 18.22 +/* TODO: Until a serious rescan/automagical discovery policy emerges, we perform 18.23 + * discovery only once at initialization time. */ 18.24 + 18.25 +static char inited = 0; 18.26 +static char descs_ok = 0; 18.27 + 18.28 +int 18.29 +lv2_dyn_manifest_open(LV2_Dyn_Manifest_Handle *handle, 18.30 + const LV2_Feature *const *features) 18.31 +{ 18.32 + static char called = 0; 18.33 + 18.34 + if (called) 18.35 + return -1; 18.36 + called = 1; 18.37 + 18.38 + if (!inited) 18.39 + { 18.40 + _nadssi_pluglib_load_all(); 18.41 + descs_ok = _nadssi_lv2api_generate_descs() >= 0; 18.42 + inited = 1; 18.43 + } 18.44 + 18.45 + *handle = NULL; 18.46 + 18.47 + if (_nadssi_pluglib_desc_tree == NULL) 18.48 + return -1; 18.49 + 18.50 + called = 0; 18.51 + 18.52 + return 0; 18.53 +} 18.54 + 18.55 +static void __attribute__((destructor)) 18.56 +fini() 18.57 +{ 18.58 + _nadssi_pluglib_unload_all(); 18.59 + _nadssi_lv2api_free_descs(); 18.60 +} 18.61 + 18.62 +static void 18.63 +print_subject(void *content, void *data) 18.64 +{ 18.65 + nacore_manifest_print_subject_triple( 18.66 + (struct nacore_descriptor *)content, (FILE *)data); 18.67 +} 18.68 + 18.69 +int 18.70 +lv2_dyn_manifest_get_subjects(LV2_Dyn_Manifest_Handle handle, FILE *fp) 18.71 +{ 18.72 + if (descs_ok == 0) 18.73 + return 0; 18.74 + 18.75 + nacore_manifest_print_subject_prefixes(fp); 18.76 + 18.77 + nacore_avl_tree_for_each(_nadssi_pluglib_desc_tree, print_subject, 18.78 + (void *)fp); 18.79 + 18.80 + return 0; 18.81 +} 18.82 + 18.83 +int 18.84 +lv2_dyn_manifest_get_data(LV2_Dyn_Manifest_Handle handle, FILE *fp, 18.85 + const char *uri) 18.86 +{ 18.87 + struct nacore_descriptor *d; 18.88 + 18.89 + if (descs_ok == 0) 18.90 + return 0; 18.91 + 18.92 + d = (struct nacore_descriptor *)nacore_avl_tree_find( 18.93 + _nadssi_pluglib_desc_tree, (void *)uri); 18.94 + if (d == NULL) 18.95 + return -1; 18.96 + 18.97 + nacore_manifest_print_data(d, fp, "dssi"); 18.98 + 18.99 + return 0; 18.100 +} 18.101 + 18.102 +void 18.103 +lv2_dyn_manifest_close(LV2_Dyn_Manifest_Handle handle) 18.104 +{ 18.105 +}
19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 19.2 +++ b/naspro-bridges-bad/dssi/manifest.ttl Fri Sep 11 13:31:52 2009 +0200 19.3 @@ -0,0 +1,14 @@ 19.4 +# 19.5 +# NASPRO - NASPRO Architecture for Sound Processing 19.6 +# DSSI bridge 19.7 +# 19.8 +# Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 19.9 +# 19.10 +# See the COPYING file for license conditions. 19.11 +# 19.12 + 19.13 +@prefix lv2: <http://lv2plug.in/ns/lv2core#>. 19.14 +@prefix dman: <http://lv2plug.in/ns/ext/dynmanifest#>. 19.15 + 19.16 +<http://naspro.atheme.org/dssi> a dman:DynManifest; 19.17 + lv2:binary <dssi.so>.
20.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 20.2 +++ b/naspro-bridges-bad/dssi/pluglib.c Fri Sep 11 13:31:52 2009 +0200 20.3 @@ -0,0 +1,228 @@ 20.4 +/* 20.5 + * NASPRO - NASPRO Architecture for Sound Processing 20.6 + * DSSI bridge 20.7 + * 20.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 20.9 + * 20.10 + * See the COPYING file for license conditions. 20.11 + */ 20.12 + 20.13 +#include <stdlib.h> 20.14 +#include <stdio.h> 20.15 +#include <string.h> 20.16 +#include <errno.h> 20.17 + 20.18 +#include <dssi.h> 20.19 + 20.20 +#include <NASPRO/core/lib.h> 20.21 + 20.22 +#include "pluglib.h" 20.23 +#include "descriptor.h" 20.24 +#include "lrdf.h" 20.25 + 20.26 +nacore_avl_tree_t _nadssi_pluglib_desc_tree = NULL; 20.27 + 20.28 +struct pluglib 20.29 + { 20.30 + nacore_dl_module_t dl_module; 20.31 + struct nacore_descriptor *descs; 20.32 + size_t descs_count; 20.33 + struct nacore_port_descriptor *port_descs; 20.34 + size_t port_descs_count; 20.35 + char *uris; 20.36 + size_t uris_size; 20.37 + }; 20.38 + 20.39 +static struct pluglib *pluglibs = NULL; 20.40 +static size_t pluglibs_count = 0; 20.41 + 20.42 +static void 20.43 +pluglib_load(const char *file, const char *basename, void *data) 20.44 +{ 20.45 + nacore_dl_module_t dl_module; 20.46 + const DSSI_Descriptor *ddesc; 20.47 + DSSI_Descriptor_Function get_desc; 20.48 + struct pluglib *tmp_pluglibs; 20.49 + struct nacore_descriptor *tmp_descs; 20.50 + struct nacore_port_descriptor *tmp_port_descs; 20.51 + char *tmp_uris; 20.52 + size_t descs_count, ports_count, uris_size; 20.53 + unsigned long i; 20.54 + 20.55 + dl_module = nacore_dl_open(file); 20.56 + if (dl_module == NULL) 20.57 + goto dl_open_err; 20.58 + 20.59 + if (nacore_dl_sym(dl_module, "naspro_backbridge") != NULL) 20.60 + goto backbridge; 20.61 + 20.62 + *(void **)(&get_desc) = nacore_dl_sym(dl_module, "dssi_descriptor"); 20.63 + if (get_desc == NULL) 20.64 + goto get_desc_err; 20.65 + 20.66 + for (i = 0, descs_count = 0, ports_count = 0, uris_size = 0; 20.67 + (ddesc = get_desc(i)) != NULL; i++) 20.68 + { 20.69 + if (ddesc->DSSI_API_Version != 1) 20.70 + continue; 20.71 + 20.72 + ports_count += ddesc->LADSPA_Plugin->PortCount; 20.73 + if ((ddesc->run_synth != NULL) 20.74 + || (ddesc->run_multiple_synths != NULL)) 20.75 + ports_count++; 20.76 + uris_size += strlen(basename) 20.77 + + strlen(ddesc->LADSPA_Plugin->Label) + 11; 20.78 + descs_count++; 20.79 + } 20.80 + if (descs_count == 0) 20.81 + goto no_desc; 20.82 + 20.83 + tmp_descs = malloc(descs_count * sizeof(struct nacore_descriptor)); 20.84 + if (tmp_descs == NULL) 20.85 + goto descs_err; 20.86 + 20.87 + tmp_port_descs = NULL; 20.88 + if (ports_count != 0) 20.89 + { 20.90 + tmp_port_descs = malloc(ports_count 20.91 + * sizeof(struct nacore_port_descriptor)); 20.92 + if (tmp_port_descs == NULL) 20.93 + goto port_descs_err; 20.94 + } 20.95 + 20.96 + tmp_uris = malloc(uris_size); 20.97 + if (tmp_uris == NULL) 20.98 + goto uris_err; 20.99 + 20.100 + tmp_pluglibs = realloc(pluglibs, 20.101 + (pluglibs_count + 1) * sizeof(struct pluglib)); 20.102 + if (tmp_pluglibs == NULL) 20.103 + goto pluglibs_err; 20.104 + 20.105 + pluglibs = tmp_pluglibs; 20.106 + tmp_pluglibs = pluglibs + pluglibs_count; 20.107 + pluglibs_count++; 20.108 + 20.109 + tmp_pluglibs->dl_module = dl_module; 20.110 + 20.111 + tmp_pluglibs->descs = tmp_descs; 20.112 + tmp_pluglibs->descs_count = descs_count; 20.113 + tmp_pluglibs->port_descs = tmp_port_descs; 20.114 + tmp_pluglibs->port_descs_count = ports_count; 20.115 + tmp_pluglibs->uris = tmp_uris; 20.116 + tmp_pluglibs->uris_size = uris_size; 20.117 + 20.118 + for (i = 0, descs_count = 0, ports_count = 0, uris_size = 0; 20.119 + (ddesc = get_desc(i)) != NULL; i++) 20.120 + { 20.121 + if (ddesc->DSSI_API_Version != 1) 20.122 + continue; 20.123 + 20.124 + tmp_pluglibs->descs[descs_count].port_descs = 20.125 + tmp_pluglibs->port_descs + ports_count; 20.126 + tmp_pluglibs->descs[descs_count].port_descs_count = 20.127 + ddesc->LADSPA_Plugin->PortCount; 20.128 + if ((ddesc->run_synth != NULL) 20.129 + || (ddesc->run_multiple_synths != NULL)) 20.130 + tmp_pluglibs->descs[descs_count].port_descs_count++; 20.131 + tmp_pluglibs->descs[descs_count].uri = 20.132 + tmp_pluglibs->uris + uris_size; 20.133 + sprintf(tmp_pluglibs->descs[descs_count].uri, "urn:dssi:%s:%s", 20.134 + basename, ddesc->LADSPA_Plugin->Label); 20.135 + 20.136 + _nadssi_descriptor_fill(tmp_pluglibs->descs + descs_count, 20.137 + ddesc); 20.138 + 20.139 + nacore_avl_tree_add(_nadssi_pluglib_desc_tree, 20.140 + tmp_pluglibs->descs + descs_count); 20.141 + 20.142 + ports_count += ddesc->LADSPA_Plugin->PortCount; 20.143 + if ((ddesc->run_synth != NULL) 20.144 + || (ddesc->run_multiple_synths != NULL)) 20.145 + ports_count++; 20.146 + uris_size += strlen(basename) 20.147 + + strlen(ddesc->LADSPA_Plugin->Label) + 11; 20.148 + descs_count++; 20.149 + } 20.150 + 20.151 + return; 20.152 + 20.153 +pluglibs_err: 20.154 + free(tmp_uris); 20.155 +uris_err: 20.156 + if (tmp_port_descs != NULL) 20.157 + free(tmp_port_descs); 20.158 +port_descs_err: 20.159 + free(tmp_descs); 20.160 +descs_err: 20.161 +no_desc: 20.162 +get_desc_err: 20.163 +backbridge: 20.164 + nacore_dl_close(dl_module); 20.165 +dl_open_err: 20.166 + return; 20.167 +} 20.168 + 20.169 +void 20.170 +_nadssi_pluglib_load_all() 20.171 +{ 20.172 + char *dssi_path; 20.173 + char *ladspa_path; 20.174 + 20.175 + _nadssi_pluglib_desc_tree = nacore_avl_tree_new( 20.176 + nacore_content_cmp_descriptor_by_uri, 20.177 + nacore_key_cmp_descriptor_by_uri); 20.178 + if (_nadssi_pluglib_desc_tree == NULL) 20.179 + return; 20.180 + 20.181 + dssi_path = nacore_env_get_var("DSSI_PATH"); 20.182 + ladspa_path = nacore_env_get_var("LADSPA_PATH"); 20.183 + if (NACORE_STRING_IS_NULL_OR_EMPTY(ladspa_path) 20.184 + && NACORE_STRING_IS_NULL_OR_EMPTY(dssi_path)) 20.185 + { 20.186 + /* TODO: This is *nix-only */ 20.187 + nacore_path_home_for_each(".dssi", pluglib_load, 20.188 + nacore_dl_filename_filter, NULL); 20.189 + nacore_path_for_each("/usr/local/lib/dssi:/usr/lib/dssi", 20.190 + pluglib_load, nacore_dl_filename_filter, 20.191 + NULL); 20.192 + } 20.193 + else 20.194 + { 20.195 + if (!NACORE_STRING_IS_NULL_OR_EMPTY(dssi_path)) 20.196 + nacore_path_for_each(dssi_path, pluglib_load, 20.197 + nacore_dl_filename_filter, NULL); 20.198 + if (!NACORE_STRING_IS_NULL_OR_EMPTY(ladspa_path)) 20.199 + nacore_path_for_each(ladspa_path, pluglib_load, 20.200 + nacore_dl_filename_filter, NULL); 20.201 + } 20.202 + 20.203 + if (ladspa_path != NULL) 20.204 + nacore_env_free_var_value(ladspa_path); 20.205 + if (dssi_path != NULL) 20.206 + nacore_env_free_var_value(dssi_path); 20.207 +} 20.208 + 20.209 +void 20.210 +_nadssi_pluglib_unload_all() 20.211 +{ 20.212 + size_t i; 20.213 + 20.214 + if (pluglibs == NULL) 20.215 + return; 20.216 + 20.217 + for (i = 0; i < pluglibs_count; i++) 20.218 + { 20.219 + nacore_dl_close(pluglibs[i].dl_module); 20.220 + free(pluglibs[i].descs); 20.221 + free(pluglibs[i].port_descs); 20.222 + free(pluglibs[i].uris); 20.223 + } 20.224 + 20.225 + free(pluglibs); 20.226 + pluglibs = NULL; 20.227 + pluglibs_count = 0; 20.228 + 20.229 + nacore_avl_tree_free(_nadssi_pluglib_desc_tree); 20.230 + _nadssi_pluglib_desc_tree = NULL; 20.231 +}
21.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 21.2 +++ b/naspro-bridges-bad/dssi/pluglib.h Fri Sep 11 13:31:52 2009 +0200 21.3 @@ -0,0 +1,20 @@ 21.4 +/* 21.5 + * NASPRO - NASPRO Architecture for Sound Processing 21.6 + * DSSI bridge 21.7 + * 21.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 21.9 + * 21.10 + * See the COPYING file for license conditions. 21.11 + */ 21.12 + 21.13 +#ifndef _NADSSI_PLUGLIB_H 21.14 +#define _NADSSI_PLUGLIB_H 21.15 + 21.16 +#include <NASPRO/core/lib.h> 21.17 + 21.18 +void _nadssi_pluglib_load_all(); 21.19 +void _nadssi_pluglib_unload_all(); 21.20 + 21.21 +nacore_avl_tree_t _nadssi_pluglib_desc_tree; 21.22 + 21.23 +#endif /* !_NADSSI_PLUGLIB_H */
22.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 22.2 +++ b/naspro-bridges-bad/ladspa/Makefile Fri Sep 11 13:31:52 2009 +0200 22.3 @@ -0,0 +1,48 @@ 22.4 +.POSIX: 22.5 + 22.6 +.SUFFIXES: 22.7 + 22.8 +### Change this... 22.9 + 22.10 +PREFIX = /usr/local 22.11 +LIB_DIR = $(PREFIX)/lib 22.12 + 22.13 +LV2_DIR = $(LIB_DIR)/lv2 22.14 + 22.15 +LADSPA_BRIDGE_BUNDLE_DIR = $(LV2_DIR)/naspro-ladspa.lv2 22.16 + 22.17 +CC = gcc 22.18 +CFLAGS = -O2 -ansi -pedantic -Wall -fPIC 22.19 + 22.20 +DL_LDFLAGS = -ldl 22.21 +LDFLAGS = -shared $(DL_LDFLAGS) 22.22 + 22.23 +SO_FILE_EXT = .so 22.24 + 22.25 +### ... but not this 22.26 + 22.27 +TARGETS = ladspa.so 22.28 + 22.29 +LADSPA_BRIDGE_SOURCES = descriptor.c \ 22.30 + descriptor.h \ 22.31 + lrdf.c \ 22.32 + lrdf.h \ 22.33 + lv2api.c \ 22.34 + lv2api.h \ 22.35 + manifest.c \ 22.36 + pluglib.c \ 22.37 + pluglib.h 22.38 +LADSPA_BRIDGE_LIBS = -lnacore -lrdf 22.39 + 22.40 +all: $(TARGETS) 22.41 + 22.42 +ladspa.so: $(LADSPA_BRIDGE_SOURCES) 22.43 + $(CC) $(CFLAGS) $(LDFLAGS) $(LADSPA_BRIDGE_SOURCES) \ 22.44 + $(LADSPA_BRIDGE_LIBS) -o $@ 22.45 + 22.46 +install: $(TARGETS) manifest.ttl 22.47 + mkdir -p $(LADSPA_BRIDGE_BUNDLE_DIR) 22.48 + cp ladspa.so manifest.ttl $(LADSPA_BRIDGE_BUNDLE_DIR) 22.49 + 22.50 +clean: 22.51 + rm -f $(TARGETS)
23.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 23.2 +++ b/naspro-bridges-bad/ladspa/descriptor.c Fri Sep 11 13:31:52 2009 +0200 23.3 @@ -0,0 +1,174 @@ 23.4 +/* 23.5 + * NASPRO - NASPRO Architecture for Sound Processing 23.6 + * LADSPA bridge 23.7 + * 23.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 23.9 + * 23.10 + * See the COPYING file for license conditions. 23.11 + */ 23.12 + 23.13 +#include <stddef.h> 23.14 +#include <string.h> 23.15 + 23.16 +#include <math.h> 23.17 + 23.18 +#include <ladspa.h> 23.19 + 23.20 +#include <NASPRO/core/lib.h> 23.21 + 23.22 +#include "descriptor.h" 23.23 +#include "lrdf.h" 23.24 +#include "lv2api.h" 23.25 + 23.26 +void 23.27 +_naladspa_descriptor_fill(struct nacore_descriptor *desc, 23.28 + const LADSPA_Descriptor *ldesc) 23.29 +{ 23.30 + size_t i; 23.31 + 23.32 + desc->data = (void *)ldesc; 23.33 + 23.34 + desc->name = (char *)ldesc->Name; 23.35 + desc->creator = (*ldesc->Maker != '\0') ? NULL : (char *)ldesc->Maker; 23.36 + desc->rights = strcmp(ldesc->Copyright, "None") 23.37 + ? (char *)ldesc->Copyright : NULL; 23.38 + 23.39 + desc->instantiate = _naladspa_lv2api_instantiate; 23.40 + desc->connect_port = _naladspa_lv2api_connect_port; 23.41 + desc->activate = ldesc->activate != NULL ? _naladspa_lv2api_activate 23.42 + : NULL; 23.43 + desc->run = _naladspa_lv2api_run; 23.44 + desc->deactivate = ldesc->deactivate != NULL 23.45 + ? _naladspa_lv2api_deactivate : NULL; 23.46 + desc->cleanup = _naladspa_lv2api_cleanup; 23.47 + desc->extension_data = NULL; 23.48 + 23.49 + desc->properties = 0; 23.50 + if (LADSPA_IS_REALTIME(ldesc->Properties)) 23.51 + desc->properties |= NACORE_DESCRIPTOR_HAS_LIVE_DEP; 23.52 + if (LADSPA_IS_INPLACE_BROKEN(ldesc->Properties)) 23.53 + desc->properties |= NACORE_DESCRIPTOR_INPLACE_BROKEN; 23.54 + if (LADSPA_IS_HARD_RT_CAPABLE(ldesc->Properties)) 23.55 + desc->properties |= NACORE_DESCRIPTOR_HARD_RT_CAPABLE; 23.56 + 23.57 + desc->classes_1 = 0; 23.58 + desc->classes_2 = 0; 23.59 + _naladspa_lrdf_get_classes(desc); 23.60 + 23.61 + for (i = 0; i < desc->port_descs_count; i++) 23.62 + { 23.63 + /* This check is due to Josh Green's broken vocoder plugin */ 23.64 + if (ldesc->PortNames[i] == NULL) 23.65 + desc->port_descs[i].name = "(null)"; 23.66 + else 23.67 + desc->port_descs[i].name = (char *)ldesc->PortNames[i]; 23.68 + 23.69 + desc->port_descs[i].data = NULL; 23.70 + desc->port_descs[i].scale.unit = nacore_scale_unit_none; 23.71 + desc->port_descs[i].scale.points = NULL; 23.72 + desc->port_descs[i].scale.points_count = 0; 23.73 + 23.74 + desc->port_descs[i].properties = 0; 23.75 + if (LADSPA_IS_PORT_OUTPUT(ldesc->PortDescriptors[i])) 23.76 + desc->port_descs[i].properties |= NACORE_PORT_IS_OUTPUT; 23.77 + if (LADSPA_IS_PORT_AUDIO(ldesc->PortDescriptors[i])) 23.78 + desc->port_descs[i].properties |= NACORE_PORT_IS_AUDIO; 23.79 + 23.80 + if (desc->port_descs[i].properties & NACORE_PORT_IS_AUDIO) 23.81 + continue; 23.82 + 23.83 + if (!strcmp(ldesc->PortNames[i], "latency") 23.84 + || !strcmp(ldesc->PortNames[i], "_latency")) 23.85 + desc->port_descs[i].properties |= 23.86 + NACORE_PORT_REPORTS_LATENCY; 23.87 + if (LADSPA_IS_HINT_TOGGLED( 23.88 + ldesc->PortRangeHints[i].HintDescriptor)) 23.89 + desc->port_descs[i].properties |= NACORE_PORT_TOGGLED; 23.90 + if (LADSPA_IS_HINT_SAMPLE_RATE( 23.91 + ldesc->PortRangeHints[i].HintDescriptor)) 23.92 + desc->port_descs[i].properties |= 23.93 + NACORE_PORT_SAMPLE_RATE; 23.94 + if (LADSPA_IS_HINT_INTEGER( 23.95 + ldesc->PortRangeHints[i].HintDescriptor)) 23.96 + desc->port_descs[i].properties |= NACORE_PORT_INTEGER; 23.97 + if (LADSPA_IS_HINT_LOGARITHMIC( 23.98 + ldesc->PortRangeHints[i].HintDescriptor)) 23.99 + desc->port_descs[i].properties |= 23.100 + NACORE_PORT_LOGARITHMIC; 23.101 + 23.102 + desc->port_descs[i].scale.properties = 0; 23.103 + if (LADSPA_IS_HINT_BOUNDED_BELOW( 23.104 + ldesc->PortRangeHints[i].HintDescriptor)) 23.105 + { 23.106 + desc->port_descs[i].scale.properties |= 23.107 + NACORE_SCALE_HAS_MIN; 23.108 + desc->port_descs[i].scale.min = 23.109 + ldesc->PortRangeHints[i].LowerBound; 23.110 + } 23.111 + if (LADSPA_IS_HINT_BOUNDED_ABOVE( 23.112 + ldesc->PortRangeHints[i].HintDescriptor)) 23.113 + { 23.114 + desc->port_descs[i].scale.properties |= 23.115 + NACORE_SCALE_HAS_MAX; 23.116 + desc->port_descs[i].scale.max = 23.117 + ldesc->PortRangeHints[i].UpperBound; 23.118 + } 23.119 + if (LADSPA_IS_HINT_HAS_DEFAULT( 23.120 + ldesc->PortRangeHints[i].HintDescriptor)) 23.121 + { 23.122 + desc->port_descs[i].scale.properties |= 23.123 + NACORE_SCALE_HAS_DEFAULT; 23.124 + if (LADSPA_IS_HINT_DEFAULT_MINIMUM( 23.125 + ldesc->PortRangeHints[i].HintDescriptor)) 23.126 + desc->port_descs[i].scale.defaultv = 23.127 + desc->port_descs[i].scale.min; 23.128 + else if (LADSPA_IS_HINT_DEFAULT_LOW( 23.129 + ldesc->PortRangeHints[i].HintDescriptor)) 23.130 + desc->port_descs[i].scale.defaultv = 23.131 + (desc->port_descs[i].properties & NACORE_PORT_LOGARITHMIC) 23.132 + ? exp(log(desc->port_descs[i].scale.min) * 0.75 + log(desc->port_descs[i].scale.max) * 0.25) 23.133 + : desc->port_descs[i].scale.min * 0.75 + desc->port_descs[i].scale.max * 0.25; 23.134 + else if (LADSPA_IS_HINT_DEFAULT_MIDDLE( 23.135 + ldesc->PortRangeHints[i].HintDescriptor)) 23.136 + desc->port_descs[i].scale.defaultv = 23.137 + (desc->port_descs[i].properties & NACORE_PORT_LOGARITHMIC) 23.138 + ? exp(log(desc->port_descs[i].scale.min) * 0.5 + log(desc->port_descs[i].scale.max) * 0.5) 23.139 + : desc->port_descs[i].scale.min * 0.5 + desc->port_descs[i].scale.max * 0.5; 23.140 + else if (LADSPA_IS_HINT_DEFAULT_HIGH( 23.141 + ldesc->PortRangeHints[i].HintDescriptor)) 23.142 + desc->port_descs[i].scale.defaultv = 23.143 + (desc->port_descs[i].properties & NACORE_PORT_LOGARITHMIC) 23.144 + ? exp(log(desc->port_descs[i].scale.min) * 0.25 + log(desc->port_descs[i].scale.max) * 0.75) 23.145 + : desc->port_descs[i].scale.min * 0.25 + desc->port_descs[i].scale.max * 0.75; 23.146 + else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM( 23.147 + ldesc->PortRangeHints[i].HintDescriptor)) 23.148 + desc->port_descs[i].scale.defaultv = 23.149 + desc->port_descs[i].scale.max; 23.150 + else if (LADSPA_IS_HINT_DEFAULT_0( 23.151 + ldesc->PortRangeHints[i].HintDescriptor)) 23.152 + desc->port_descs[i].scale.defaultv = 0.0; 23.153 + else if (LADSPA_IS_HINT_DEFAULT_1( 23.154 + ldesc->PortRangeHints[i].HintDescriptor)) 23.155 + desc->port_descs[i].scale.defaultv = 1.0; 23.156 + else if (LADSPA_IS_HINT_DEFAULT_100( 23.157 + ldesc->PortRangeHints[i].HintDescriptor)) 23.158 + desc->port_descs[i].scale.defaultv = 100.0; 23.159 + else /* LADSPA_IS_HINT_DEFAULT_440 */ 23.160 + desc->port_descs[i].scale.defaultv = 440.0; 23.161 + } 23.162 + 23.163 + _naladspa_lrdf_get_scale_units(desc, desc->port_descs + i, i); 23.164 + _naladspa_lrdf_get_scale_points(desc, desc->port_descs + i, i); 23.165 + } 23.166 + 23.167 + _naladspa_lrdf_get_scale_defaults(desc, desc->port_descs); 23.168 +} 23.169 + 23.170 +void 23.171 +_naladspa_descriptor_free_data(struct nacore_descriptor *desc) 23.172 +{ 23.173 + size_t i; 23.174 + 23.175 + for (i = 0; i < desc->port_descs_count; i++) 23.176 + _naladspa_lrdf_free_data(desc->port_descs + i); 23.177 +}
24.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 24.2 +++ b/naspro-bridges-bad/ladspa/descriptor.h Fri Sep 11 13:31:52 2009 +0200 24.3 @@ -0,0 +1,21 @@ 24.4 +/* 24.5 + * NASPRO - NASPRO Architecture for Sound Processing 24.6 + * LADSPA bridge 24.7 + * 24.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 24.9 + * 24.10 + * See the COPYING file for license conditions. 24.11 + */ 24.12 + 24.13 +#ifndef _NALADSPA_DESCRIPTOR_H 24.14 +#define _NALADSPA_DESCRIPTOR_H 24.15 + 24.16 +#include <ladspa.h> 24.17 + 24.18 +#include <NASPRO/core/lib.h> 24.19 + 24.20 +void _naladspa_descriptor_fill(struct nacore_descriptor *desc, 24.21 + const LADSPA_Descriptor *ldesc); 24.22 +void _naladspa_descriptor_free_data(struct nacore_descriptor *desc); 24.23 + 24.24 +#endif /* !_NALADSPA_DESCRIPTOR_H */
25.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 25.2 +++ b/naspro-bridges-bad/ladspa/lrdf.c Fri Sep 11 13:31:52 2009 +0200 25.3 @@ -0,0 +1,766 @@ 25.4 +/* 25.5 + * NASPRO - NASPRO Architecture for Sound Processing 25.6 + * LADSPA bridge 25.7 + * 25.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 25.9 + * 25.10 + * See the COPYING file for license conditions. 25.11 + */ 25.12 + 25.13 +#include <stdlib.h> 25.14 +#include <stdint.h> 25.15 +#include <string.h> 25.16 +#include <errno.h> 25.17 + 25.18 +#include <locale.h> 25.19 + 25.20 +#include <ladspa.h> 25.21 + 25.22 +#include <librdf.h> 25.23 + 25.24 +#include <NASPRO/core/lib.h> 25.25 + 25.26 +#include "lrdf.h" 25.27 + 25.28 +#define LADSPA_PREFIX "http://ladspa.org/ontology#" 25.29 +#define RDF_PREFIX "http://www.w3.org/1999/02/22-rdf-syntax-ns#" 25.30 + 25.31 +static librdf_world *world = NULL; 25.32 +static librdf_parser *parser = NULL; 25.33 +static librdf_storage *storage = NULL; 25.34 +static librdf_model *model = NULL; 25.35 + 25.36 +static void 25.37 +parse_file(const char *file, const char *basename, void *data) 25.38 +{ 25.39 + librdf_uri *uri; 25.40 + 25.41 + uri = librdf_new_uri_from_filename(world, file); 25.42 + if (uri == NULL) 25.43 + return; 25.44 + 25.45 + librdf_parser_parse_into_model(parser, uri, NULL, model); 25.46 + 25.47 + librdf_free_uri(uri); 25.48 +} 25.49 + 25.50 +static char 25.51 +rdf_filter(const char *file) 25.52 +{ 25.53 + size_t file_len; 25.54 + 25.55 + file_len = strlen(file); 25.56 + 25.57 + if (file_len <= 4) 25.58 + return 0; 25.59 + if (!strcmp(file + file_len - 4, ".rdf")) 25.60 + return 1; 25.61 + 25.62 + if (file_len <= 5) 25.63 + return 0; 25.64 + 25.65 + return !strcmp(file + file_len - 5, ".rdfs"); 25.66 +} 25.67 + 25.68 +void 25.69 +_naladspa_lrdf_load_all() 25.70 +{ 25.71 + char *lrdf_path; 25.72 + char *prev_locale; 25.73 + 25.74 + world = librdf_new_world(); 25.75 + if (world == NULL) 25.76 + goto world_err; 25.77 + 25.78 + parser = librdf_new_parser(world, NULL, NULL, NULL); 25.79 + if (parser == NULL) 25.80 + goto parser_err; 25.81 + 25.82 + storage = librdf_new_storage(world, "hashes", NULL, 25.83 + "hash-type='memory'"); 25.84 + if (storage == NULL) 25.85 + goto storage_err; 25.86 + 25.87 + model = librdf_new_model(world, storage, NULL); 25.88 + if (model == NULL) 25.89 + goto model_err; 25.90 + 25.91 + prev_locale = setlocale(LC_NUMERIC, NULL); 25.92 + setlocale(LC_NUMERIC, "C"); 25.93 + 25.94 + lrdf_path = nacore_env_get_var("LADSPA_RDF_PATH"); 25.95 + if (NACORE_STRING_IS_NULL_OR_EMPTY(lrdf_path)) 25.96 + { 25.97 + /* TODO: This is *nix-only */ 25.98 + nacore_path_home_for_each(".ladspa/rdf", parse_file, rdf_filter, 25.99 + NULL); 25.100 + nacore_path_for_each("/usr/share/ladspa/rdf", parse_file, 25.101 + rdf_filter, NULL); 25.102 + } 25.103 + else 25.104 + nacore_path_for_each(lrdf_path, parse_file, rdf_filter, NULL); 25.105 + 25.106 + if (lrdf_path != NULL) 25.107 + nacore_env_free_var_value(lrdf_path); 25.108 + 25.109 + setlocale(LC_NUMERIC, prev_locale); 25.110 + 25.111 + return; 25.112 + 25.113 +model_err: 25.114 + librdf_free_storage(storage); 25.115 +storage_err: 25.116 + librdf_free_parser(parser); 25.117 +parser_err: 25.118 + librdf_free_world(world); 25.119 +world_err: 25.120 + return; 25.121 +} 25.122 + 25.123 +void 25.124 +_naladspa_lrdf_unload_all() 25.125 +{ 25.126 + if (model == NULL) 25.127 + return; 25.128 + 25.129 + librdf_free_model(model); 25.130 + model = NULL; 25.131 + librdf_free_storage(storage); 25.132 + storage = NULL; 25.133 + librdf_free_parser(parser); 25.134 + parser = NULL; 25.135 + librdf_free_world(world); 25.136 + world = NULL; 25.137 +} 25.138 + 25.139 +static char 25.140 +model_contains_statement_with_subject_node(librdf_node *subject_node, 25.141 + const char *predicate, 25.142 + const char *object) 25.143 +{ 25.144 + librdf_node *predicate_node, *object_node; 25.145 + librdf_statement *statement; 25.146 + char ret; 25.147 + 25.148 + predicate_node = librdf_new_node_from_uri_string(world, 25.149 + (const unsigned char *)predicate); 25.150 + if (predicate_node == NULL) 25.151 + { 25.152 + librdf_free_node(subject_node); 25.153 + return 0; 25.154 + } 25.155 + 25.156 + object_node = librdf_new_node_from_uri_string(world, 25.157 + (const unsigned char *)object); 25.158 + if (object_node == NULL) 25.159 + { 25.160 + librdf_free_node(predicate_node); 25.161 + librdf_free_node(subject_node); 25.162 + return 0; 25.163 + } 25.164 + 25.165 + statement = librdf_new_statement_from_nodes(world, subject_node, 25.166 + predicate_node, object_node); 25.167 + if (statement == NULL) 25.168 + { 25.169 + librdf_free_node(object_node); 25.170 + librdf_free_node(predicate_node); 25.171 + librdf_free_node(subject_node); 25.172 + return 0; 25.173 + } 25.174 + 25.175 + ret = librdf_model_contains_statement(model, statement) != 0; 25.176 + 25.177 + librdf_free_statement(statement); 25.178 + 25.179 + return ret; 25.180 +} 25.181 + 25.182 +static char 25.183 +model_contains_statement(const char *subject, const char *predicate, 25.184 + const char *object) 25.185 +{ 25.186 + librdf_node *subject_node; 25.187 + 25.188 + subject_node = librdf_new_node_from_uri_string(world, 25.189 + (const unsigned char*)subject); 25.190 + if (subject_node == NULL) 25.191 + return 0; 25.192 + 25.193 + return model_contains_statement_with_subject_node(subject_node, 25.194 + predicate, object); 25.195 +} 25.196 + 25.197 +static librdf_stream * 25.198 +model_find_statements_with_subject_node(librdf_node *subject_node, 25.199 + const char *predicate, 25.200 + const char *object) 25.201 +{ 25.202 + librdf_node *predicate_node, *object_node; 25.203 + librdf_statement *statement; 25.204 + librdf_stream *ret; 25.205 + 25.206 + predicate_node = NULL; 25.207 + if (predicate != NULL) 25.208 + { 25.209 + predicate_node = librdf_new_node_from_uri_string(world, 25.210 + (const unsigned char*)predicate); 25.211 + if (predicate_node == NULL) 25.212 + { 25.213 + if (subject_node != NULL) 25.214 + librdf_free_node(subject_node); 25.215 + return NULL; 25.216 + } 25.217 + } 25.218 + 25.219 + object_node = NULL; 25.220 + if (object_node != NULL) 25.221 + { 25.222 + object_node = librdf_new_node_from_uri_string(world, 25.223 + (const unsigned char*)object); 25.224 + if (object_node == NULL) 25.225 + { 25.226 + if (predicate_node != NULL) 25.227 + librdf_free_node(predicate_node); 25.228 + if (subject_node != NULL) 25.229 + librdf_free_node(subject_node); 25.230 + return NULL; 25.231 + } 25.232 + } 25.233 + 25.234 + statement = librdf_new_statement(world); 25.235 + if (statement == NULL) 25.236 + { 25.237 + if (object_node != NULL) 25.238 + librdf_free_node(object_node); 25.239 + if (predicate_node != NULL) 25.240 + librdf_free_node(predicate_node); 25.241 + if (subject_node != NULL) 25.242 + librdf_free_node(subject_node); 25.243 + return NULL; 25.244 + } 25.245 + 25.246 + if (subject_node != NULL) 25.247 + librdf_statement_set_subject(statement, subject_node); 25.248 + if (predicate_node != NULL) 25.249 + librdf_statement_set_predicate(statement, predicate_node); 25.250 + if (object_node != NULL) 25.251 + librdf_statement_set_object(statement, object_node); 25.252 + 25.253 + ret = librdf_model_find_statements(model, statement); 25.254 + 25.255 + librdf_free_statement(statement); 25.256 + 25.257 + return ret; 25.258 +} 25.259 + 25.260 +static librdf_stream * 25.261 +model_find_statements(const char *subject, const char *predicate, 25.262 + const char *object) 25.263 +{ 25.264 + librdf_node *subject_node; 25.265 + 25.266 + subject_node = NULL; 25.267 + if (subject != NULL) 25.268 + { 25.269 + subject_node = librdf_new_node_from_uri_string(world, 25.270 + (const unsigned char*)subject); 25.271 + if (subject_node == NULL) 25.272 + return NULL; 25.273 + } 25.274 + 25.275 + return model_find_statements_with_subject_node(subject_node, 25.276 + predicate, object); 25.277 +} 25.278 + 25.279 +#define X_MATCH(string, code) \ 25.280 + if (model_contains_statement(subject, RDF_PREFIX "type", \ 25.281 + LADSPA_PREFIX string)) \ 25.282 + { \ 25.283 + code \ 25.284 + } 25.285 + 25.286 +#define S_MATCH_1(string, na_class) \ 25.287 + X_MATCH(string, classes_1 |= na_class;) 25.288 + 25.289 +#define C_MATCH_1(string, na_class, na_out_class) \ 25.290 + X_MATCH(string, \ 25.291 + classes_1 |= na_class; \ 25.292 + classes_1 &= ~(na_out_class);) 25.293 + 25.294 +#define S_MATCH_2(string, na_class) \ 25.295 + X_MATCH(string, classes_2 |= na_class;) 25.296 + 25.297 +#define C_MATCH_2(string, na_class, na_out_class) \ 25.298 + X_MATCH(string, \ 25.299 + classes_2 |= na_class; \ 25.300 + classes_2 &= ~(na_out_class);) 25.301 + 25.302 +void 25.303 +_naladspa_lrdf_get_classes(struct nacore_descriptor *desc) 25.304 +{ 25.305 + LADSPA_Descriptor *ldesc; 25.306 + char subject[strlen(LADSPA_PREFIX) + 9]; 25.307 + uint32_t classes_1 = 0, classes_2 = 0; 25.308 + 25.309 + if (model == NULL) 25.310 + return; 25.311 + 25.312 + ldesc = (LADSPA_Descriptor *)desc->data; 25.313 + 25.314 + sprintf(subject, "%s%lu", LADSPA_PREFIX, ldesc->UniqueID); 25.315 + 25.316 + S_MATCH_1("UtilityPlugin", NACORE_DESCRIPTOR_CLASS_UTILITY); 25.317 + S_MATCH_1("GeneratorPlugin", NACORE_DESCRIPTOR_CLASS_GENERATOR); 25.318 + S_MATCH_1("SimulatorPlugin", NACORE_DESCRIPTOR_CLASS_SIMULATOR); 25.319 + S_MATCH_1("DelayPlugin", NACORE_DESCRIPTOR_CLASS_DELAY); 25.320 + S_MATCH_1("ModulatorPlugin", NACORE_DESCRIPTOR_CLASS_MODULATOR); 25.321 + S_MATCH_1("FrequencyPlugin", NACORE_DESCRIPTOR_CLASS_SPECTRAL); 25.322 + S_MATCH_1("FilterPlugin", NACORE_DESCRIPTOR_CLASS_FILTER); 25.323 + S_MATCH_2("AmplitudePlugin", NACORE_DESCRIPTOR_CLASS_DYNAMICS); 25.324 + S_MATCH_1("AmplifierPlugin", NACORE_DESCRIPTOR_CLASS_AMPLIFIER); 25.325 + S_MATCH_1("DistortionPlugin", NACORE_DESCRIPTOR_CLASS_DISTORTION); 25.326 + S_MATCH_1("ModulatorPlugin", NACORE_DESCRIPTOR_CLASS_MODULATOR); 25.327 + S_MATCH_2("DynamicsPlugin", NACORE_DESCRIPTOR_CLASS_DYNAMICS); 25.328 + C_MATCH_1("OscillatorPlugin", NACORE_DESCRIPTOR_CLASS_OSCILLATOR, 25.329 + NACORE_DESCRIPTOR_CLASS_GENERATOR); 25.330 + C_MATCH_1("PhaserPlugin", NACORE_DESCRIPTOR_CLASS_PHASER, 25.331 + NACORE_DESCRIPTOR_CLASS_MODULATOR); 25.332 + C_MATCH_1("FlangerPlugin", NACORE_DESCRIPTOR_CLASS_FLANGER, 25.333 + NACORE_DESCRIPTOR_CLASS_MODULATOR); 25.334 + C_MATCH_1("ChorusPlugin", NACORE_DESCRIPTOR_CLASS_CHORUS, 25.335 + NACORE_DESCRIPTOR_CLASS_MODULATOR); 25.336 + C_MATCH_1("ReverbPlugin", NACORE_DESCRIPTOR_CLASS_REVERB, 25.337 + NACORE_DESCRIPTOR_CLASS_SIMULATOR 25.338 + | NACORE_DESCRIPTOR_CLASS_DELAY); 25.339 + C_MATCH_1("FrequencyMeterPlugin", NACORE_DESCRIPTOR_CLASS_SPECTRAL 25.340 + | NACORE_DESCRIPTOR_CLASS_ANALYSER, 25.341 + NACORE_DESCRIPTOR_CLASS_UTILITY); 25.342 + C_MATCH_1("LowpassPlugin", NACORE_DESCRIPTOR_CLASS_LOWPASS, 25.343 + NACORE_DESCRIPTOR_CLASS_FILTER); 25.344 + C_MATCH_1("HighpassPlugin", NACORE_DESCRIPTOR_CLASS_HIGHPASS, 25.345 + NACORE_DESCRIPTOR_CLASS_FILTER); 25.346 + C_MATCH_1("BandpassPlugin", NACORE_DESCRIPTOR_CLASS_BANDPASS, 25.347 + NACORE_DESCRIPTOR_CLASS_FILTER); 25.348 + C_MATCH_1("CombPlugin", NACORE_DESCRIPTOR_CLASS_COMB, 25.349 + NACORE_DESCRIPTOR_CLASS_FILTER); 25.350 + C_MATCH_1("AllpassPlugin", NACORE_DESCRIPTOR_CLASS_ALLPASS, 25.351 + NACORE_DESCRIPTOR_CLASS_FILTER); 25.352 + C_MATCH_1("EQPlugin", NACORE_DESCRIPTOR_CLASS_EQ, 25.353 + NACORE_DESCRIPTOR_CLASS_FILTER); 25.354 + C_MATCH_1("ParaEQPlugin", NACORE_DESCRIPTOR_CLASS_PARAEQ, 25.355 + NACORE_DESCRIPTOR_CLASS_FILTER 25.356 + | NACORE_DESCRIPTOR_CLASS_EQ); 25.357 + C_MATCH_1("MultiEQPlugin", NACORE_DESCRIPTOR_CLASS_MULTIEQ, 25.358 + NACORE_DESCRIPTOR_CLASS_FILTER 25.359 + | NACORE_DESCRIPTOR_CLASS_EQ); 25.360 + C_MATCH_1("PitchPlugin", NACORE_DESCRIPTOR_CLASS_PITCH, 25.361 + NACORE_DESCRIPTOR_CLASS_SPECTRAL); 25.362 + C_MATCH_1("WaveshaperPlugin", NACORE_DESCRIPTOR_CLASS_WAVESHAPER, 25.363 + NACORE_DESCRIPTOR_CLASS_DISTORTION); 25.364 + C_MATCH_2("CompressorPlugin", NACORE_DESCRIPTOR_CLASS_COMPRESSOR, 25.365 + NACORE_DESCRIPTOR_CLASS_DYNAMICS); 25.366 + C_MATCH_2("ExpanderPlugin", NACORE_DESCRIPTOR_CLASS_EXPANDER, 25.367 + NACORE_DESCRIPTOR_CLASS_DYNAMICS); 25.368 + C_MATCH_2("LimiterPlugin", NACORE_DESCRIPTOR_CLASS_LIMITER, 25.369 + NACORE_DESCRIPTOR_CLASS_DYNAMICS); 25.370 + C_MATCH_2("GatePlugin", NACORE_DESCRIPTOR_CLASS_GATE, 25.371 + NACORE_DESCRIPTOR_CLASS_DYNAMICS); 25.372 + 25.373 + desc->classes_1 = classes_1; 25.374 + desc->classes_2 = classes_2; 25.375 +} 25.376 + 25.377 +void 25.378 +_naladspa_lrdf_get_scale_defaults(struct nacore_descriptor *desc, 25.379 + struct nacore_port_descriptor *port_descs) 25.380 +{ 25.381 + LADSPA_Descriptor *ldesc; 25.382 + librdf_node *setting_node; 25.383 + librdf_node *setting_node2; 25.384 + librdf_node *default_node; 25.385 + librdf_node *port_value_node; 25.386 + librdf_node *port_value_node2; 25.387 + librdf_node *port_value_node3; 25.388 + librdf_stream *stream; 25.389 + librdf_stream *stream2; 25.390 + char subject[strlen(LADSPA_PREFIX) + 9]; 25.391 + float value; 25.392 + unsigned long index; 25.393 + char *prev_locale; 25.394 + 25.395 + if (model == NULL) 25.396 + return; 25.397 + 25.398 + prev_locale = setlocale(LC_NUMERIC, NULL); 25.399 + setlocale(LC_NUMERIC, "C"); 25.400 + 25.401 + ldesc = (LADSPA_Descriptor *)desc->data; 25.402 + 25.403 + sprintf(subject, "%s%lu", LADSPA_PREFIX, ldesc->UniqueID); 25.404 + 25.405 + stream = model_find_statements(subject, LADSPA_PREFIX "hasSetting", 25.406 + NULL); 25.407 + if (stream == NULL) 25.408 + goto end; 25.409 + 25.410 + default_node = NULL; 25.411 + while (!librdf_stream_end(stream)) 25.412 + { 25.413 + setting_node = librdf_statement_get_object( 25.414 + librdf_stream_get_object(stream)); 25.415 + setting_node2 = librdf_new_node_from_node(setting_node); 25.416 + 25.417 + if (model_contains_statement_with_subject_node(setting_node2, 25.418 + RDF_PREFIX "type", LADSPA_PREFIX "Default")) 25.419 + { 25.420 + default_node = librdf_new_node_from_node(setting_node); 25.421 + break; 25.422 + } 25.423 + 25.424 + librdf_stream_next(stream); 25.425 + } 25.426 + librdf_free_stream(stream); 25.427 + 25.428 + if (default_node == NULL) 25.429 + goto end; 25.430 + 25.431 + stream = model_find_statements_with_subject_node(default_node, 25.432 + LADSPA_PREFIX "hasPortValue", NULL); 25.433 + if (stream == NULL) 25.434 + goto end; 25.435 + 25.436 + while (!librdf_stream_end(stream)) 25.437 + { 25.438 + port_value_node = librdf_statement_get_object( 25.439 + librdf_stream_get_object(stream)); 25.440 + port_value_node2 = librdf_new_node_from_node(port_value_node); 25.441 + port_value_node3 = librdf_new_node_from_node(port_value_node); 25.442 + 25.443 + stream2 = model_find_statements_with_subject_node( 25.444 + port_value_node2, RDF_PREFIX "value", NULL); 25.445 + if (stream2 == NULL) 25.446 + break; 25.447 + 25.448 + if (librdf_stream_end(stream2)) 25.449 + { 25.450 + librdf_free_stream(stream2); 25.451 + break; 25.452 + } 25.453 + value = atof((char *) 25.454 + librdf_node_get_literal_value( 25.455 + librdf_statement_get_object( 25.456 + librdf_stream_get_object(stream2)))); 25.457 + 25.458 + librdf_free_stream(stream2); 25.459 + 25.460 + stream2 = model_find_statements_with_subject_node( 25.461 + port_value_node3, LADSPA_PREFIX "forPort", 25.462 + NULL); 25.463 + if (stream2 == NULL) 25.464 + break; 25.465 + 25.466 + if (librdf_stream_end(stream2)) 25.467 + { 25.468 + librdf_free_stream(stream2); 25.469 + break; 25.470 + } 25.471 + 25.472 + index = strtoul( 25.473 + strrchr((char *) 25.474 + librdf_uri_as_string( 25.475 + librdf_node_get_uri( 25.476 + librdf_statement_get_object( 25.477 + librdf_stream_get_object(stream2)))), 25.478 + '.') + 1, 25.479 + NULL, 10); 25.480 + 25.481 + librdf_free_stream(stream2); 25.482 + 25.483 + if (index < desc->port_descs_count) 25.484 + { 25.485 + port_descs[index].scale.properties |= 25.486 + NACORE_SCALE_HAS_DEFAULT; 25.487 + port_descs[index].scale.defaultv = value; 25.488 + } 25.489 + 25.490 + librdf_stream_next(stream); 25.491 + } 25.492 + librdf_free_stream(stream); 25.493 + 25.494 +end: 25.495 + setlocale(LC_NUMERIC, prev_locale); 25.496 +} 25.497 + 25.498 +void 25.499 +_naladspa_lrdf_get_scale_points(struct nacore_descriptor *desc, 25.500 + struct nacore_port_descriptor *port, 25.501 + size_t index) 25.502 +{ 25.503 + LADSPA_Descriptor *ldesc; 25.504 + librdf_stream *stream; 25.505 + librdf_stream *stream2; 25.506 + librdf_stream *stream3; 25.507 + librdf_node *scale_node; 25.508 + librdf_node *scale_node2; 25.509 + librdf_node *point_node; 25.510 + librdf_node *point_node2; 25.511 + char subject[strlen(LADSPA_PREFIX) + 20]; 25.512 + char *label, *p; 25.513 + size_t len, count, i; 25.514 + char *prev_locale; 25.515 + 25.516 + if (model == NULL) 25.517 + return; 25.518 + 25.519 + prev_locale = setlocale(LC_NUMERIC, NULL); 25.520 + setlocale(LC_NUMERIC, "C"); 25.521 + 25.522 + ldesc = (LADSPA_Descriptor *)desc->data; 25.523 + 25.524 + sprintf(subject, "%s%lu.%lu", LADSPA_PREFIX, ldesc->UniqueID, 25.525 + (unsigned long)index); 25.526 + 25.527 + stream = model_find_statements(subject, LADSPA_PREFIX "hasScale", NULL); 25.528 + if (stream == NULL) 25.529 + goto stream_err; 25.530 + 25.531 + if (librdf_stream_end(stream)) 25.532 + goto stream_end; 25.533 + 25.534 + scale_node = librdf_statement_get_object( 25.535 + librdf_stream_get_object(stream)); 25.536 + scale_node2 = librdf_new_node_from_node(scale_node); 25.537 + if (scale_node2 == NULL) 25.538 + goto stream_end; 25.539 + 25.540 + stream2 = model_find_statements_with_subject_node(scale_node2, 25.541 + LADSPA_PREFIX "hasPoint", NULL); 25.542 + if (stream2 == NULL) 25.543 + { 25.544 + librdf_free_node(scale_node2); 25.545 + goto stream_end; 25.546 + } 25.547 + 25.548 + count = 0; 25.549 + len = 0; 25.550 + while (!librdf_stream_end(stream2)) 25.551 + { 25.552 + point_node = librdf_statement_get_object( 25.553 + librdf_stream_get_object(stream2)); 25.554 + point_node2 = librdf_new_node_from_node(point_node); 25.555 + 25.556 + stream3 = model_find_statements_with_subject_node( 25.557 + point_node2, LADSPA_PREFIX "hasLabel", NULL); 25.558 + if (stream3 == NULL) 25.559 + { 25.560 + librdf_free_stream(stream2); 25.561 + goto stream_end; 25.562 + } 25.563 + 25.564 + if (librdf_stream_end(stream3)) 25.565 + { 25.566 + librdf_free_stream(stream3); 25.567 + librdf_free_stream(stream2); 25.568 + goto stream_end; 25.569 + } 25.570 + 25.571 + label = (char *) 25.572 + librdf_node_get_literal_value( 25.573 + librdf_statement_get_object( 25.574 + librdf_stream_get_object(stream3))); 25.575 + 25.576 + len += strlen(label) + 1; 25.577 + count++; 25.578 + 25.579 + librdf_free_stream(stream3); 25.580 + 25.581 + librdf_stream_next(stream2); 25.582 + } 25.583 + librdf_free_stream(stream2); 25.584 + 25.585 + if (count == 0) 25.586 + goto stream_end; 25.587 + 25.588 + port->data = malloc(len); 25.589 + if (port->data == NULL) 25.590 + goto stream_end; 25.591 + 25.592 + port->scale.points = malloc(count * sizeof(struct nacore_scale_point)); 25.593 + if (port->scale.points == NULL) 25.594 + { 25.595 + free(port->data); 25.596 + port->data = NULL; 25.597 + goto stream_end; 25.598 + } 25.599 + 25.600 + scale_node2 = librdf_new_node_from_node(scale_node); 25.601 + if (scale_node2 == NULL) 25.602 + { 25.603 + free(port->data); 25.604 + port->data = NULL; 25.605 + free(port->scale.points); 25.606 + port->scale.points = NULL; 25.607 + goto stream_end; 25.608 + } 25.609 + 25.610 + stream2 = model_find_statements_with_subject_node(scale_node2, 25.611 + LADSPA_PREFIX "hasPoint", NULL); 25.612 + if (stream2 == NULL) 25.613 + { 25.614 + free(port->data); 25.615 + port->data = NULL; 25.616 + free(port->scale.points); 25.617 + port->scale.points = NULL; 25.618 + goto stream_end; 25.619 + } 25.620 + 25.621 + i = 0; 25.622 + p = (char *)port->data; 25.623 + while (!librdf_stream_end(stream2)) 25.624 + { 25.625 + point_node = librdf_statement_get_object( 25.626 + librdf_stream_get_object(stream2)); 25.627 + point_node2 = librdf_new_node_from_node(point_node); 25.628 + 25.629 + stream3 = model_find_statements_with_subject_node( 25.630 + point_node2, LADSPA_PREFIX "hasLabel", NULL); 25.631 + if (stream3 == NULL) 25.632 + { 25.633 + librdf_free_stream(stream2); 25.634 + free(port->data); 25.635 + port->data = NULL; 25.636 + free(port->scale.points); 25.637 + port->scale.points = NULL; 25.638 + goto stream_end; 25.639 + } 25.640 + 25.641 + if (librdf_stream_end(stream3)) 25.642 + { 25.643 + librdf_free_stream(stream3); 25.644 + librdf_free_stream(stream2); 25.645 + free(port->data); 25.646 + port->data = NULL; 25.647 + free(port->scale.points); 25.648 + port->scale.points = NULL; 25.649 + goto stream_end; 25.650 + } 25.651 + 25.652 + label = (char *) 25.653 + librdf_node_get_literal_value( 25.654 + librdf_statement_get_object( 25.655 + librdf_stream_get_object(stream3))); 25.656 + 25.657 + port->scale.points[i].label = p; 25.658 + 25.659 + strcpy(p, label); 25.660 + p += strlen(p) + 1; 25.661 + 25.662 + librdf_free_stream(stream3); 25.663 + 25.664 + point_node2 = librdf_new_node_from_node(point_node); 25.665 + 25.666 + stream3 = model_find_statements_with_subject_node( 25.667 + point_node2, RDF_PREFIX "value", NULL); 25.668 + if (stream3 == NULL) 25.669 + { 25.670 + librdf_free_stream(stream2); 25.671 + free(port->data); 25.672 + port->data = NULL; 25.673 + free(port->scale.points); 25.674 + port->scale.points = NULL; 25.675 + goto stream_end; 25.676 + } 25.677 + 25.678 + if (librdf_stream_end(stream3)) 25.679 + { 25.680 + librdf_free_stream(stream3); 25.681 + librdf_free_stream(stream2); 25.682 + free(port->data); 25.683 + port->data = NULL; 25.684 + free(port->scale.points); 25.685 + port->scale.points = NULL; 25.686 + goto stream_end; 25.687 + } 25.688 + 25.689 + port->scale.points[i].value = atof((char *) 25.690 + librdf_node_get_literal_value( 25.691 + librdf_statement_get_object( 25.692 + librdf_stream_get_object(stream3)))); 25.693 + 25.694 + librdf_free_stream(stream3); 25.695 + 25.696 + i++; 25.697 + 25.698 + librdf_stream_next(stream2); 25.699 + } 25.700 + librdf_free_stream(stream2); 25.701 + 25.702 + port->scale.points_count = count; 25.703 + 25.704 +stream_end: 25.705 + librdf_free_stream(stream); 25.706 +stream_err: 25.707 + setlocale(LC_NUMERIC, prev_locale); 25.708 +} 25.709 + 25.710 +#define MATCH_UNIT(s, u) \ 25.711 + if (!strcmp(value, LADSPA_PREFIX s)) \ 25.712 + { \ 25.713 + port->scale.unit = u; \ 25.714 + librdf_free_stream(stream); \ 25.715 + return; \ 25.716 + } 25.717 + 25.718 +void 25.719 +_naladspa_lrdf_get_scale_units(struct nacore_descriptor *desc, 25.720 + struct nacore_port_descriptor *port, 25.721 + size_t index) 25.722 +{ 25.723 + LADSPA_Descriptor *ldesc; 25.724 + librdf_stream *stream; 25.725 + char subject[strlen(LADSPA_PREFIX) + 20]; 25.726 + char *value; 25.727 + 25.728 + port->scale.unit = nacore_scale_unit_none; 25.729 + 25.730 + if (model == NULL) 25.731 + return; 25.732 + 25.733 + ldesc = (LADSPA_Descriptor *)desc->data; 25.734 + 25.735 + sprintf(subject, "%s%lu.%lu", LADSPA_PREFIX, ldesc->UniqueID, 25.736 + (unsigned long)index); 25.737 + 25.738 + stream = model_find_statements(subject, LADSPA_PREFIX "hasUnit", NULL); 25.739 + if (stream == NULL) 25.740 + return; 25.741 + 25.742 + if (librdf_stream_end(stream)) 25.743 + { 25.744 + librdf_free_stream(stream); 25.745 + return; 25.746 + } 25.747 + 25.748 + value = (char *)librdf_node_get_literal_value( 25.749 + librdf_statement_get_object( 25.750 + librdf_stream_get_object(stream))); 25.751 + 25.752 + MATCH_UNIT("dB", nacore_scale_unit_db); 25.753 + MATCH_UNIT("coef", nacore_scale_unit_coeff); 25.754 + MATCH_UNIT("Hz", nacore_scale_unit_hz); 25.755 + MATCH_UNIT("seconds", nacore_scale_unit_s); 25.756 + MATCH_UNIT("milliseconds", nacore_scale_unit_ms); 25.757 + MATCH_UNIT("minutes", nacore_scale_unit_m); 25.758 + 25.759 + librdf_free_stream(stream); 25.760 +} 25.761 + 25.762 +void 25.763 +_naladspa_lrdf_free_data(struct nacore_port_descriptor *port) 25.764 +{ 25.765 + if (port->scale.points != NULL) 25.766 + free(port->scale.points); 25.767 + if (port->data != NULL) 25.768 + free(port->data); 25.769 +}
26.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 26.2 +++ b/naspro-bridges-bad/ladspa/lrdf.h Fri Sep 11 13:31:52 2009 +0200 26.3 @@ -0,0 +1,28 @@ 26.4 +/* 26.5 + * NASPRO - NASPRO Architecture for Sound Processing 26.6 + * LADSPA bridge 26.7 + * 26.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 26.9 + * 26.10 + * See the COPYING file for license conditions. 26.11 + */ 26.12 + 26.13 +#ifndef _NALADSPA_LRDF_H 26.14 +#define _NALADSPA_LRDF_H 26.15 + 26.16 +#include <NASPRO/core/lib.h> 26.17 + 26.18 +void _naladspa_lrdf_load_all(); 26.19 +void _naladspa_lrdf_unload_all(); 26.20 +void _naladspa_lrdf_get_classes(struct nacore_descriptor *desc); 26.21 +void _naladspa_lrdf_get_scale_defaults(struct nacore_descriptor *desc, 26.22 + struct nacore_port_descriptor *port_descs); 26.23 +void _naladspa_lrdf_get_scale_points(struct nacore_descriptor *desc, 26.24 + struct nacore_port_descriptor *port, 26.25 + size_t index); 26.26 +void _naladspa_lrdf_get_scale_units(struct nacore_descriptor *desc, 26.27 + struct nacore_port_descriptor *port, 26.28 + size_t index); 26.29 +void _naladspa_lrdf_free_data(struct nacore_port_descriptor *port); 26.30 + 26.31 +#endif /* !_NALADSPA_LRDF_H */
27.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 27.2 +++ b/naspro-bridges-bad/ladspa/lv2api.c Fri Sep 11 13:31:52 2009 +0200 27.3 @@ -0,0 +1,178 @@ 27.4 +/* 27.5 + * NASPRO - NASPRO Architecture for Sound Processing 27.6 + * LADSPA bridge 27.7 + * 27.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 27.9 + * 27.10 + * See the COPYING file for license conditions. 27.11 + */ 27.12 + 27.13 +#include <stdlib.h> 27.14 + 27.15 +#include <ladspa.h> 27.16 + 27.17 +#include <lv2.h> 27.18 + 27.19 +#include <NASPRO/core/lib.h> 27.20 + 27.21 +#include "pluglib.h" 27.22 +#include "lv2api.h" 27.23 + 27.24 +struct ll_desc 27.25 + { 27.26 + LV2_Descriptor lv2_desc; 27.27 + LADSPA_Descriptor *l_desc; 27.28 + }; 27.29 + 27.30 +struct instance 27.31 + { 27.32 + LADSPA_Handle l_handle; 27.33 + LADSPA_Descriptor *l_desc; 27.34 + }; 27.35 + 27.36 +static struct ll_desc *descs = NULL; 27.37 +static size_t descs_count = 0; 27.38 + 27.39 +LV2_Handle 27.40 +_naladspa_lv2api_instantiate(const LV2_Descriptor *descriptor, 27.41 + double sample_rate, const char *bundle_path, 27.42 + const LV2_Feature * const *features) 27.43 +{ 27.44 + LADSPA_Descriptor *ldesc; 27.45 + LADSPA_Handle *handle; 27.46 + struct instance *instance; 27.47 + 27.48 + instance = malloc(sizeof(struct instance)); 27.49 + if (instance == NULL) 27.50 + return NULL; 27.51 + 27.52 + /* This should work correctly according to the ANSI C standard. */ 27.53 + ldesc = ((struct ll_desc *)descriptor)->l_desc; 27.54 + 27.55 + handle = ldesc->instantiate(ldesc, sample_rate); 27.56 + if (handle == NULL) 27.57 + { 27.58 + free(instance); 27.59 + return NULL; 27.60 + } 27.61 + 27.62 + instance->l_desc = ldesc; 27.63 + instance->l_handle = handle; 27.64 + 27.65 + return (LV2_Handle)instance; 27.66 +} 27.67 + 27.68 +void 27.69 +_naladspa_lv2api_connect_port(LV2_Handle instance, uint32_t port, 27.70 + void *data_location) 27.71 +{ 27.72 + struct instance *i; 27.73 + 27.74 + /* This is needed to avoid a little incompatibility beetween LADSPA and 27.75 + * LV2. LADSPA's connect_port() does not specify whether data_location 27.76 + * is valid at the time it is being run, while LV2 mandates the plugin 27.77 + * not to trust the memory location indicated by the pointer at the time 27.78 + * connect_port() is run. */ 27.79 + if (data_location == NULL) 27.80 + return; 27.81 + 27.82 + i = ((struct instance *)instance); 27.83 + 27.84 + i->l_desc->connect_port(i->l_handle, port, data_location); 27.85 +} 27.86 + 27.87 +void 27.88 +_naladspa_lv2api_activate(LV2_Handle instance) 27.89 +{ 27.90 + struct instance *i; 27.91 + 27.92 + i = (struct instance *)instance; 27.93 + 27.94 + i->l_desc->activate(i->l_handle); 27.95 +} 27.96 + 27.97 +void 27.98 +_naladspa_lv2api_run(LV2_Handle instance, uint32_t sample_count) 27.99 +{ 27.100 + struct instance *i; 27.101 + 27.102 + i = (struct instance *)instance; 27.103 + 27.104 + i->l_desc->run(i->l_handle, sample_count); 27.105 +} 27.106 + 27.107 +void 27.108 +_naladspa_lv2api_deactivate(LV2_Handle instance) 27.109 +{ 27.110 + struct instance *i; 27.111 + 27.112 + i = (struct instance *)instance; 27.113 + 27.114 + i->l_desc->deactivate(i->l_handle); 27.115 +} 27.116 + 27.117 +void 27.118 +_naladspa_lv2api_cleanup(LV2_Handle instance) 27.119 +{ 27.120 + struct instance *i; 27.121 + 27.122 + i = (struct instance *)instance; 27.123 + 27.124 + i->l_desc->cleanup(i->l_handle); 27.125 + free(i); 27.126 +} 27.127 + 27.128 +static void 27.129 +generate_desc(void *content, void *data) 27.130 +{ 27.131 + struct nacore_descriptor *ndesc; 27.132 + LADSPA_Descriptor *ldesc; 27.133 + struct ll_desc *lldesc; 27.134 + size_t *n; 27.135 + 27.136 + n = (size_t *)data; 27.137 + lldesc = descs + *n; 27.138 + ndesc = (struct nacore_descriptor *)content; 27.139 + ldesc = (LADSPA_Descriptor *)ndesc->data; 27.140 + 27.141 + nacore_lv2api_fill_desc(&lldesc->lv2_desc, ndesc); 27.142 + lldesc->l_desc = ldesc; 27.143 + 27.144 + (*n)++; 27.145 +} 27.146 + 27.147 +int 27.148 +_naladspa_lv2api_generate_descs() 27.149 +{ 27.150 + size_t n; 27.151 + 27.152 + n = nacore_avl_tree_get_nodes_count(_naladspa_pluglib_desc_tree); 27.153 + descs = malloc(n * sizeof(struct ll_desc)); 27.154 + if (descs == NULL) 27.155 + return -1; 27.156 + 27.157 + descs_count = n; 27.158 + 27.159 + n = 0; 27.160 + nacore_avl_tree_for_each(_naladspa_pluglib_desc_tree, generate_desc, 27.161 + &n); 27.162 + 27.163 + return 0; 27.164 +} 27.165 + 27.166 +void 27.167 +_naladspa_lv2api_free_descs() 27.168 +{ 27.169 + free(descs); 27.170 + descs = NULL; 27.171 + descs_count = 0; 27.172 +} 27.173 + 27.174 +const LV2_Descriptor * 27.175 +lv2_descriptor(uint32_t index) 27.176 +{ 27.177 + if (index >= descs_count) 27.178 + return NULL; 27.179 + 27.180 + return &descs[index].lv2_desc; 27.181 +}
28.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 28.2 +++ b/naspro-bridges-bad/ladspa/lv2api.h Fri Sep 11 13:31:52 2009 +0200 28.3 @@ -0,0 +1,31 @@ 28.4 +/* 28.5 + * NASPRO - NASPRO Architecture for Sound Processing 28.6 + * LADSPA bridge 28.7 + * 28.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 28.9 + * 28.10 + * See the COPYING file for license conditions. 28.11 + */ 28.12 + 28.13 +#ifndef _NALADSPA_LV2API_H 28.14 +#define _NALADSPA_LV2API_H 28.15 + 28.16 +#include <stdlib.h> 28.17 + 28.18 +#include <lv2.h> 28.19 + 28.20 +LV2_Handle _naladspa_lv2api_instantiate(const LV2_Descriptor *descriptor, 28.21 + double sample_rate, 28.22 + const char *bundle_path, 28.23 + const LV2_Feature * const *features); 28.24 +void _naladspa_lv2api_connect_port(LV2_Handle instance, uint32_t port, 28.25 + void *data_location); 28.26 +void _naladspa_lv2api_activate(LV2_Handle instance); 28.27 +void _naladspa_lv2api_run(LV2_Handle instance, uint32_t sample_count); 28.28 +void _naladspa_lv2api_deactivate(LV2_Handle instance); 28.29 +void _naladspa_lv2api_cleanup(LV2_Handle instance); 28.30 + 28.31 +int _naladspa_lv2api_generate_descs(); 28.32 +void _naladspa_lv2api_free_descs(); 28.33 + 28.34 +#endif /* !_NALADSPA_LV2API_H */
29.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 29.2 +++ b/naspro-bridges-bad/ladspa/manifest.c Fri Sep 11 13:31:52 2009 +0200 29.3 @@ -0,0 +1,102 @@ 29.4 +/* 29.5 + * NASPRO - NASPRO Architecture for Sound Processing 29.6 + * LADSPA bridge 29.7 + * 29.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 29.9 + * 29.10 + * See the COPYING file for license conditions. 29.11 + */ 29.12 + 29.13 +#include <stdio.h> 29.14 + 29.15 +#include <lv2_dyn_manifest.h> 29.16 + 29.17 +#include <NASPRO/core/lib.h> 29.18 + 29.19 +#include "pluglib.h" 29.20 +#include "lv2api.h" 29.21 + 29.22 +/* TODO: Until a serious rescan/automagical discovery policy emerges, we perform 29.23 + * discovery only once at initialization time. */ 29.24 + 29.25 +static char inited = 0; 29.26 +static char descs_ok = 0; 29.27 + 29.28 +int 29.29 +lv2_dyn_manifest_open(LV2_Dyn_Manifest_Handle *handle, 29.30 + const LV2_Feature *const *features) 29.31 +{ 29.32 + static char called = 0; 29.33 + 29.34 + if (called) 29.35 + return -1; 29.36 + called = 1; 29.37 + 29.38 + if (!inited) 29.39 + { 29.40 + _naladspa_pluglib_load_all(); 29.41 + descs_ok = _naladspa_lv2api_generate_descs() >= 0; 29.42 + inited = 1; 29.43 + } 29.44 + 29.45 + *handle = NULL; 29.46 + 29.47 + if (_naladspa_pluglib_desc_tree == NULL) 29.48 + return -1; 29.49 + 29.50 + called = 0; 29.51 + 29.52 + return 0; 29.53 +} 29.54 + 29.55 +static void __attribute__((destructor)) 29.56 +fini() 29.57 +{ 29.58 + _naladspa_pluglib_unload_all(); 29.59 + _naladspa_lv2api_free_descs(); 29.60 +} 29.61 + 29.62 +static void 29.63 +print_subject(void *content, void *data) 29.64 +{ 29.65 + nacore_manifest_print_subject_triple( 29.66 + (struct nacore_descriptor *)content, (FILE *)data); 29.67 +} 29.68 + 29.69 +int 29.70 +lv2_dyn_manifest_get_subjects(LV2_Dyn_Manifest_Handle handle, FILE *fp) 29.71 +{ 29.72 + if (descs_ok == 0) 29.73 + return 0; 29.74 + 29.75 + nacore_manifest_print_subject_prefixes(fp); 29.76 + 29.77 + nacore_avl_tree_for_each(_naladspa_pluglib_desc_tree, print_subject, 29.78 + (void *)fp); 29.79 + 29.80 + return 0; 29.81 +} 29.82 + 29.83 +int 29.84 +lv2_dyn_manifest_get_data(LV2_Dyn_Manifest_Handle handle, FILE *fp, 29.85 + const char *uri) 29.86 +{ 29.87 + struct nacore_descriptor *d; 29.88 + 29.89 + if (descs_ok == 0) 29.90 + return 0; 29.91 + 29.92 + d = (struct nacore_descriptor *)nacore_avl_tree_find( 29.93 + _naladspa_pluglib_desc_tree, (void *)uri); 29.94 + if (d == NULL) 29.95 + return -1; 29.96 + 29.97 + nacore_manifest_print_data(d, fp, "ladspa"); 29.98 + 29.99 + return 0; 29.100 +} 29.101 + 29.102 +void 29.103 +lv2_dyn_manifest_close(LV2_Dyn_Manifest_Handle handle) 29.104 +{ 29.105 +}
30.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 30.2 +++ b/naspro-bridges-bad/ladspa/manifest.ttl Fri Sep 11 13:31:52 2009 +0200 30.3 @@ -0,0 +1,14 @@ 30.4 +# 30.5 +# NASPRO - NASPRO Architecture for Sound Processing 30.6 +# LADSPA bridge 30.7 +# 30.8 +# Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 30.9 +# 30.10 +# See the COPYING file for license conditions. 30.11 +# 30.12 + 30.13 +@prefix lv2: <http://lv2plug.in/ns/lv2core#>. 30.14 +@prefix dman: <http://lv2plug.in/ns/ext/dynmanifest#>. 30.15 + 30.16 +<http://naspro.atheme.org/ladspa> a dman:DynManifest; 30.17 + lv2:binary <ladspa.so>.
31.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 31.2 +++ b/naspro-bridges-bad/ladspa/pluglib.c Fri Sep 11 13:31:52 2009 +0200 31.3 @@ -0,0 +1,268 @@ 31.4 +/* 31.5 + * NASPRO - NASPRO Architecture for Sound Processing 31.6 + * LADSPA bridge 31.7 + * 31.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 31.9 + * 31.10 + * See the COPYING file for license conditions. 31.11 + */ 31.12 + 31.13 +#include <stdlib.h> 31.14 +#include <stdio.h> 31.15 +#include <string.h> 31.16 +#include <errno.h> 31.17 + 31.18 +#include <ladspa.h> 31.19 + 31.20 +#include <NASPRO/core/lib.h> 31.21 + 31.22 +#include "pluglib.h" 31.23 +#include "descriptor.h" 31.24 +#include "lrdf.h" 31.25 + 31.26 +nacore_avl_tree_t _naladspa_pluglib_desc_tree = NULL; 31.27 + 31.28 +struct pluglib 31.29 + { 31.30 + nacore_dl_module_t dl_module; 31.31 + struct nacore_descriptor *descs; 31.32 + size_t descs_count; 31.33 + struct nacore_port_descriptor *port_descs; 31.34 + size_t port_descs_count; 31.35 + char *uris; 31.36 + size_t uris_size; 31.37 + }; 31.38 + 31.39 +static struct pluglib *pluglibs = NULL; 31.40 +static size_t pluglibs_count = 0; 31.41 + 31.42 +static nacore_avl_tree_t uid_tree; 31.43 + 31.44 +static size_t 31.45 +uint_to_dec_str_len(unsigned long i) 31.46 +{ 31.47 + size_t ret; 31.48 + 31.49 + ret = 0; 31.50 + do 31.51 + { 31.52 + i /= 10; 31.53 + ret++; 31.54 + } 31.55 + while (i != 0); 31.56 + 31.57 + return ret; 31.58 +} 31.59 + 31.60 +static void 31.61 +pluglib_load(const char *file, const char *basename, void *data) 31.62 +{ 31.63 + nacore_dl_module_t dl_module; 31.64 + const LADSPA_Descriptor *ldesc; 31.65 + LADSPA_Descriptor_Function get_desc; 31.66 + struct pluglib *tmp_pluglibs; 31.67 + struct nacore_descriptor *tmp_descs; 31.68 + struct nacore_port_descriptor *tmp_port_descs; 31.69 + char *tmp_uris; 31.70 + size_t descs_count, ports_count, uris_size; 31.71 + unsigned long i; 31.72 + void *p; 31.73 + 31.74 + dl_module = nacore_dl_open(file); 31.75 + if (dl_module == NULL) 31.76 + goto dl_open_err; 31.77 + 31.78 + if (nacore_dl_sym(dl_module, "naspro_backbridge") != NULL) 31.79 + goto backbridge; 31.80 + 31.81 + *(void **)(&get_desc) = nacore_dl_sym(dl_module, "ladspa_descriptor"); 31.82 + if (get_desc == NULL) 31.83 + goto get_desc_err; 31.84 + 31.85 + for (i = 0, descs_count = 0, ports_count = 0, uris_size = 0; 31.86 + (ldesc = get_desc(i)) != NULL; i++) 31.87 + { 31.88 + p = nacore_avl_tree_find(uid_tree, (void *)&ldesc->UniqueID); 31.89 + if (p != NULL) 31.90 + continue; 31.91 + 31.92 + nacore_avl_tree_add(uid_tree, (void *)ldesc); 31.93 + 31.94 + ports_count += ldesc->PortCount; 31.95 + uris_size += uint_to_dec_str_len(ldesc->UniqueID) + 12; 31.96 + descs_count++; 31.97 + } 31.98 + if (descs_count == 0) 31.99 + goto no_desc; 31.100 + 31.101 + tmp_descs = malloc(descs_count * sizeof(struct nacore_descriptor)); 31.102 + if (tmp_descs == NULL) 31.103 + goto descs_err; 31.104 + 31.105 + tmp_port_descs = NULL; 31.106 + if (ports_count != 0) 31.107 + { 31.108 + tmp_port_descs = malloc(ports_count 31.109 + * sizeof(struct nacore_port_descriptor)); 31.110 + if (tmp_port_descs == NULL) 31.111 + goto port_descs_err; 31.112 + } 31.113 + 31.114 + tmp_uris = malloc(uris_size); 31.115 + if (tmp_uris == NULL) 31.116 + goto uris_err; 31.117 + 31.118 + tmp_pluglibs = realloc(pluglibs, 31.119 + (pluglibs_count + 1) * sizeof(struct pluglib)); 31.120 + if (tmp_pluglibs == NULL) 31.121 + goto pluglibs_err; 31.122 + 31.123 + pluglibs = tmp_pluglibs; 31.124 + tmp_pluglibs = pluglibs + pluglibs_count; 31.125 + pluglibs_count++; 31.126 + 31.127 + tmp_pluglibs->dl_module = dl_module; 31.128 + 31.129 + tmp_pluglibs->descs = tmp_descs; 31.130 + tmp_pluglibs->descs_count = descs_count; 31.131 + tmp_pluglibs->port_descs = tmp_port_descs; 31.132 + tmp_pluglibs->port_descs_count = ports_count; 31.133 + tmp_pluglibs->uris = tmp_uris; 31.134 + tmp_pluglibs->uris_size = uris_size; 31.135 + 31.136 + for (i = 0, descs_count = 0, ports_count = 0, uris_size = 0; 31.137 + (ldesc = get_desc(i)) != NULL; i++) 31.138 + { 31.139 + p = nacore_avl_tree_find(uid_tree, (void *)&ldesc->UniqueID); 31.140 + if (p != ldesc) 31.141 + continue; 31.142 + 31.143 + tmp_pluglibs->descs[descs_count].port_descs = 31.144 + tmp_pluglibs->port_descs + ports_count; 31.145 + tmp_pluglibs->descs[descs_count].port_descs_count = 31.146 + ldesc->PortCount; 31.147 + tmp_pluglibs->descs[descs_count].uri = 31.148 + tmp_pluglibs->uris + uris_size; 31.149 + sprintf(tmp_pluglibs->descs[descs_count].uri, "urn:ladspa:%lu", 31.150 + ldesc->UniqueID); 31.151 + 31.152 + _naladspa_descriptor_fill(tmp_pluglibs->descs + descs_count, 31.153 + ldesc); 31.154 + 31.155 + nacore_avl_tree_add(_naladspa_pluglib_desc_tree, 31.156 + tmp_pluglibs->descs + descs_count); 31.157 + 31.158 + ports_count += ldesc->PortCount; 31.159 + uris_size += uint_to_dec_str_len(ldesc->UniqueID) + 12; 31.160 + descs_count++; 31.161 + } 31.162 + 31.163 + return; 31.164 + 31.165 +pluglibs_err: 31.166 + free(tmp_uris); 31.167 +uris_err: 31.168 + if (tmp_port_descs != NULL) 31.169 + free(tmp_port_descs); 31.170 +port_descs_err: 31.171 + free(tmp_descs); 31.172 +descs_err: 31.173 +no_desc: 31.174 +get_desc_err: 31.175 +backbridge: 31.176 + nacore_dl_close(dl_module); 31.177 +dl_open_err: 31.178 + return; 31.179 +} 31.180 + 31.181 +static int 31.182 +uid_content_cmp(void *c1, void *c2) 31.183 +{ 31.184 + if (((LADSPA_Descriptor *)c1)->UniqueID 31.185 + < ((LADSPA_Descriptor *)c2)->UniqueID) 31.186 + return -1; 31.187 + if (((LADSPA_Descriptor *)c1)->UniqueID 31.188 + == ((LADSPA_Descriptor *)c2)->UniqueID) 31.189 + return 0; 31.190 + return 1; 31.191 +} 31.192 + 31.193 +static int 31.194 +uid_key_cmp(void *content, void *key) 31.195 +{ 31.196 + if (((LADSPA_Descriptor *)content)->UniqueID < *((unsigned long *)key)) 31.197 + return -1; 31.198 + if (((LADSPA_Descriptor *)content)->UniqueID == *((unsigned long *)key)) 31.199 + return 0; 31.200 + return 1; 31.201 +} 31.202 + 31.203 +void 31.204 +_naladspa_pluglib_load_all() 31.205 +{ 31.206 + char *ladspa_path; 31.207 + 31.208 + _naladspa_pluglib_desc_tree = nacore_avl_tree_new( 31.209 + nacore_content_cmp_descriptor_by_uri, 31.210 + nacore_key_cmp_descriptor_by_uri); 31.211 + if (_naladspa_pluglib_desc_tree == NULL) 31.212 + return; 31.213 + 31.214 + uid_tree = nacore_avl_tree_new(uid_content_cmp, uid_key_cmp); 31.215 + if (uid_tree == NULL) 31.216 + { 31.217 + nacore_avl_tree_free(_naladspa_pluglib_desc_tree); 31.218 + _naladspa_pluglib_desc_tree = NULL; 31.219 + return; 31.220 + } 31.221 + 31.222 + _naladspa_lrdf_load_all(); 31.223 + 31.224 + ladspa_path = nacore_env_get_var("LADSPA_PATH"); 31.225 + if (NACORE_STRING_IS_NULL_OR_EMPTY(ladspa_path)) 31.226 + { 31.227 + /* TODO: This is *nix-only */ 31.228 + nacore_path_home_for_each(".ladspa", pluglib_load, 31.229 + nacore_dl_filename_filter, NULL); 31.230 + nacore_path_for_each("/usr/local/lib/ladspa:/usr/lib/ladspa", 31.231 + pluglib_load, nacore_dl_filename_filter, 31.232 + NULL); 31.233 + } 31.234 + else 31.235 + nacore_path_for_each(ladspa_path, pluglib_load, 31.236 + nacore_dl_filename_filter, NULL); 31.237 + 31.238 + if (ladspa_path != NULL) 31.239 + nacore_env_free_var_value(ladspa_path); 31.240 + 31.241 + nacore_avl_tree_free(uid_tree); 31.242 +} 31.243 + 31.244 +void 31.245 +_naladspa_pluglib_unload_all() 31.246 +{ 31.247 + size_t i, j; 31.248 + 31.249 + if (pluglibs == NULL) 31.250 + return; 31.251 + 31.252 + for (i = 0; i < pluglibs_count; i++) 31.253 + { 31.254 + for (j = 0; j < pluglibs[i].descs_count; j++) 31.255 + _naladspa_descriptor_free_data(pluglibs[i].descs + j); 31.256 + 31.257 + nacore_dl_close(pluglibs[i].dl_module); 31.258 + free(pluglibs[i].descs); 31.259 + free(pluglibs[i].port_descs); 31.260 + free(pluglibs[i].uris); 31.261 + } 31.262 + 31.263 + free(pluglibs); 31.264 + pluglibs = NULL; 31.265 + pluglibs_count = 0; 31.266 + 31.267 + _naladspa_lrdf_unload_all(); 31.268 + 31.269 + nacore_avl_tree_free(_naladspa_pluglib_desc_tree); 31.270 + _naladspa_pluglib_desc_tree = NULL; 31.271 +}
32.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 32.2 +++ b/naspro-bridges-bad/ladspa/pluglib.h Fri Sep 11 13:31:52 2009 +0200 32.3 @@ -0,0 +1,20 @@ 32.4 +/* 32.5 + * NASPRO - NASPRO Architecture for Sound Processing 32.6 + * LADSPA bridge 32.7 + * 32.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 32.9 + * 32.10 + * See the COPYING file for license conditions. 32.11 + */ 32.12 + 32.13 +#ifndef _NALADSPA_PLUGLIB_H 32.14 +#define _NALADSPA_PLUGLIB_H 32.15 + 32.16 +#include <NASPRO/core/lib.h> 32.17 + 32.18 +void _naladspa_pluglib_load_all(); 32.19 +void _naladspa_pluglib_unload_all(); 32.20 + 32.21 +nacore_avl_tree_t _naladspa_pluglib_desc_tree; 32.22 + 32.23 +#endif /* !_NALADSPA_PLUGLIB_H */
33.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 33.2 +++ b/naspro-bridges-bad/ndf/Makefile Fri Sep 11 13:31:52 2009 +0200 33.3 @@ -0,0 +1,42 @@ 33.4 +.POSIX: 33.5 + 33.6 +.SUFFIXES: 33.7 + 33.8 +### Change this... 33.9 + 33.10 +PREFIX = /usr/local 33.11 +LIB_DIR = $(PREFIX)/lib 33.12 + 33.13 +LV2_DIR = $(LIB_DIR)/lv2 33.14 + 33.15 +NDF_BRIDGE_BUNDLE_DIR = $(LV2_DIR)/naspro-ndf.lv2 33.16 + 33.17 +CC = gcc 33.18 +CFLAGS = -O2 -ansi -pedantic -Wall -fPIC 33.19 + 33.20 +DL_LDFLAGS = -ldl 33.21 +LDFLAGS = -shared $(DL_LDFLAGS) 33.22 + 33.23 +SO_FILE_EXT = .so 33.24 + 33.25 +### ... but not this 33.26 + 33.27 +TARGETS = ndf.so 33.28 + 33.29 +NDF_BRIDGE_SOURCES = collection.c \ 33.30 + collection.h \ 33.31 + manifest.c 33.32 +NDF_BRIDGE_LIBS = -lnacore 33.33 + 33.34 +all: $(TARGETS) 33.35 + 33.36 +ndf.so: $(NDF_BRIDGE_SOURCES) 33.37 + $(CC) $(CFLAGS) $(LDFLAGS) $(NDF_BRIDGE_SOURCES) \ 33.38 + $(NDF_BRIDGE_LIBS) -o $@ 33.39 + 33.40 +install: $(TARGETS) manifest.ttl 33.41 + mkdir -p $(NDF_BRIDGE_BUNDLE_DIR) 33.42 + cp ndf.so manifest.ttl $(NDF_BRIDGE_BUNDLE_DIR) 33.43 + 33.44 +clean: 33.45 + rm -f $(TARGETS)
34.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 34.2 +++ b/naspro-bridges-bad/ndf/collection.c Fri Sep 11 13:31:52 2009 +0200 34.3 @@ -0,0 +1,81 @@ 34.4 +/* 34.5 + * NASPRO - NASPRO Architecture for Sound Processing 34.6 + * NDF (NASPRO Digital Filters) 34.7 + * 34.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 34.9 + * 34.10 + * See the COPYING file for license conditions. 34.11 + */ 34.12 + 34.13 +#include <stdlib.h> 34.14 +#include <string.h> 34.15 + 34.16 +#include <NASPRO/core/lib.h> 34.17 + 34.18 +#include "collection.h" 34.19 + 34.20 +nacore_avl_tree_t _nandf_collection_desc_tree = NULL; 34.21 + 34.22 +static void 34.23 +load_file(const char *file, const char *basename, void *data) 34.24 +{ 34.25 + 34.26 +} 34.27 + 34.28 +static char 34.29 +ndf_filter(const char *file) 34.30 +{ 34.31 + size_t file_len; 34.32 + 34.33 + file_len = strlen(file); 34.34 + 34.35 + if (file_len <= 4) 34.36 + return 0; 34.37 + 34.38 + if (file[file_len - 4] != '.') 34.39 + return 0; 34.40 + if ((file[file_len - 3] != 'n') && (file[file_len - 3] != 'N')) 34.41 + return 0; 34.42 + if ((file[file_len - 2] != 'd') && (file[file_len - 2] != 'D')) 34.43 + return 0; 34.44 + if ((file[file_len - 1] != 'f') && (file[file_len - 1] != 'F')) 34.45 + return 0; 34.46 + 34.47 + return 1; 34.48 +} 34.49 + 34.50 +char 34.51 +_nandf_collection_load_all() 34.52 +{ 34.53 + char *ndf_path; 34.54 + 34.55 + _nandf_collection_desc_tree = nacore_avl_tree_new( 34.56 + nacore_content_cmp_descriptor_by_uri, 34.57 + nacore_key_cmp_descriptor_by_uri); 34.58 + if (_nandf_collection_desc_tree == NULL) 34.59 + return 0; 34.60 + 34.61 + ndf_path = nacore_env_get_var("NDF_PATH"); 34.62 + if (NACORE_STRING_IS_NULL_OR_EMPTY(ndf_path)) 34.63 + { 34.64 + /* TODO: This is *nix-only - use XDG_DATA_HOME or 34.65 + * XDG_DATA_DIRS */ 34.66 + nacore_path_home_for_each(".ndf", load_file, ndf_filter, NULL); 34.67 + nacore_path_for_each("/usr/local/share/ndf:/usr/share/ndf", 34.68 + load_file, ndf_filter, NULL); 34.69 + } 34.70 + else 34.71 + nacore_path_for_each(ndf_path, load_file, ndf_filter, NULL); 34.72 + 34.73 + if (ndf_path != NULL) 34.74 + nacore_env_free_var_value(ndf_path); 34.75 + 34.76 + return 1; 34.77 +} 34.78 + 34.79 +void 34.80 +_nandf_collection_unload_all() 34.81 +{ 34.82 + nacore_avl_tree_free(_nandf_collection_desc_tree); 34.83 + _nandf_collection_desc_tree = NULL; 34.84 +}
35.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 35.2 +++ b/naspro-bridges-bad/ndf/collection.h Fri Sep 11 13:31:52 2009 +0200 35.3 @@ -0,0 +1,20 @@ 35.4 +/* 35.5 + * NASPRO - NASPRO Architecture for Sound Processing 35.6 + * NDF (NASPRO Digital Filters) 35.7 + * 35.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 35.9 + * 35.10 + * See the COPYING file for license conditions. 35.11 + */ 35.12 + 35.13 +#ifndef _NANDF_COLLECTION_H 35.14 +#define _NANDF_COLLECTION_H 35.15 + 35.16 +#include <NASPRO/core/lib.h> 35.17 + 35.18 +char _nandf_collection_load_all(); 35.19 +void _nandf_collection_unload_all(); 35.20 + 35.21 +nacore_avl_tree_t _nandf_collection_desc_tree; 35.22 + 35.23 +#endif /* !_NANDF_COLLECTION_H */
36.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 36.2 +++ b/naspro-bridges-bad/ndf/manifest.c Fri Sep 11 13:31:52 2009 +0200 36.3 @@ -0,0 +1,71 @@ 36.4 +/* 36.5 + * NASPRO - NASPRO Architecture for Sound Processing 36.6 + * NDF (NASPRO Digital Filters) 36.7 + * 36.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 36.9 + * 36.10 + * See the COPYING file for license conditions. 36.11 + */ 36.12 + 36.13 +#include <stdio.h> 36.14 +#include <stddef.h> 36.15 + 36.16 +#include <lv2_dyn_manifest.h> 36.17 + 36.18 +#include <NASPRO/core/lib.h> 36.19 + 36.20 +#include "collection.h" 36.21 + 36.22 +/* TODO: Until a serious rescan/automagical discovery policy emerges, we perform 36.23 + * discovery only once at initialization time. */ 36.24 + 36.25 +static char inited = 0; 36.26 +static char init_ok = 0; 36.27 + 36.28 +int 36.29 +lv2_dyn_manifest_open(LV2_Dyn_Manifest_Handle *handle, 36.30 + const LV2_Feature *const *features) 36.31 +{ 36.32 + static char called = 0; 36.33 + 36.34 + if (called) 36.35 + return -1; 36.36 + called = 1; 36.37 + 36.38 + if (!inited) 36.39 + { 36.40 + init_ok = _nandf_collection_load_all(); 36.41 + inited = 1; 36.42 + } 36.43 + 36.44 + *handle = NULL; 36.45 + 36.46 + called = 0; 36.47 + 36.48 + return 0; 36.49 +} 36.50 + 36.51 +static void __attribute__((destructor)) 36.52 +fini() 36.53 +{ 36.54 + if (init_ok) 36.55 + _nandf_collection_unload_all(); 36.56 +} 36.57 + 36.58 +int 36.59 +lv2_dyn_manifest_get_subjects(LV2_Dyn_Manifest_Handle handle, FILE *fp) 36.60 +{ 36.61 + return 0; 36.62 +} 36.63 + 36.64 +int 36.65 +lv2_dyn_manifest_get_data(LV2_Dyn_Manifest_Handle handle, FILE *fp, 36.66 + const char *uri) 36.67 +{ 36.68 + return 0; 36.69 +} 36.70 + 36.71 +void 36.72 +lv2_dyn_manifest_close(LV2_Dyn_Manifest_Handle handle) 36.73 +{ 36.74 +}
37.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 37.2 +++ b/naspro-bridges-bad/ndf/manifest.ttl Fri Sep 11 13:31:52 2009 +0200 37.3 @@ -0,0 +1,14 @@ 37.4 +# 37.5 +# NASPRO - NASPRO Architecture for Sound Processing 37.6 +# NDF (NASPRO Digital Filters) 37.7 +# 37.8 +# Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 37.9 +# 37.10 +# See the COPYING file for license conditions. 37.11 +# 37.12 + 37.13 +@prefix lv2: <http://lv2plug.in/ns/lv2core#>. 37.14 +@prefix dman: <http://lv2plug.in/ns/ext/dynmanifest#>. 37.15 + 37.16 +<http://naspro.atheme.org/ndf> a dman:DynManifest; 37.17 + lv2:binary <ndf.so>.
38.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 38.2 +++ b/naspro-bridges-bad/ndf/parser.y Fri Sep 11 13:31:52 2009 +0200 38.3 @@ -0,0 +1,32 @@ 38.4 +%{ 38.5 +static void 38.6 +yyerror(const char *str) 38.7 +{ 38.8 +} 38.9 + 38.10 +static int 38.11 +yywrap() 38.12 +{ 38.13 + return 1; 38.14 +} 38.15 +%} 38.16 + 38.17 +%union 38.18 + { 38.19 + float f; 38.20 + } 38.21 + 38.22 +%token IN OUT MONO STEREO COLON SEP 38.23 +%token <f> FLOAT 38.24 + 38.25 +%% 38.26 + 38.27 +file: SEP s2 SEP s3 SEP s4 SEP s5 ; 38.28 + 38.29 +s2: ; 38.30 + 38.31 +s3: ; 38.32 + 38.33 +s4: ; 38.34 + 38.35 +s5: ;
39.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 39.2 +++ b/naspro-bridges-bad/ndf/scanner.l Fri Sep 11 13:31:52 2009 +0200 39.3 @@ -0,0 +1,82 @@ 39.4 +/* 39.5 + * NASPRO - NASPRO Architecture for Sound Processing 39.6 + * NDF (NASPRO Digital Filters) 39.7 + * 39.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 39.9 + * 39.10 + * See the COPYING file for license conditions. 39.11 + */ 39.12 + 39.13 +%x S1 S2 S3 S4 39.14 + 39.15 +NEWLINE (\n|\n\r|\r\n) 39.16 + 39.17 +%% 39.18 + 39.19 +^NDF0002T/{NEWLINE} BEGIN S1; 39.20 + 39.21 +<S1>uri return URI; 39.22 +<S1>name return NAME; 39.23 +<S1>creator return CREATOR; 39.24 +<S1>rights return RIGHTS; 39.25 +<S1>class return CLASS; 39.26 +<S1>generator return GENERATOR; 39.27 +<S1>instrument return INSTRUMENT; 39.28 +<S1>oscillator return OSCILLATOR; 39.29 +<S1>utility return UTILITY; 39.30 +<S1>converter return CONVERTER; 39.31 +<S1>analyser return ANALYSER; 39.32 +<S1>simulator return SIMULATOR; 39.33 +<S1>delay return DELAY; 39.34 +<S1>modulator return MODULATOR; 39.35 +<S1>reverb return REVERB; 39.36 +<S1>phaser return PHASER; 39.37 +<S1>flanger return FLANGER; 39.38 +<S1>chorus return CHORUS; 39.39 +<S1>filter return FILTER; 39.40 +<S1>lowpass return LOWPASS; 39.41 +<S1>bandpass return BANDPASS; 39.42 +<S1>highpass return HIGHPASS; 39.43 +<S1>comb return COMB; 39.44 +<S1>allpass return ALLPASS; 39.45 +<S1>eq return EQ; 39.46 +<S1>paraeq return PARAEQ; 39.47 +<S1>multieq return MULTIEQ; 39.48 +<S1>spectral return SPECTRAL; 39.49 +<S1>pitch return PITCH; 39.50 +<S1>amplifier return AMPLIFIER; 39.51 +<S1>distortion return DISTORTION; 39.52 +<S1>waveshaper return WAVESHAPER; 39.53 +<S1>dynamics return DYNAMICS; 39.54 +<S1>compressor return COMPRESSOR; 39.55 +<S1>expander return EXPANDER; 39.56 +<S1>limiter return LIMITER; 39.57 +<S1>gate return GATE; 39.58 + 39.59 +<S1>^"%%"/{NEWLINE} BEGIN S2; return SEP; 39.60 + 39.61 +<S2>audio return AUDIO; 39.62 +<S2>control return CONTROL; 39.63 +<S2>in return IN; 39.64 +<S2>out return OUT; 39.65 +<S2>as return AS; 39.66 +<S2>to return TO; 39.67 +<S2>default return DEFAULT; 39.68 +<S2>minimum return MINIMUM; 39.69 +<S2>maximum return MAXIMUM; 39.70 + 39.71 +<S2>^"%%"/{NEWLINE} BEGIN S3; return SEP; 39.72 + 39.73 +<S3>include return INCLUDE; 39.74 +<S3>sample_rate return SAMPLE_RATE; 39.75 + 39.76 +<S1,S2>\"([:print:]{-}[{NEWLINE}]|\\\")*\" return STRING; 39.77 +<S2,S3>, return COMA; 39.78 +<S1,S2>: return COLON; 39.79 +<S1,S2,S3>; return SEMICOLON; 39.80 +<S1,S2,S3>[_a-zA-Z][_0-9a-zA-Z]* return IDENTIFIER; 39.81 + 39.82 +<S3>\( return LPAR; 39.83 +<S3>\) return RPAR; 39.84 +<S3>\{ return LBRACE; 39.85 +<S3>\} return RBRACE;
40.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 40.2 +++ b/naspro-core/COPYING Fri Sep 11 13:31:52 2009 +0200 40.3 @@ -0,0 +1,24 @@ 40.4 +Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 40.5 +All rights reserved. 40.6 + 40.7 +Redistribution and use in source and binary forms, with or without 40.8 +modification, are permitted provided that the following conditions 40.9 +are met: 40.10 + 1. Redistributions of source code must retain the above copyright 40.11 + notice, this list of conditions and the following disclaimer. 40.12 + 2. Redistributions in binary form must reproduce the above copyright 40.13 + notice, this list of conditions and the following disclaimer in the 40.14 + documentation and/or other materials provided with the distribution. 40.15 + 3. The name of the author may not be used to endorse or promote products 40.16 + derived from this software without specific prior written permission. 40.17 + 40.18 +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 40.19 +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 40.20 +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 40.21 +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 40.22 +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 40.23 +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 40.24 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 40.25 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 40.26 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 40.27 +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 41.2 +++ b/naspro-core/Makefile Fri Sep 11 13:31:52 2009 +0200 41.3 @@ -0,0 +1,59 @@ 41.4 +.POSIX: 41.5 + 41.6 +.SUFFIXES: 41.7 + 41.8 +### Change this... 41.9 + 41.10 +PREFIX = /usr/local 41.11 +LIB_DIR = $(PREFIX)/lib 41.12 +INCLUDE_DIR = $(PREFIX)/include 41.13 + 41.14 +CC = gcc 41.15 +CFLAGS = -O2 -ansi -pedantic -Wall -fPIC 41.16 + 41.17 +DL_LDFLAGS = -ldl 41.18 +LDFLAGS = -shared $(DL_LDFLAGS) 41.19 + 41.20 +SO_FILE_EXT = .so 41.21 + 41.22 +### ... but not this 41.23 + 41.24 +TARGETS = src/libnacore.so 41.25 + 41.26 +LIBNACORE_SOURCES = src/avl.c \ 41.27 + src/dl.h \ 41.28 + src/init.c \ 41.29 + src/lv2api.c \ 41.30 + src/manifest.c \ 41.31 + src/path.h \ 41.32 + src/posix/dl.c \ 41.33 + src/posix/env.c \ 41.34 + src/posix/path.c 41.35 + 41.36 +INCLUDE_PATHS = -I. -Iinclude 41.37 + 41.38 +HEADERS = include/NASPRO/core/avl.h \ 41.39 + include/NASPRO/core/bridge.h \ 41.40 + include/NASPRO/core/dl.h \ 41.41 + include/NASPRO/core/env.h \ 41.42 + include/NASPRO/core/lib.h \ 41.43 + include/NASPRO/core/lv2api.h \ 41.44 + include/NASPRO/core/manifest.h \ 41.45 + include/NASPRO/core/path.h \ 41.46 + include/NASPRO/core/string.h 41.47 + 41.48 +DEFS = -DSO_FILE_EXT="\"$(SO_FILE_EXT)\"" 41.49 + 41.50 +all: $(TARGETS) 41.51 + 41.52 +src/libnacore.so: $(LIBNACORE_SOURCES) $(HEADERS) 41.53 + $(CC) $(CFLAGS) $(LDFLAGS) $(DEFS) $(INCLUDE_PATHS) \ 41.54 + $(LIBNACORE_SOURCES) -o $@ 41.55 + 41.56 +install: $(TARGETS) $(HEADERS) 41.57 + cp src/libnacore.so $(LIB_DIR) 41.58 + mkdir -p $(INCLUDE_DIR) 41.59 + cp -R include/NASPRO $(INCLUDE_DIR) 41.60 + 41.61 +clean: 41.62 + rm -f $(TARGETS)
42.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 42.2 +++ b/naspro-core/include/NASPRO/core/avl.h Fri Sep 11 13:31:52 2009 +0200 42.3 @@ -0,0 +1,30 @@ 42.4 +/* 42.5 + * NASPRO - NASPRO Architecture for Sound Processing 42.6 + * Core library 42.7 + * 42.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 42.9 + * 42.10 + * See the COPYING file for license conditions. 42.11 + */ 42.12 + 42.13 +#ifndef _NACORE_AVL_H 42.14 +#define _NACORE_AVL_H 42.15 + 42.16 +#include <stdlib.h> 42.17 + 42.18 +typedef struct _nacore_avl_tree * nacore_avl_tree_t; 42.19 + 42.20 +nacore_avl_tree_t nacore_avl_tree_new(int (*content_cmp)(void *c1, void *c2), 42.21 + int (*key_cmp)(void *content, void *key)); 42.22 +void nacore_avl_tree_add(nacore_avl_tree_t tree, void *content); 42.23 +void nacore_avl_tree_for_each(nacore_avl_tree_t tree, 42.24 + void (*callback)(void *content, void *data), 42.25 + void *data); 42.26 +void *nacore_avl_tree_find(nacore_avl_tree_t tree, void *key); 42.27 +size_t nacore_avl_tree_get_nodes_count(nacore_avl_tree_t tree); 42.28 +void nacore_avl_tree_free(nacore_avl_tree_t tree); 42.29 + 42.30 +int nacore_content_cmp_descriptor_by_uri(void *c1, void *c2); 42.31 +int nacore_key_cmp_descriptor_by_uri(void *content, void *data); 42.32 + 42.33 +#endif /* !_NACORE_AVL_H */
43.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 43.2 +++ b/naspro-core/include/NASPRO/core/bridge.h Fri Sep 11 13:31:52 2009 +0200 43.3 @@ -0,0 +1,169 @@ 43.4 +/* 43.5 + * NASPRO - NASPRO Architecture for Sound Processing 43.6 + * Core library 43.7 + * 43.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 43.9 + * 43.10 + * See the COPYING file for license conditions. 43.11 + */ 43.12 + 43.13 +#ifndef _NACORE_BRIDGE_H 43.14 +#define _NACORE_BRIDGE_H 43.15 + 43.16 +#include <stdlib.h> 43.17 +#include <stdio.h> 43.18 +#include <stdint.h> 43.19 + 43.20 +#include <lv2.h> 43.21 + 43.22 +#ifdef __cplusplus 43.23 +extern "C" { 43.24 +#endif 43.25 + 43.26 +/* Plugins beloging to a subclass should have the superclass disabled: 43.27 + * e.g. if NACORE_DESCRIPTOR_CLASS_INSTRUMENT is on, then 43.28 + * NACORE_DESCRIPTOR_CLASS_GENERATOR must be off. */ 43.29 + 43.30 +/* descriptor.classes_1 */ 43.31 +#define NACORE_DESCRIPTOR_CLASS_GENERATOR (1) 43.32 +#define NACORE_DESCRIPTOR_CLASS_INSTRUMENT (1 << 1) 43.33 +#define NACORE_DESCRIPTOR_CLASS_OSCILLATOR (1 << 2) 43.34 +#define NACORE_DESCRIPTOR_CLASS_UTILITY (1 << 3) 43.35 +#define NACORE_DESCRIPTOR_CLASS_CONVERTER (1 << 4) 43.36 +#define NACORE_DESCRIPTOR_CLASS_ANALYSER (1 << 5) 43.37 +#define NACORE_DESCRIPTOR_CLASS_MIXER (1 << 6) 43.38 +#define NACORE_DESCRIPTOR_CLASS_SIMULATOR (1 << 7) 43.39 +#define NACORE_DESCRIPTOR_CLASS_DELAY (1 << 8) 43.40 +#define NACORE_DESCRIPTOR_CLASS_MODULATOR (1 << 9) 43.41 +#define NACORE_DESCRIPTOR_CLASS_REVERB (1 << 10) 43.42 +#define NACORE_DESCRIPTOR_CLASS_PHASER (1 << 11) 43.43 +#define NACORE_DESCRIPTOR_CLASS_FLANGER (1 << 12) 43.44 +#define NACORE_DESCRIPTOR_CLASS_CHORUS (1 << 13) 43.45 +#define NACORE_DESCRIPTOR_CLASS_FILTER (1 << 14) 43.46 +#define NACORE_DESCRIPTOR_CLASS_LOWPASS (1 << 15) 43.47 +#define NACORE_DESCRIPTOR_CLASS_BANDPASS (1 << 16) 43.48 +#define NACORE_DESCRIPTOR_CLASS_HIGHPASS (1 << 17) 43.49 +#define NACORE_DESCRIPTOR_CLASS_COMB (1 << 18) 43.50 +#define NACORE_DESCRIPTOR_CLASS_ALLPASS (1 << 19) 43.51 +#define NACORE_DESCRIPTOR_CLASS_EQ (1 << 20) 43.52 +#define NACORE_DESCRIPTOR_CLASS_PARAEQ (1 << 21) 43.53 +#define NACORE_DESCRIPTOR_CLASS_MULTIEQ (1 << 22) 43.54 +#define NACORE_DESCRIPTOR_CLASS_SPECTRAL (1 << 23) 43.55 +#define NACORE_DESCRIPTOR_CLASS_PITCH (1 << 24) 43.56 +#define NACORE_DESCRIPTOR_CLASS_AMPLIFIER (1 << 25) 43.57 +#define NACORE_DESCRIPTOR_CLASS_DISTORTION (1 << 26) 43.58 +#define NACORE_DESCRIPTOR_CLASS_WAVESHAPER (1 << 27) 43.59 + 43.60 +/* descriptor.classes_2 */ 43.61 +#define NACORE_DESCRIPTOR_CLASS_DYNAMICS (1) 43.62 +#define NACORE_DESCRIPTOR_CLASS_COMPRESSOR (1 << 1) 43.63 +#define NACORE_DESCRIPTOR_CLASS_EXPANDER (1 << 2) 43.64 +#define NACORE_DESCRIPTOR_CLASS_LIMITER (1 << 3) 43.65 +#define NACORE_DESCRIPTOR_CLASS_GATE (1 << 4) 43.66 + 43.67 +/* descriptor.properties */ 43.68 +#define NACORE_DESCRIPTOR_HAS_LIVE_DEP (1) 43.69 +#define NACORE_DESCRIPTOR_INPLACE_BROKEN (1 << 1) 43.70 +#define NACORE_DESCRIPTOR_HARD_RT_CAPABLE (1 << 2) 43.71 + 43.72 +/* port_descriptor.properties */ 43.73 +#define NACORE_PORT_IS_OUTPUT (1) 43.74 +#define NACORE_PORT_IS_AUDIO (1 << 1) 43.75 +#define NACORE_PORT_IS_MIDI (1 << 2) 43.76 +#define NACORE_PORT_CONNECTION_OPTIONAL (1 << 3) 43.77 +#define NACORE_PORT_REPORTS_LATENCY (1 << 4) 43.78 +#define NACORE_PORT_TOGGLED (1 << 5) 43.79 +#define NACORE_PORT_SAMPLE_RATE (1 << 6) 43.80 +#define NACORE_PORT_INTEGER (1 << 7) 43.81 +#define NACORE_PORT_LOGARITHMIC (1 << 8) 43.82 + 43.83 +/* port_descriptor.scale.properties */ 43.84 +#define NACORE_SCALE_HAS_MIN (1) 43.85 +#define NACORE_SCALE_HAS_MAX (1 << 1) 43.86 +#define NACORE_SCALE_HAS_DEFAULT (1 << 2) 43.87 + 43.88 +enum nacore_scale_unit 43.89 + { 43.90 + nacore_scale_unit_none = 0, 43.91 + nacore_scale_unit_bar, 43.92 + nacore_scale_unit_beat, 43.93 + nacore_scale_unit_bpm, 43.94 + nacore_scale_unit_cent, 43.95 + nacore_scale_unit_cm, 43.96 + nacore_scale_unit_coeff, 43.97 + nacore_scale_unit_db, 43.98 + nacore_scale_unit_deg, 43.99 + nacore_scale_unit_hz, 43.100 + nacore_scale_unit_inch, 43.101 + nacore_scale_unit_khz, 43.102 + nacore_scale_unit_km, 43.103 + nacore_scale_unit_m, 43.104 + nacore_scale_unit_mhz, 43.105 + nacore_scale_unit_midi_note, 43.106 + nacore_scale_unit_mi, 43.107 + nacore_scale_unit_min, 43.108 + nacore_scale_unit_mm, 43.109 + nacore_scale_unit_ms, 43.110 + nacore_scale_unit_oct, 43.111 + nacore_scale_unit_pc, 43.112 + nacore_scale_unit_s, 43.113 + nacore_scale_unit_semitone 43.114 + }; 43.115 + 43.116 +struct nacore_scale_point 43.117 + { 43.118 + char *label; 43.119 + float value; 43.120 + }; 43.121 + 43.122 +struct nacore_port_scale 43.123 + { 43.124 + uint32_t properties; 43.125 + float min; 43.126 + float max; 43.127 + float defaultv; 43.128 + enum nacore_scale_unit unit; 43.129 + struct nacore_scale_point *points; 43.130 + size_t points_count; 43.131 + }; 43.132 + 43.133 +struct nacore_port_descriptor 43.134 + { 43.135 + char *name; 43.136 + uint32_t properties; 43.137 + struct nacore_port_scale scale; 43.138 + void *data; 43.139 + }; 43.140 + 43.141 +struct nacore_descriptor 43.142 + { 43.143 + char *name; 43.144 + char *uri; 43.145 + char *creator; 43.146 + char *rights; 43.147 + struct nacore_port_descriptor *port_descs; 43.148 + size_t port_descs_count; 43.149 + uint32_t properties; 43.150 + uint32_t classes_1; 43.151 + uint32_t classes_2; 43.152 + void *data; 43.153 + 43.154 + LV2_Handle (*instantiate) (const LV2_Descriptor *descriptor, 43.155 + double sample_rate, 43.156 + const char *bundle_path, 43.157 + const LV2_Feature * const *features); 43.158 + void (*connect_port) (LV2_Handle instance, uint32_t port, 43.159 + void *data_location); 43.160 + void (*activate) (LV2_Handle instance); 43.161 + void (*run) (LV2_Handle instance, 43.162 + uint32_t sample_count); 43.163 + void (*deactivate) (LV2_Handle instance); 43.164 + void (*cleanup) (LV2_Handle instance); 43.165 + const void * (*extension_data)(const char *uri); 43.166 + }; 43.167 + 43.168 +#ifdef __cplusplus 43.169 +} 43.170 +#endif 43.171 + 43.172 +#endif /* !_NACORE_BRIDGE_H */
44.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 44.2 +++ b/naspro-core/include/NASPRO/core/dl.h Fri Sep 11 13:31:52 2009 +0200 44.3 @@ -0,0 +1,28 @@ 44.4 +/* 44.5 + * NASPRO - NASPRO Architecture for Sound Processing 44.6 + * Core library 44.7 + * 44.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 44.9 + * 44.10 + * See the COPYING file for license conditions. 44.11 + */ 44.12 + 44.13 +#ifndef _NACORE_DL_H 44.14 +#define _NACORE_DL_H 44.15 + 44.16 +#ifdef __cplusplus 44.17 +extern "C" { 44.18 +#endif 44.19 + 44.20 +typedef struct _nacore_dl_module * nacore_dl_module_t; 44.21 + 44.22 +nacore_dl_module_t nacore_dl_open(const char *file); 44.23 +void * nacore_dl_sym(nacore_dl_module_t handle, const char *symbol); 44.24 +void nacore_dl_close(nacore_dl_module_t handle); 44.25 +char nacore_dl_filename_filter(const char *file); 44.26 + 44.27 +#ifdef __cplusplus 44.28 +} 44.29 +#endif 44.30 + 44.31 +#endif /* !_NACORE_DL_H */
45.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 45.2 +++ b/naspro-core/include/NASPRO/core/env.h Fri Sep 11 13:31:52 2009 +0200 45.3 @@ -0,0 +1,16 @@ 45.4 +/* 45.5 + * NASPRO - NASPRO Architecture for Sound Processing 45.6 + * Core library 45.7 + * 45.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 45.9 + * 45.10 + * See the COPYING file for license conditions. 45.11 + */ 45.12 + 45.13 +#ifndef _NACORE_ENV_H 45.14 +#define _NACORE_ENV_H 45.15 + 45.16 +char * nacore_env_get_var(const char *name); 45.17 +void nacore_env_free_var_value(char *value); 45.18 + 45.19 +#endif /* !_NACORE_ENV_H */
46.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 46.2 +++ b/naspro-core/include/NASPRO/core/lib.h Fri Sep 11 13:31:52 2009 +0200 46.3 @@ -0,0 +1,22 @@ 46.4 +/* 46.5 + * NASPRO - NASPRO Architecture for Sound Processing 46.6 + * Core library 46.7 + * 46.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 46.9 + * 46.10 + * See the COPYING file for license conditions. 46.11 + */ 46.12 + 46.13 +#ifndef _NACORE_LIB_H 46.14 +#define _NACORE_LIB_H 46.15 + 46.16 +#include <NASPRO/core/string.h> 46.17 +#include <NASPRO/core/env.h> 46.18 +#include <NASPRO/core/path.h> 46.19 +#include <NASPRO/core/dl.h> 46.20 +#include <NASPRO/core/bridge.h> 46.21 +#include <NASPRO/core/lv2api.h> 46.22 +#include <NASPRO/core/avl.h> 46.23 +#include <NASPRO/core/manifest.h> 46.24 + 46.25 +#endif /* !_NACORE_LIB_H */
47.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 47.2 +++ b/naspro-core/include/NASPRO/core/lv2api.h Fri Sep 11 13:31:52 2009 +0200 47.3 @@ -0,0 +1,20 @@ 47.4 +/* 47.5 + * NASPRO - NASPRO Architecture for Sound Processing 47.6 + * Core library 47.7 + * 47.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 47.9 + * 47.10 + * See the COPYING file for license conditions. 47.11 + */ 47.12 + 47.13 +#ifndef _NACORE_LV2API_H 47.14 +#define _NACORE_LV2API_H 47.15 + 47.16 +#include <lv2.h> 47.17 + 47.18 +#include <NASPRO/core/bridge.h> 47.19 + 47.20 +void nacore_lv2api_fill_desc(LV2_Descriptor *lv2_desc, 47.21 + struct nacore_descriptor *n_desc); 47.22 + 47.23 +#endif /* !_NACORE_LV2API_H */
48.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 48.2 +++ b/naspro-core/include/NASPRO/core/manifest.h Fri Sep 11 13:31:52 2009 +0200 48.3 @@ -0,0 +1,21 @@ 48.4 +/* 48.5 + * NASPRO - NASPRO Architecture for Sound Processing 48.6 + * Core library 48.7 + * 48.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 48.9 + * 48.10 + * See the COPYING file for license conditions. 48.11 + */ 48.12 + 48.13 +#ifndef _NACORE_MANIFEST_H 48.14 +#define _NACORE_MANIFEST_H 48.15 + 48.16 +#include <stdio.h> 48.17 + 48.18 +void nacore_manifest_print_subject_prefixes(FILE *fp); 48.19 +void nacore_manifest_print_subject_triple(struct nacore_descriptor *desc, 48.20 + FILE *fp); 48.21 +void nacore_manifest_print_data(struct nacore_descriptor *desc, FILE *fp, 48.22 + const char *binary); 48.23 + 48.24 +#endif /* !_NACORE_MANIFEST_H */
49.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 49.2 +++ b/naspro-core/include/NASPRO/core/path.h Fri Sep 11 13:31:52 2009 +0200 49.3 @@ -0,0 +1,28 @@ 49.4 +/* 49.5 + * NASPRO - NASPRO Architecture for Sound Processing 49.6 + * Core library 49.7 + * 49.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 49.9 + * 49.10 + * See the COPYING file for license conditions. 49.11 + */ 49.12 + 49.13 +#ifndef _NACORE_PATH_H 49.14 +#define _NACORE_PATH_H 49.15 + 49.16 +#ifdef __cplusplus 49.17 +extern "C" { 49.18 +#endif 49.19 + 49.20 +void nacore_path_for_each(const char *path, 49.21 + void (*callback)(const char *file, const char *basename, void *data), 49.22 + char (*filter)(const char *file), void *data); 49.23 +void nacore_path_home_for_each(const char *dir, 49.24 + void (*callback)(const char *file, const char *basename, void *data), 49.25 + char (*filter)(const char *file), void *data); 49.26 + 49.27 +#ifdef __cplusplus 49.28 +} 49.29 +#endif 49.30 + 49.31 +#endif /* !_NACORE_PATH_H */
50.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 50.2 +++ b/naspro-core/include/NASPRO/core/string.h Fri Sep 11 13:31:52 2009 +0200 50.3 @@ -0,0 +1,15 @@ 50.4 +/* 50.5 + * NASPRO - NASPRO Architecture for Sound Processing 50.6 + * Core library 50.7 + * 50.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 50.9 + * 50.10 + * See the COPYING file for license conditions. 50.11 + */ 50.12 + 50.13 +#ifndef _NACORE_STRING_H 50.14 +#define _NACORE_STRING_H 50.15 + 50.16 +#define NACORE_STRING_IS_NULL_OR_EMPTY(s) ((s == NULL) ? 1 : (*s == '\0')) 50.17 + 50.18 +#endif /* !_NACORE_STRING_H */
51.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 51.2 +++ b/naspro-core/src/avl.c Fri Sep 11 13:31:52 2009 +0200 51.3 @@ -0,0 +1,414 @@ 51.4 +/* 51.5 + * NASPRO - NASPRO Architecture for Sound Processing 51.6 + * Core library 51.7 + * 51.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 51.9 + * 51.10 + * See the COPYING file for license conditions. 51.11 + */ 51.12 + 51.13 +#include <stdlib.h> 51.14 +#include <string.h> 51.15 + 51.16 +#include <NASPRO/core/lib.h> 51.17 + 51.18 +/* TODO: Nothing here is thread-safe. */ 51.19 + 51.20 +struct avl_tree_node 51.21 + { 51.22 + size_t father; 51.23 + size_t left; 51.24 + size_t right; 51.25 + size_t l_height; 51.26 + size_t r_height; 51.27 + void *content; 51.28 + }; 51.29 + 51.30 +struct _nacore_avl_tree 51.31 + { 51.32 + size_t root; 51.33 + struct avl_tree_node *nodes; 51.34 + size_t count; 51.35 + 51.36 + int (*content_cmp) (void *c1, void *c2); 51.37 + int (*key_cmp) (void *content, void *key); 51.38 + }; 51.39 + 51.40 +nacore_avl_tree_t 51.41 +nacore_avl_tree_new(int (*content_cmp) (void *c1, void *c2), 51.42 + int (*key_cmp) (void *content, void *key)) 51.43 +{ 51.44 + nacore_avl_tree_t tree; 51.45 + 51.46 + tree = malloc(sizeof(struct _nacore_avl_tree)); 51.47 + if (tree == NULL) 51.48 + return NULL; 51.49 + 51.50 + tree->root = 0; 51.51 + tree->nodes = NULL; 51.52 + tree->count = 0; 51.53 + tree->content_cmp = content_cmp; 51.54 + tree->key_cmp = key_cmp; 51.55 + 51.56 + return tree; 51.57 +} 51.58 + 51.59 +#define max(x, y) (((x) > (y)) ? (x) : (y)) 51.60 + 51.61 +#if 0 51.62 +static void 51.63 +node_dump(nacore_avl_tree_t tree, struct avl_tree_node *node) 51.64 +{ 51.65 + printf(" node: %lu (%p), father: %lu (%p), left: %lu (%p), right: %lu (%p), l_height: %lu, r_height: %lu\n", 51.66 + node - tree->nodes + 1, node, 51.67 + node->father, tree->nodes + node->father - 1, 51.68 + node->left, tree->nodes + node->left - 1, 51.69 + node->right, tree->nodes + node->right - 1, 51.70 + node->l_height, node->r_height); 51.71 + if (node->left != 0) 51.72 + node_dump(tree, tree->nodes + node->left - 1); 51.73 + if (node->right != 0) 51.74 + node_dump(tree, tree->nodes + node->right - 1); 51.75 +} 51.76 + 51.77 +static void 51.78 +tree_dump(nacore_avl_tree_t tree) 51.79 +{ 51.80 + printf("Tree: %p, nodes: %lu, root: %lu (%p)\n", tree, tree->count, tree->root, tree->nodes + tree->root - 1); 51.81 + if (tree->root != 0) 51.82 + node_dump(tree, tree->nodes + tree->root - 1); 51.83 +} 51.84 +#endif 51.85 + 51.86 +static void 51.87 +adjust_heights(nacore_avl_tree_t tree, struct avl_tree_node *p) 51.88 +{ 51.89 + struct avl_tree_node *p2; 51.90 + 51.91 + for (p2 = p, p = (p->father == 0) ? NULL : tree->nodes + p->father - 1; 51.92 + p != NULL; 51.93 + p2 = p, p = (p->father == 0) ? NULL : tree->nodes + p2->father - 1) 51.94 + { 51.95 + if (p->left == p2 - tree->nodes + 1) 51.96 + p->l_height = max(p2->l_height, p2->r_height) + 1; 51.97 + else 51.98 + p->r_height = max(p2->l_height, p2->r_height) + 1; 51.99 + } 51.100 +} 51.101 + 51.102 +void 51.103 +nacore_avl_tree_add(nacore_avl_tree_t tree, void *content) 51.104 +{ 51.105 + struct avl_tree_node *p, *tmp, *tmp2; 51.106 + 51.107 + /* Allocation */ 51.108 + tmp = realloc(tree->nodes, 51.109 + (tree->count + 1) * sizeof(struct avl_tree_node)); 51.110 + if (tmp == NULL) 51.111 + return; 51.112 + 51.113 + tree->nodes = tmp; 51.114 + tmp = tree->nodes + tree->count; 51.115 + 51.116 + tmp->content = content; 51.117 + tmp->father = 0; 51.118 + tmp->left = 0; 51.119 + tmp->right = 0; 51.120 + tmp->l_height = 0; 51.121 + tmp->r_height = 0; 51.122 + tree->count++; 51.123 + 51.124 + /* Insertion */ 51.125 + if (tree->root == 0) 51.126 + { 51.127 + tree->root = 1; 51.128 + return; 51.129 + } 51.130 + 51.131 + p = tree->nodes + tree->root - 1; 51.132 + while (1) 51.133 + { 51.134 + if (tree->content_cmp(content, p->content) > 0) 51.135 + { 51.136 + if (p->right != 0) 51.137 + p = tree->nodes + p->right - 1; 51.138 + else 51.139 + { 51.140 + p->r_height = 1; 51.141 + p->right = tree->count; 51.142 + tmp->father = p - tree->nodes + 1; 51.143 + adjust_heights(tree, p); 51.144 + break; 51.145 + } 51.146 + } 51.147 + else 51.148 + { 51.149 + if (p->left != 0) 51.150 + p = tree->nodes + p->left - 1; 51.151 + else 51.152 + { 51.153 + p->l_height = 1; 51.154 + p->left = tree->count; 51.155 + tmp->father = p - tree->nodes + 1; 51.156 + adjust_heights(tree, p); 51.157 + break; 51.158 + } 51.159 + } 51.160 + } 51.161 + 51.162 + /* Balancing */ 51.163 + while (p->father != 0) 51.164 + { 51.165 + p = tree->nodes + p->father - 1; 51.166 + 51.167 + if ((p->l_height - p->r_height) == 2) 51.168 + { 51.169 + if (tree->nodes[p->left - 1].l_height 51.170 + == (p->l_height - 1)) 51.171 + { 51.172 + /* right rotation */ 51.173 + 51.174 + /* p is root, tmp is pivot */ 51.175 + tmp = tree->nodes + p->left - 1; 51.176 + 51.177 + p->left = tmp->right; 51.178 + tmp->right = p - tree->nodes + 1; 51.179 + 51.180 + p->l_height = tmp->r_height; 51.181 + tmp->r_height = max(p->l_height, p->r_height) 51.182 + + 1; 51.183 + 51.184 + tmp->father = p->father; 51.185 + p->father = tmp - tree->nodes + 1; 51.186 + 51.187 + if (p->left != 0) 51.188 + tree->nodes[p->left - 1].father = 51.189 + p - tree->nodes + 1; 51.190 + 51.191 + if (tmp->father != 0) 51.192 + { 51.193 + if (tree->nodes[tmp->father - 1].left 51.194 + == p - tree->nodes + 1) 51.195 + tree->nodes[tmp->father 51.196 + - 1].left = 51.197 + tmp - tree->nodes + 1; 51.198 + else 51.199 + tree->nodes[tmp->father 51.200 + - 1].right = 51.201 + tmp - tree->nodes + 1; 51.202 + } 51.203 + 51.204 + adjust_heights(tree, p); 51.205 + } 51.206 + else 51.207 + { 51.208 + /* left-right rotation */ 51.209 + 51.210 + /* p is root's father, tmp is pivot, 51.211 + * tmp2 is root */ 51.212 + tmp = tree->nodes 51.213 + + tree->nodes[p->left - 1].right - 1; 51.214 + tmp2 = tree->nodes + tmp->father - 1; 51.215 + 51.216 + p->left = tmp->right; 51.217 + tmp2->right = tmp->left; 51.218 + tmp->left = tmp2 - tree->nodes + 1; 51.219 + tmp->right = p - tree->nodes + 1; 51.220 + 51.221 + p->l_height = tmp->r_height; 51.222 + tmp2->r_height = tmp->l_height; 51.223 + tmp->l_height = max(tmp2->l_height, 51.224 + tmp2->r_height) + 1; 51.225 + tmp->r_height = max(p->l_height, p->r_height) 51.226 + + 1; 51.227 + 51.228 + tmp->father = p->father; 51.229 + p->father = tmp - tree->nodes + 1; 51.230 + tmp2->father = tmp - tree->nodes + 1; 51.231 + 51.232 + if (tmp2->right != 0) 51.233 + tree->nodes[tmp2->right - 1].father = 51.234 + tmp2 - tree->nodes + 1; 51.235 + if (p->left != 0) 51.236 + tree->nodes[p->left - 1].father = 51.237 + p - tree->nodes + 1; 51.238 + 51.239 + if (tmp->father != 0) 51.240 + { 51.241 + if (tree->nodes[tmp->father - 1].left 51.242 + == p - tree->nodes + 1) 51.243 + tree->nodes[tmp->father 51.244 + - 1].left = 51.245 + tmp - tree->nodes + 1; 51.246 + else 51.247 + tree->nodes[tmp->father 51.248 + - 1].right = 51.249 + tmp - tree->nodes + 1; 51.250 + } 51.251 + 51.252 + adjust_heights(tree, p); 51.253 + } 51.254 + } 51.255 + else if ((p->r_height - p->l_height) == 2) 51.256 + { 51.257 + if (tree->nodes[p->right - 1].r_height 51.258 + == (p->r_height - 1)) 51.259 + { 51.260 + /* left rotation */ 51.261 + 51.262 + /* p is root, tmp is pivot */ 51.263 + 51.264 + tmp = tree->nodes + p->right - 1; 51.265 + 51.266 + p->right = tmp->left; 51.267 + tmp->left = p - tree->nodes + 1; 51.268 + 51.269 + p->r_height = tmp->l_height; 51.270 + tmp->l_height = max(p->l_height, p->r_height) 51.271 + + 1; 51.272 + 51.273 + tmp->father = p->father; 51.274 + p->father = tmp - tree->nodes + 1; 51.275 + 51.276 + if (p->right != 0) 51.277 + tree->nodes[p->right - 1].father = 51.278 + p - tree->nodes + 1; 51.279 + 51.280 + if (tmp->father != 0) 51.281 + { 51.282 + if (tree->nodes[tmp->father - 1].left 51.283 + == p - tree->nodes + 1) 51.284 + tree->nodes[tmp->father 51.285 + - 1].left = 51.286 + tmp - tree->nodes + 1; 51.287 + else 51.288 + tree->nodes[tmp->father 51.289 + - 1].right = 51.290 + tmp - tree->nodes + 1; 51.291 + } 51.292 + 51.293 + adjust_heights(tree, p); 51.294 + } 51.295 + else 51.296 + { 51.297 + /* right-left rotation */ 51.298 + 51.299 + /* p is root's father, tmp is pivot, 51.300 + * tmp2 is root */ 51.301 + 51.302 + tmp = tree->nodes + 51.303 + tree->nodes[p->right - 1].left - 1; 51.304 + tmp2 = tree->nodes + tmp->father - 1; 51.305 + 51.306 + p->right = tmp->left; 51.307 + tmp2->left = tmp->right; 51.308 + tmp->left = p - tree->nodes + 1; 51.309 + tmp->right = tmp2 - tree->nodes + 1; 51.310 + 51.311 + p->r_height = tmp->l_height; 51.312 + tmp2->l_height = tmp->r_height; 51.313 + tmp->l_height = max(p->l_height, p->r_height) 51.314 + + 1; 51.315 + tmp->r_height = max(tmp2->l_height, 51.316 + tmp2->r_height) + 1; 51.317 + 51.318 + tmp->father = p->father; 51.319 + p->father = tmp - tree->nodes + 1; 51.320 + tmp2->father = tmp - tree->nodes + 1; 51.321 + 51.322 + if (tmp2->left != 0) 51.323 + tree->nodes[tmp2->left - 1].father = 51.324 + tmp2 -tree->nodes + 1; 51.325 + if (p->right != 0) 51.326 + tree->nodes[p->right - 1].father = 51.327 + p -tree->nodes + 1; 51.328 + 51.329 + if (tmp->father != 0) 51.330 + { 51.331 + if (tree->nodes[tmp->father - 1].left 51.332 + == p - tree->nodes + 1) 51.333 + tree->nodes[tmp->father 51.334 + - 1].left = 51.335 + tmp - tree->nodes + 1; 51.336 + else 51.337 + tree->nodes[tmp->father 51.338 + - 1].right = 51.339 + tmp - tree->nodes + 1; 51.340 + } 51.341 + 51.342 + adjust_heights(tree, p); 51.343 + } 51.344 + } 51.345 + } 51.346 + 51.347 + /* Fix root node */ 51.348 + p = tree->nodes + tree->root - 1; 51.349 + while (p->father != 0) 51.350 + p = tree->nodes + p->father - 1; 51.351 + 51.352 + tree->root = p - tree->nodes + 1; 51.353 +} 51.354 + 51.355 +void 51.356 +nacore_avl_tree_for_each(nacore_avl_tree_t tree, 51.357 + void (*callback)(void *content, void *data), 51.358 + void *data) 51.359 +{ 51.360 + size_t i; 51.361 + 51.362 + for (i = 0; i < tree->count; i++) 51.363 + callback(tree->nodes[i].content, data); 51.364 +} 51.365 + 51.366 +void * 51.367 +nacore_avl_tree_find(nacore_avl_tree_t tree, void *key) 51.368 +{ 51.369 + struct avl_tree_node *p; 51.370 + int cmp; 51.371 + size_t next; 51.372 + 51.373 + if (tree->root == 0) 51.374 + return NULL; 51.375 + 51.376 + next = tree->root; 51.377 + do 51.378 + { 51.379 + p = tree->nodes + next - 1; 51.380 + cmp = tree->key_cmp(p->content, key); 51.381 + if (cmp == 0) 51.382 + return p->content; 51.383 + if (cmp < 0) 51.384 + next = p->right; 51.385 + else 51.386 + next = p->left; 51.387 + } 51.388 + while (next != 0); 51.389 + 51.390 + return NULL; 51.391 +} 51.392 + 51.393 +size_t 51.394 +nacore_avl_tree_get_nodes_count(nacore_avl_tree_t tree) 51.395 +{ 51.396 + return tree->count; 51.397 +} 51.398 + 51.399 +void 51.400 +nacore_avl_tree_free(nacore_avl_tree_t tree) 51.401 +{ 51.402 + free(tree->nodes); 51.403 + free(tree); 51.404 +} 51.405 + 51.406 +int 51.407 +nacore_content_cmp_descriptor_by_uri(void *c1, void *c2) 51.408 +{ 51.409 + return strcmp(((struct nacore_descriptor *)c1)->uri, 51.410 + ((struct nacore_descriptor *)c2)->uri); 51.411 +} 51.412 + 51.413 +int 51.414 +nacore_key_cmp_descriptor_by_uri(void *content, void *key) 51.415 +{ 51.416 + return strcmp(((struct nacore_descriptor *)content)->uri, (char *)key); 51.417 +}
52.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 52.2 +++ b/naspro-core/src/dl.h Fri Sep 11 13:31:52 2009 +0200 52.3 @@ -0,0 +1,16 @@ 52.4 +/* 52.5 + * NASPRO - NASPRO Architecture for Sound Processing 52.6 + * Core library 52.7 + * 52.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 52.9 + * 52.10 + * See the COPYING file for license conditions. 52.11 + */ 52.12 + 52.13 +#ifndef _NACORE_LIB_DL_H 52.14 +#define _NACORE_LIB_DL_H 52.15 + 52.16 +void _nacore_dl_init(); 52.17 +void _nacore_dl_fini(); 52.18 + 52.19 +#endif /* !_NACORE_LIB_DL_H */
53.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 53.2 +++ b/naspro-core/src/init.c Fri Sep 11 13:31:52 2009 +0200 53.3 @@ -0,0 +1,25 @@ 53.4 +/* 53.5 + * NASPRO - NASPRO Architecture for Sound Processing 53.6 + * Core library 53.7 + * 53.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 53.9 + * 53.10 + * See the COPYING file for license conditions. 53.11 + */ 53.12 + 53.13 +#include "src/path.h" 53.14 +#include "src/dl.h" 53.15 + 53.16 +static void __attribute__((constructor)) 53.17 +init() 53.18 +{ 53.19 + _nacore_path_init(); 53.20 + _nacore_dl_init(); 53.21 +} 53.22 + 53.23 +static void __attribute__((destructor)) 53.24 +fini() 53.25 +{ 53.26 + _nacore_dl_fini(); 53.27 + _nacore_path_fini(); 53.28 +}
54.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 54.2 +++ b/naspro-core/src/lv2api.c Fri Sep 11 13:31:52 2009 +0200 54.3 @@ -0,0 +1,25 @@ 54.4 +/* 54.5 + * NASPRO - NASPRO Architecture for Sound Processing 54.6 + * Core library 54.7 + * 54.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 54.9 + * 54.10 + * See the COPYING file for license conditions. 54.11 + */ 54.12 + 54.13 +#include <NASPRO/core/lib.h> 54.14 + 54.15 +void 54.16 +nacore_lv2api_fill_desc(LV2_Descriptor *lv2_desc, 54.17 + struct nacore_descriptor *n_desc) 54.18 +{ 54.19 + lv2_desc->URI = n_desc->uri; 54.20 + 54.21 + lv2_desc->instantiate = n_desc->instantiate; 54.22 + lv2_desc->connect_port = n_desc->connect_port; 54.23 + lv2_desc->activate = n_desc->activate; 54.24 + lv2_desc->run = n_desc->run; 54.25 + lv2_desc->deactivate = n_desc->deactivate; 54.26 + lv2_desc->cleanup = n_desc->cleanup; 54.27 + lv2_desc->extension_data = n_desc->extension_data; 54.28 +}
55.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 55.2 +++ b/naspro-core/src/manifest.c Fri Sep 11 13:31:52 2009 +0200 55.3 @@ -0,0 +1,311 @@ 55.4 +/* 55.5 + * NASPRO - NASPRO Architecture for Sound Processing 55.6 + * Core library 55.7 + * 55.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 55.9 + * 55.10 + * See the COPYING file for license conditions. 55.11 + */ 55.12 + 55.13 +#include <stdlib.h> 55.14 +#include <stdio.h> 55.15 +#include <string.h> 55.16 + 55.17 +#include <locale.h> 55.18 + 55.19 +#include <NASPRO/core/lib.h> 55.20 + 55.21 +/* TODO: setlocale + multi-threading = ouch! */ 55.22 + 55.23 +void 55.24 +nacore_manifest_print_subject_prefixes(FILE *fp) 55.25 +{ 55.26 + fprintf(fp, "@prefix lv2: <http://lv2plug.in/ns/lv2core#> .\n"); 55.27 +} 55.28 + 55.29 +void 55.30 +nacore_manifest_print_subject_triple(struct nacore_descriptor *desc, FILE *fp) 55.31 +{ 55.32 + fprintf(fp, "<%s> a lv2:Plugin .\n", desc->uri); 55.33 +} 55.34 + 55.35 +static void 55.36 +print_escaped_string(FILE *fp, const char *string) 55.37 +{ 55.38 + size_t i, len; 55.39 + 55.40 + len = strlen(string); 55.41 + for (i = 0; i < len; i++) 55.42 + { 55.43 + switch (string[i]) 55.44 + { 55.45 + case '\t': 55.46 + fputs("\\t", fp); 55.47 + break; 55.48 + case '\r': 55.49 + fputs("\\r", fp); 55.50 + break; 55.51 + case '\n': 55.52 + fputs("\\n", fp); 55.53 + break; 55.54 + case '"': 55.55 + fputs("\\\"", fp); 55.56 + break; 55.57 + case '\\': 55.58 + fputs("\\\\", fp); 55.59 + break; 55.60 + /* TODO: unicode escapes, see 55.61 + * http://www.dajobe.org/2004/01/turtle/#sec-strings */ 55.62 + default: 55.63 + fputc(string[i], fp); 55.64 + break; 55.65 + } 55.66 + } 55.67 +} 55.68 + 55.69 +#define PRINT_C1(na_class, string) \ 55.70 + if (desc->classes_1 & na_class) \ 55.71 + fprintf(fp, "\ta " string " ;\n"); 55.72 + 55.73 +#define PRINT_C2(na_class, string) \ 55.74 + if (desc->classes_2 & na_class) \ 55.75 + fprintf(fp, "\ta " string " ;\n"); 55.76 + 55.77 +static void 55.78 +print_classes(FILE *fp, struct nacore_descriptor *desc) 55.79 +{ 55.80 + PRINT_C1(NACORE_DESCRIPTOR_CLASS_GENERATOR, "lv2:GeneratorPlugin"); 55.81 + PRINT_C1(NACORE_DESCRIPTOR_CLASS_INSTRUMENT, "lv2:InstrumentPlugin"); 55.82 + PRINT_C1(NACORE_DESCRIPTOR_CLASS_OSCILLATOR, "lv2:OscillatorPlugin"); 55.83 + PRINT_C1(NACORE_DESCRIPTOR_CLASS_UTILITY, "lv2:UtilityPlugin"); 55.84 + PRINT_C1(NACORE_DESCRIPTOR_CLASS_CONVERTER, "lv2:ConverterPlugin"); 55.85 + PRINT_C1(NACORE_DESCRIPTOR_CLASS_ANALYSER, "lv2:AnalyserPlugin"); 55.86 + PRINT_C1(NACORE_DESCRIPTOR_CLASS_MIXER, "lv2:MixerPlugin"); 55.87 + PRINT_C1(NACORE_DESCRIPTOR_CLASS_SIMULATOR, "lv2:SimulatorPlugin"); 55.88 + PRINT_C1(NACORE_DESCRIPTOR_CLASS_DELAY, "lv2:DelayPlugin"); 55.89 + PRINT_C1(NACORE_DESCRIPTOR_CLASS_MODULATOR, "lv2:ModulatorPlugin"); 55.90 + PRINT_C1(NACORE_DESCRIPTOR_CLASS_REVERB, "lv2:ReverbPlugin"); 55.91 + PRINT_C1(NACORE_DESCRIPTOR_CLASS_PHASER, "lv2:PhaserPlugin"); 55.92 + PRINT_C1(NACORE_DESCRIPTOR_CLASS_FLANGER, "lv2:FlangerPlugin"); 55.93 + PRINT_C1(NACORE_DESCRIPTOR_CLASS_CHORUS, "lv2:ChorusPlugin"); 55.94 + PRINT_C1(NACORE_DESCRIPTOR_CLASS_FILTER, "lv2:FilterPlugin"); 55.95 + PRINT_C1(NACORE_DESCRIPTOR_CLASS_LOWPASS, "lv2:LowpassPlugin"); 55.96 + PRINT_C1(NACORE_DESCRIPTOR_CLASS_BANDPASS, "lv2:BandpassPlugin"); 55.97 + PRINT_C1(NACORE_DESCRIPTOR_CLASS_HIGHPASS, "lv2:HighpassPlugin"); 55.98 + PRINT_C1(NACORE_DESCRIPTOR_CLASS_COMB, "lv2:CombPlugin"); 55.99 + PRINT_C1(NACORE_DESCRIPTOR_CLASS_ALLPASS, "lv2:AllpassPlugin"); 55.100 + PRINT_C1(NACORE_DESCRIPTOR_CLASS_EQ, "lv2:EQPlugin"); 55.101 + PRINT_C1(NACORE_DESCRIPTOR_CLASS_PARAEQ, "lv2:ParaEQPlugin"); 55.102 + PRINT_C1(NACORE_DESCRIPTOR_CLASS_MULTIEQ, "lv2:MultiEQPlugin"); 55.103 + PRINT_C1(NACORE_DESCRIPTOR_CLASS_SPECTRAL, "lv2:SpectralPlugin"); 55.104 + PRINT_C1(NACORE_DESCRIPTOR_CLASS_PITCH, "lv2:PitchPlugin"); 55.105 + PRINT_C1(NACORE_DESCRIPTOR_CLASS_AMPLIFIER, "lv2:AmplifierPlugin"); 55.106 + PRINT_C1(NACORE_DESCRIPTOR_CLASS_DISTORTION, "lv2:DistortionPlugin"); 55.107 + PRINT_C1(NACORE_DESCRIPTOR_CLASS_WAVESHAPER, "lv2:WaveshaperPlugin"); 55.108 + PRINT_C2(NACORE_DESCRIPTOR_CLASS_DYNAMICS, "lv2:DynamicsPlugin"); 55.109 + PRINT_C2(NACORE_DESCRIPTOR_CLASS_COMPRESSOR, "lv2:CompressorPlugin"); 55.110 + PRINT_C2(NACORE_DESCRIPTOR_CLASS_EXPANDER, "lv2:ExpanderPlugin"); 55.111 + PRINT_C2(NACORE_DESCRIPTOR_CLASS_LIMITER, "lv2:LimiterPlugin"); 55.112 + PRINT_C2(NACORE_DESCRIPTOR_CLASS_GATE, "lv2:GatePlugin"); 55.113 +} 55.114 + 55.115 +#define PRINT_UNIT(na_unit, lv2_unit) \ 55.116 + case na_unit: \ 55.117 + fprintf(fp, "\t\tlv2units:unit " lv2_unit " ;\n"); \ 55.118 + break; 55.119 + 55.120 +static void 55.121 +print_scale_units(FILE *fp, struct nacore_descriptor *desc, size_t index) 55.122 +{ 55.123 + switch (desc->port_descs[index].scale.unit) 55.124 + { 55.125 + PRINT_UNIT(nacore_scale_unit_bar, "lv2units:bar"); 55.126 + PRINT_UNIT(nacore_scale_unit_beat, "lv2units:beat"); 55.127 + PRINT_UNIT(nacore_scale_unit_bpm, "lv2units:bpm"); 55.128 + PRINT_UNIT(nacore_scale_unit_cent, "lv2units:cent"); 55.129 + PRINT_UNIT(nacore_scale_unit_cm, "lv2units:cm"); 55.130 + PRINT_UNIT(nacore_scale_unit_coeff, "lv2units:coef"); 55.131 + PRINT_UNIT(nacore_scale_unit_db, "lv2units:db"); 55.132 + PRINT_UNIT(nacore_scale_unit_deg, "lv2units:degree"); 55.133 + PRINT_UNIT(nacore_scale_unit_hz, "lv2units:hz"); 55.134 + PRINT_UNIT(nacore_scale_unit_inch, "lv2units:inch"); 55.135 + PRINT_UNIT(nacore_scale_unit_khz, "lv2units:khz"); 55.136 + PRINT_UNIT(nacore_scale_unit_km, "lv2units:km"); 55.137 + PRINT_UNIT(nacore_scale_unit_m, "lv2units:m"); 55.138 + PRINT_UNIT(nacore_scale_unit_mhz, "lv2units:mhz"); 55.139 + PRINT_UNIT(nacore_scale_unit_midi_note, "lv2units:midiNote"); 55.140 + PRINT_UNIT(nacore_scale_unit_mi, "lv2units:mile"); 55.141 + PRINT_UNIT(nacore_scale_unit_min, "lv2units:min"); 55.142 + PRINT_UNIT(nacore_scale_unit_mm, "lv2units:mm"); 55.143 + PRINT_UNIT(nacore_scale_unit_ms, "lv2units:ms"); 55.144 + PRINT_UNIT(nacore_scale_unit_oct, "lv2units:oct"); 55.145 + PRINT_UNIT(nacore_scale_unit_pc, "lv2units:pc"); 55.146 + PRINT_UNIT(nacore_scale_unit_s, "lv2units:s"); 55.147 + PRINT_UNIT(nacore_scale_unit_semitone, 55.148 + "lv2units:semitone12TET"); 55.149 + default: 55.150 + break; 55.151 + } 55.152 +} 55.153 + 55.154 +static void 55.155 +print_scale_points(FILE *fp, struct nacore_descriptor *desc, size_t index) 55.156 +{ 55.157 + size_t i; 55.158 + 55.159 + if (desc->port_descs[index].scale.points_count == 0) 55.160 + return; 55.161 + 55.162 + for (i = 0; i < desc->port_descs[index].scale.points_count; i++) 55.163 + { 55.164 + fprintf(fp, "\t\tlv2:scalePoint [ rdfs:label \""); 55.165 + print_escaped_string(fp, 55.166 + desc->port_descs[index].scale.points[i].label); 55.167 + fprintf(fp, "\"; rdf:value %f ] ;\n", 55.168 + desc->port_descs[index].scale.points[i].value); 55.169 + } 55.170 +} 55.171 + 55.172 +void 55.173 +nacore_manifest_print_data(struct nacore_descriptor *desc, FILE *fp, 55.174 + const char *binary) 55.175 +{ 55.176 + struct nacore_port_descriptor *port_desc; 55.177 + char *prev_locale; 55.178 + size_t i; 55.179 + 55.180 + prev_locale = setlocale(LC_NUMERIC, NULL); 55.181 + setlocale(LC_NUMERIC, "C"); 55.182 + 55.183 + fprintf(fp, "@prefix rdf: <http://www.w3.org/1999/02/" 55.184 + "22-rdf-syntax-ns#> .\n"); 55.185 + fprintf(fp, "@prefix rdfs: <http://www.w3.org/2000/01/" 55.186 + "rdf-schema#> .\n"); 55.187 + fprintf(fp, "@prefix lv2: <http://lv2plug.in/ns/lv2core#> .\n"); 55.188 + fprintf(fp, "@prefix doap: <http://usefulinc.com/ns/doap#> .\n"); 55.189 + fprintf(fp, "@prefix dc: <http://purl.org/dc/elements/1.1/> .\n"); 55.190 + fprintf(fp, "@prefix epp: <http://lv2plug.in/ns/dev/extportinfo#> .\n"); 55.191 + fprintf(fp, "@prefix lv2units: <http://lv2plug.in/ns/extensions/" 55.192 + "units#> .\n"); 55.193 + fprintf(fp, "@prefix lv2ev: <http://lv2plug.in/ns/ext/event#> .\n"); 55.194 + fprintf(fp, "@prefix lv2midi: <http://lv2plug.in/ns/ext/midi#> .\n"); 55.195 + 55.196 + fprintf(fp, "<%s>\n", desc->uri); 55.197 + fprintf(fp, "\ta lv2:Plugin ;\n"); 55.198 + fprintf(fp, "\tlv2:binary <"); 55.199 + print_escaped_string(fp, binary); 55.200 + fprintf(fp, SO_FILE_EXT "> ;\n"); 55.201 + fprintf(fp, "\tdoap:name \""); 55.202 + print_escaped_string(fp, desc->name); 55.203 + fprintf(fp, "\" ;\n"); 55.204 + fprintf(fp, "\tdoap:license \"%s\" ;\n", 55.205 + "http://usefulinc.com/doap/licenses/unknown"); 55.206 + if (desc->creator != NULL) 55.207 + { 55.208 + fprintf(fp, "\tdc:creator \""); 55.209 + print_escaped_string(fp, desc->creator); 55.210 + fprintf(fp, "\" ;\n"); 55.211 + } 55.212 + if (desc->rights != NULL) 55.213 + { 55.214 + fprintf(fp, "\tdc:rights \""); 55.215 + print_escaped_string(fp, desc->rights); 55.216 + fprintf(fp, "\" ;\n"); 55.217 + } 55.218 + 55.219 + if (desc->properties & NACORE_DESCRIPTOR_HAS_LIVE_DEP) 55.220 + fprintf(fp, "\tlv2:requiredFeature lv2:isLive ;\n"); 55.221 + if (desc->properties & NACORE_DESCRIPTOR_INPLACE_BROKEN) 55.222 + fprintf(fp, "\tlv2:requiredFeature lv2:inPlaceBroken ;\n"); 55.223 + if (desc->properties & NACORE_DESCRIPTOR_HARD_RT_CAPABLE) 55.224 + fprintf(fp, "\tlv2:optionalFeature lv2:hardRtCapable ;\n"); 55.225 + 55.226 + print_classes(fp, desc); 55.227 + 55.228 +#if 0 55.229 + for (i = 0; i < desc->port_descs_count; i++) 55.230 + { 55.231 + if (desc->port_descs[i].properties & NACORE_PORT_IS_MIDI) 55.232 + { 55.233 + fprintf(fp, "\tlv2:requiredFeature " 55.234 + "<http://lv2plug.in/ns/ext/event> ;\n"); 55.235 + fprintf(fp, "\tlv2:requiredFeature " 55.236 + "<http://lv2plug.in/ns/ext/uri-map> ;\n"); 55.237 + break; 55.238 + } 55.239 + } 55.240 +#endif 55.241 + 55.242 + for (i = 0; i < desc->port_descs_count; i++) 55.243 + { 55.244 + port_desc = desc->port_descs + i; 55.245 + 55.246 + if (i) 55.247 + fprintf(fp, " ,\n\t"); 55.248 + else 55.249 + fprintf(fp, "\tlv2:port "); 55.250 + 55.251 + fprintf(fp, "[\n"); 55.252 + fprintf(fp, "\t\ta %s, lv2:%s ;\n", 55.253 + (port_desc->properties & NACORE_PORT_IS_AUDIO) 55.254 + ? "lv2:AudioPort" : 55.255 + ((port_desc->properties & NACORE_PORT_IS_MIDI) 55.256 + ? "lv2ev:EventPort" : "lv2:ControlPort"), 55.257 + (port_desc->properties & NACORE_PORT_IS_OUTPUT) 55.258 + ? "OutputPort" : "InputPort"); 55.259 + 55.260 + fprintf(fp, "\t\tlv2:index %lu ;\n", (unsigned long)i); 55.261 + fprintf(fp, "\t\tlv2:symbol \"port%lu\" ;\n", (unsigned long)i); 55.262 + fprintf(fp, "\t\tlv2:name \""); 55.263 + print_escaped_string(fp, port_desc->name); 55.264 + fprintf(fp, "\" ;\n"); 55.265 + 55.266 + if (port_desc->properties & NACORE_PORT_CONNECTION_OPTIONAL) 55.267 + fprintf(fp, "\t\tlv2:portProperty " 55.268 + "lv2:connectionOptional ;\n"); 55.269 + 55.270 + if (!(port_desc->properties & NACORE_PORT_IS_AUDIO) 55.271 + && !(port_desc->properties & NACORE_PORT_IS_MIDI)) 55.272 + { 55.273 + if (port_desc->properties & NACORE_PORT_REPORTS_LATENCY) 55.274 + fprintf(fp, "\t\tlv2:portProperty " 55.275 + "lv2:reportsLatency ;\n"); 55.276 + if (port_desc->properties & NACORE_PORT_TOGGLED) 55.277 + fprintf(fp, "\t\tlv2:portProperty " 55.278 + "lv2:toggled ;\n"); 55.279 + if (port_desc->properties & NACORE_PORT_SAMPLE_RATE) 55.280 + fprintf(fp, "\t\tlv2:portProperty " 55.281 + "lv2:sampleRate ;\n"); 55.282 + if (port_desc->properties & NACORE_PORT_INTEGER) 55.283 + fprintf(fp, "\t\tlv2:portProperty " 55.284 + "lv2:integer ;\n"); 55.285 + if (port_desc->properties & NACORE_PORT_LOGARITHMIC) 55.286 + fprintf(fp, "\t\tlv2:portProperty " 55.287 + "epp:logarithmic ;\n"); 55.288 + if (port_desc->scale.properties & NACORE_SCALE_HAS_MIN) 55.289 + fprintf(fp, "\t\tlv2:minimum %f ;\n", 55.290 + port_desc->scale.min); 55.291 + if (port_desc->scale.properties & NACORE_SCALE_HAS_MAX) 55.292 + fprintf(fp, "\t\tlv2:maximum %f ;\n", 55.293 + port_desc->scale.max); 55.294 + if (port_desc->scale.properties 55.295 + & NACORE_SCALE_HAS_DEFAULT) 55.296 + fprintf(fp, "\t\tlv2:default %f ;\n", 55.297 + port_desc->scale.defaultv); 55.298 + 55.299 + print_scale_units(fp, desc, i); 55.300 + print_scale_points(fp, desc, i); 55.301 + } 55.302 + else if (port_desc->properties & NACORE_PORT_IS_MIDI) 55.303 + { 55.304 + fprintf(fp, "\t\tlv2ev:supportsEvent " 55.305 + "lv2midi:MidiEvent ;\n"); 55.306 + } 55.307 + 55.308 + fprintf(fp, "\t]"); 55.309 + } 55.310 + 55.311 + fprintf(fp, " .\n"); 55.312 + 55.313 + setlocale(LC_NUMERIC, prev_locale); 55.314 +}
56.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 56.2 +++ b/naspro-core/src/path.h Fri Sep 11 13:31:52 2009 +0200 56.3 @@ -0,0 +1,16 @@ 56.4 +/* 56.5 + * NASPRO - NASPRO Architecture for Sound Processing 56.6 + * Core library 56.7 + * 56.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 56.9 + * 56.10 + * See the COPYING file for license conditions. 56.11 + */ 56.12 + 56.13 +#ifndef _NACORE_LIB_PATH_H 56.14 +#define _NACORE_LIB_PATH_H 56.15 + 56.16 +void _nacore_path_init(); 56.17 +void _nacore_path_fini(); 56.18 + 56.19 +#endif /* !_NACORE_LIB_PATH_H */
57.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 57.2 +++ b/naspro-core/src/posix/dl.c Fri Sep 11 13:31:52 2009 +0200 57.3 @@ -0,0 +1,94 @@ 57.4 +/* 57.5 + * NASPRO - NASPRO Architecture for Sound Processing 57.6 + * Core library 57.7 + * 57.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 57.9 + * 57.10 + * See the COPYING file for license conditions. 57.11 + */ 57.12 + 57.13 +#include <stdlib.h> 57.14 +#include <stdio.h> 57.15 +#include <string.h> 57.16 +#include <errno.h> 57.17 + 57.18 +#include <dlfcn.h> 57.19 + 57.20 +#include <NASPRO/core/lib.h> 57.21 + 57.22 +#include "src/dl.h" 57.23 + 57.24 +struct _nacore_dl_module 57.25 + { 57.26 + void *handle; 57.27 + }; 57.28 + 57.29 +static size_t dl_file_ext_len; 57.30 + 57.31 +void 57.32 +_nacore_dl_init() 57.33 +{ 57.34 + dl_file_ext_len = strlen(SO_FILE_EXT); 57.35 +} 57.36 + 57.37 +void 57.38 +_nacore_dl_fini() 57.39 +{ 57.40 +} 57.41 + 57.42 +nacore_dl_module_t 57.43 +nacore_dl_open(const char *file) 57.44 +{ 57.45 + void *handle; 57.46 + nacore_dl_module_t dl_handle; 57.47 + 57.48 + handle = dlopen(file, RTLD_LAZY); 57.49 + if (handle == NULL) 57.50 + return NULL; 57.51 + 57.52 + dl_handle = malloc(sizeof(struct _nacore_dl_module)); 57.53 + if (dl_handle == NULL) 57.54 + { 57.55 + dlclose(handle); 57.56 + return NULL; 57.57 + } 57.58 + 57.59 + dl_handle->handle = handle; 57.60 + 57.61 + return dl_handle; 57.62 +} 57.63 + 57.64 +void * 57.65 +nacore_dl_sym(nacore_dl_module_t handle, const char *symbol) 57.66 +{ 57.67 + void *sym; 57.68 + char *error; 57.69 + 57.70 + dlerror(); /* Clear any existing error */ 57.71 + *(void **)(&sym) = dlsym(handle->handle, symbol); 57.72 + error = dlerror(); 57.73 + if (error != NULL) 57.74 + return NULL; 57.75 + 57.76 + return sym; 57.77 +} 57.78 + 57.79 +void 57.80 +nacore_dl_close(nacore_dl_module_t handle) 57.81 +{ 57.82 + dlclose(handle->handle); 57.83 + free(handle); 57.84 +} 57.85 + 57.86 +char 57.87 +nacore_dl_filename_filter(const char *file) 57.88 +{ 57.89 + size_t file_len; 57.90 + 57.91 + file_len = strlen(file); 57.92 + 57.93 + if (file_len <= dl_file_ext_len) 57.94 + return 0; 57.95 + 57.96 + return !strcmp(file + file_len - dl_file_ext_len, SO_FILE_EXT); 57.97 +}
58.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 58.2 +++ b/naspro-core/src/posix/env.c Fri Sep 11 13:31:52 2009 +0200 58.3 @@ -0,0 +1,23 @@ 58.4 +/* 58.5 + * NASPRO - NASPRO Architecture for Sound Processing 58.6 + * Core library 58.7 + * 58.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 58.9 + * 58.10 + * See the COPYING file for license conditions. 58.11 + */ 58.12 + 58.13 +#include <stdlib.h> 58.14 + 58.15 +#include <NASPRO/core/lib.h> 58.16 + 58.17 +char * 58.18 +nacore_env_get_var(const char *name) 58.19 +{ 58.20 + return getenv(name); 58.21 +} 58.22 + 58.23 +void 58.24 +nacore_env_free_var_value(char *value) 58.25 +{ 58.26 +}
59.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 59.2 +++ b/naspro-core/src/posix/path.c Fri Sep 11 13:31:52 2009 +0200 59.3 @@ -0,0 +1,270 @@ 59.4 +/* 59.5 + * NASPRO - NASPRO Architecture for Sound Processing 59.6 + * Core library 59.7 + * 59.8 + * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com> 59.9 + * 59.10 + * See the COPYING file for license conditions. 59.11 + */ 59.12 + 59.13 +#include <stdlib.h> 59.14 +#include <stdio.h> 59.15 +#include <string.h> 59.16 + 59.17 +#include <sys/types.h> 59.18 +#include <dirent.h> 59.19 +#include <pwd.h> 59.20 +#include <unistd.h> 59.21 + 59.22 +#include <NASPRO/core/lib.h> 59.23 + 59.24 +#include "src/path.h" 59.25 + 59.26 +static char *home; 59.27 + 59.28 +void 59.29 +_nacore_path_init() 59.30 +{ 59.31 + struct passwd *pwd; 59.32 + 59.33 + home = nacore_env_get_var("HOME"); 59.34 + if (NACORE_STRING_IS_NULL_OR_EMPTY(home)) 59.35 + { 59.36 + pwd = getpwuid(getuid()); 59.37 + if (pwd == NULL) 59.38 + { 59.39 + home = NULL; 59.40 + return; 59.41 + } 59.42 + home = pwd->pw_dir; 59.43 + if (NACORE_STRING_IS_NULL_OR_EMPTY(home)) 59.44 + { 59.45 + home = NULL; 59.46 + return; 59.47 + } 59.48 + } 59.49 +} 59.50 + 59.51 +void 59.52 +_nacore_path_fini() 59.53 +{ 59.54 + if (home != NULL) 59.55 + nacore_env_free_var_value(home); 59.56 +} 59.57 + 59.58 +/* TODO: UTF-8 support. */ 59.59 + 59.60 +static void 59.61 +scan_dir(const char *path, 59.62 + void (*callback)(const char *file,const char *basename, void *data), 59.63 + char (*filter)(const char *file), void *data) 59.64 +{ 59.65 + DIR *dir; 59.66 + struct dirent *entry; 59.67 + char *filename, *p; 59.68 + size_t len; 59.69 + size_t path_len; 59.70 + 59.71 + dir = opendir(path); 59.72 + if (dir == NULL) 59.73 + return; 59.74 + 59.75 + path_len = strlen(path); 59.76 + filename = NULL; 59.77 + len = 0; 59.78 + while ((entry = readdir(dir)) != NULL) 59.79
