Mercurial > mplayer.hg
annotate libaf/af_ladspa.c @ 14696:f0ff9c135053
Fix -sstep description.
author | diego |
---|---|
date | Sun, 13 Feb 2005 23:51:41 +0000 |
parents | 8f6bd2869325 |
children | f92a93cfc508 |
rev | line source |
---|---|
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
1 /* ------------------------------------------------------------------------- */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
2 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
3 /* |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
4 * af_ladspa.c, LADSPA plugin loader |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
5 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
6 * Written by Ivo van Poorten <ivop@euronet.nl> |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
7 * Copyright (C) 2004, 2005 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
8 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
9 * This program is free software; you can redistribute it and/or |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
10 * modify it under the terms of the GNU General Public License |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
11 * as published by the Free Software Foundation; either version 2 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
12 * of the License, or (at your option) any later version. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
13 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
14 * This program is distributed in the hope that it will be useful, |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
17 * GNU General Public License for more details. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
18 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
19 * You should have received a copy of the GNU General Public License |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
20 * along with this program; if not, write to the Free Software |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
22 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
23 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
24 * Changelog |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
25 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
26 * 2004-12-23 Added to CVS |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
27 * 2004-12-22 Cleaned up cosmetics |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
28 * Made conversion loops in play() more cache-friendly |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
29 * 2004-12-20 Fixed bug for stereo effect on mono signal |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
30 * (trivial >1 to >=1 change; would segfault otherwise :-) ) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
31 * Removed trailing whitespace and fixed warn/err messages |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
32 * Have CONTROL_REINIT return a proper value |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
33 * 2004-12-13 More Doxygen comments |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
34 * 2004-12-12 Made af_ladspa optional (updated configure, af.c, etc.) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
35 * 2004-12-11 Added deactivate and cleanup to uninit. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
36 * Finished Doxygen comments. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
37 * Moved translatable messages to help_mp-en.h |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
38 * 2004-12-10 Added ranges to list of controls for ease of use. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
39 * Fixed sig11 bug. Implemented (dummy) outputcontrols. Some |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
40 * perfectly normal audio processing filters also have output |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
41 * controls. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
42 * 2004-12-08 Added support for generators (no input, one output) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
43 * Added support for stereo effects |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
44 * Added LADSPA_PATH support! |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
45 * 2004-12-07 Fixed changing buffersize. Now it's really working, also in |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
46 * real-time. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
47 * 2004-12-06 First working version, mono-effects (1 input --> 1 output) only |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
48 * 2004-12-05 Started, Loading of plugin/label, Check inputs/outputs/controls |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
49 * Due to lack of documentation, I studied the ladspa_sdk source |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
50 * code and the loader code of Audacity (by Dominic Mazzoni). So, |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
51 * certain similarities in (small) pieces of code are not |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
52 * coincidental :-) No C&P jobs though! |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
53 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
54 */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
55 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
56 /* ------------------------------------------------------------------------- */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
57 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
58 /* Global Includes */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
59 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
60 #include <stdio.h> |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
61 #include <stdlib.h> |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
62 #include <string.h> |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
63 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
64 #include <unistd.h> |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
65 #include <inttypes.h> |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
66 #include <math.h> |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
67 #include <limits.h> |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
68 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
69 #include <dlfcn.h> |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
70 #include <ladspa.h> |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
71 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
72 /* ------------------------------------------------------------------------- */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
73 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
74 /* Local Includes */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
75 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
76 #include "af.h" |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
77 #include "../help_mp.h" |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
78 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
79 /* ------------------------------------------------------------------------- */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
80 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
81 /* Filter specific data */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
82 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
83 typedef struct af_ladspa_s |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
84 { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
85 int status; /**< Status of the filter. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
86 * Either AF_OK or AF_ERROR |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
87 * Because MPlayer re-inits audio filters that |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
88 * _clearly_ returned AF_ERROR anyway, I use this |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
89 * in play() to skip the processing and return |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
90 * the data unchanged. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
91 */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
92 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
93 int activated; /**< 0 or 1. Activate LADSPA filters only once, even |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
94 * if the buffers get resized, to avoid a stuttering |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
95 * filter. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
96 */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
97 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
98 char *file; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
99 char *label; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
100 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
101 char *myname; /**< It's easy to have a concatenation of file and label */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
102 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
103 void *libhandle; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
104 const LADSPA_Descriptor *plugin_descriptor; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
105 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
106 int nports; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
107 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
108 int ninputs; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
109 int *inputs; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
110 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
111 int noutputs; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
112 int *outputs; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
113 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
114 int ninputcontrols; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
115 int *inputcontrolsmap; /**< Map input port number [0-] to actual port */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
116 float *inputcontrols; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
117 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
118 int noutputcontrols; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
119 int *outputcontrolsmap; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
120 float *outputcontrols; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
121 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
122 int nch; /**< number of channels */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
123 int bufsize; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
124 float **inbufs; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
125 float **outbufs; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
126 LADSPA_Handle *chhandles; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
127 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
128 } af_ladspa_t; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
129 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
130 /* ------------------------------------------------------------------------- */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
131 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
132 static int open(af_instance_t *af); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
133 static int af_ladspa_malloc_failed(char*); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
134 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
135 /* ------------------------------------------------------------------------- */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
136 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
137 /* Description */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
138 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
139 af_info_t af_info_ladspa = { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
140 "LADSPA plugin loader", |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
141 "ladspa", |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
142 "Ivo van Poorten", |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
143 "", |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
144 AF_FLAGS_REENTRANT, |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
145 open |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
146 }; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
147 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
148 /* ------------------------------------------------------------------------- */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
149 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
150 /* By lack of a better word (in my vocabulary) this is called 'parse'. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
151 * Feel free to suggest an alternative. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
152 */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
153 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
154 /** \brief Check for inputs, outputs and controls of a given filter. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
155 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
156 * This function counts and checks all input, output and control ports |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
157 * of the filter that was loaded. If it turns out to be a valid |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
158 * filter for MPlayer use, it prints out a list of all controls and |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
159 * the corresponding range of its value at message level MSGL_V. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
160 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
161 * \param setup Current setup of the filter. Must have its |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
162 * plugin_descriptor set! |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
163 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
164 * \return Returns AF_OK if it has a valid input/output/controls |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
165 * configuration. Else, it returns AF_ERROR. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
166 */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
167 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
168 static int af_ladspa_parse_plugin(af_ladspa_t *setup) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
169 int p, i; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
170 const LADSPA_Descriptor *pdes = setup->plugin_descriptor; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
171 LADSPA_PortDescriptor d; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
172 LADSPA_PortRangeHint hint; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
173 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
174 if (!setup->libhandle) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
175 return AF_ERROR; /* only call parse after a succesful load */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
176 if (!setup->plugin_descriptor) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
177 return AF_ERROR; /* same as above */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
178 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
179 /* let's do it */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
180 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
181 setup->nports = pdes->PortCount; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
182 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
183 /* allocate memory for all inputs/outputs/controls */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
184 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
185 setup->inputs = calloc(setup->nports, sizeof(int)); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
186 if (!setup->inputs) return af_ladspa_malloc_failed(setup->myname); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
187 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
188 setup->outputs = calloc(setup->nports, sizeof(int)); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
189 if (!setup->outputs) return af_ladspa_malloc_failed(setup->myname); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
190 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
191 setup->inputcontrolsmap = calloc(setup->nports, sizeof(int)); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
192 if (!setup->inputcontrolsmap) return af_ladspa_malloc_failed(setup->myname); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
193 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
194 setup->inputcontrols = calloc(setup->nports, sizeof(float)); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
195 if (!setup->inputcontrols) return af_ladspa_malloc_failed(setup->myname); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
196 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
197 setup->outputcontrolsmap = calloc(setup->nports, sizeof(int)); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
198 if (!setup->outputcontrolsmap) return af_ladspa_malloc_failed(setup->myname); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
199 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
200 setup->outputcontrols = calloc(setup->nports, sizeof(float)); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
201 if (!setup->outputcontrols) return af_ladspa_malloc_failed(setup->myname); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
202 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
203 /* set counts to zero */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
204 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
205 setup->ninputs = 0; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
206 setup->noutputs = 0; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
207 setup->ninputcontrols = 0; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
208 setup->noutputcontrols = 0; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
209 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
210 /* check all ports, see what type it is and set variables according to |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
211 * what we have found |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
212 */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
213 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
214 for (p=0; p<setup->nports; p++) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
215 d = pdes->PortDescriptors[p]; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
216 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
217 if (LADSPA_IS_PORT_AUDIO(d)) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
218 if (LADSPA_IS_PORT_INPUT(d)) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
219 setup->inputs[setup->ninputs] = p; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
220 setup->ninputs++; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
221 } else if (LADSPA_IS_PORT_OUTPUT(d)) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
222 setup->outputs[setup->noutputs] = p; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
223 setup->noutputs++; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
224 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
225 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
226 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
227 if (LADSPA_IS_PORT_CONTROL(d)) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
228 if (LADSPA_IS_PORT_INPUT(d)) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
229 setup->inputcontrolsmap[setup->ninputcontrols] = p; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
230 setup->ninputcontrols++; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
231 /* set control to zero. set values after reading the rest |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
232 * of the suboptions and check LADSPA_?_HINT's later. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
233 */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
234 setup->inputcontrols[p] = 0.0f; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
235 } else if (LADSPA_IS_PORT_OUTPUT(d)); { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
236 /* read and handle these too, otherwise filters that have them |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
237 * will sig11 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
238 */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
239 setup->outputcontrolsmap[setup->noutputcontrols]=p; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
240 setup->noutputcontrols++; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
241 setup->outputcontrols[p] = 0.0f; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
242 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
243 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
244 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
245 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
246 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
247 if (setup->ninputs == 0) { |
14390 | 248 af_msg(AF_MSG_WARN, "%s: %s\n", setup->myname, |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
249 MSGTR_AF_LADSPA_WarnNoInputs); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
250 } else if (setup->ninputs == 1) { |
14390 | 251 af_msg(AF_MSG_VERBOSE, "%s: this is a mono effect\n", setup->myname); |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
252 } else if (setup->ninputs == 2) { |
14390 | 253 af_msg(AF_MSG_VERBOSE, "%s: this is a stereo effect\n", setup->myname); |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
254 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
255 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
256 if (setup->ninputs > 2) { |
14390 | 257 af_msg(AF_MSG_ERROR, "%s: %s\n", setup->myname, |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
258 MSGTR_AF_LADSPA_ErrMultiChannel); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
259 return AF_ERROR; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
260 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
261 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
262 if (setup->noutputs == 0) { |
14390 | 263 af_msg(AF_MSG_ERROR, "%s: %s\n", setup->myname, |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
264 MSGTR_AF_LADSPA_ErrNoOutputs); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
265 return AF_ERROR; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
266 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
267 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
268 if (setup->noutputs != setup->ninputs ) { |
14390 | 269 af_msg(AF_MSG_ERROR, "%s: %s\n", setup->myname, |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
270 MSGTR_AF_LADSPA_ErrInOutDiff); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
271 return AF_ERROR; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
272 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
273 |
14390 | 274 af_msg(AF_MSG_VERBOSE, "%s: this plugin has %d input control(s)\n", |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
275 setup->myname, setup->ninputcontrols); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
276 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
277 /* Print list of controls and its range of values it accepts */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
278 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
279 for (i=0; i<setup->ninputcontrols; i++) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
280 p = setup->inputcontrolsmap[i]; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
281 hint = pdes->PortRangeHints[p]; |
14390 | 282 af_msg(AF_MSG_VERBOSE, " --- %d %s [", i, pdes->PortNames[p]); |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
283 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
284 if (LADSPA_IS_HINT_BOUNDED_BELOW(hint.HintDescriptor)) { |
14390 | 285 af_msg(AF_MSG_VERBOSE, "%0.2f , ", hint.LowerBound); |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
286 } else { |
14390 | 287 af_msg(AF_MSG_VERBOSE, "... , "); |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
288 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
289 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
290 if (LADSPA_IS_HINT_BOUNDED_ABOVE(hint.HintDescriptor)) { |
14390 | 291 af_msg(AF_MSG_VERBOSE, "%0.2f]\n", hint.UpperBound); |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
292 } else { |
14390 | 293 af_msg(AF_MSG_VERBOSE, "...]\n"); |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
294 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
295 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
296 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
297 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
298 return AF_OK; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
299 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
300 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
301 /* ------------------------------------------------------------------------- */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
302 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
303 /* This function might "slightly" look like dlopenLADSPA in the LADSPA SDK :-) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
304 * But, I changed a few things, because imho it was broken. It did not support |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
305 * relative paths, only absolute paths that start with a / |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
306 * I think ../../some/dir/foobar.so is just as valid. And if one wants to call |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
307 * his library '...somename...so' he's crazy, but it should be allowed. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
308 * So, search the path first, try plain *filename later. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
309 * Also, try adding .so first! I like the recursion the SDK did, but it's |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
310 * better the other way around. -af ladspa=cmt:amp_stereo:0.5 is easier to type |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
311 * than -af ladspa=cmt.so:amp_stereo:0.5 :-)) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
312 */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
313 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
314 /** \brief dlopen() wrapper |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
315 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
316 * This is a wrapper around dlopen(). It tries various variations of the |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
317 * filename (with or without the addition of the .so extension) in various |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
318 * directories specified by the LADSPA_PATH environment variable. If all fails |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
319 * it tries the filename directly as an absolute path to the library. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
320 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
321 * \param filename filename of the library to load. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
322 * \param flag see dlopen(3) for a description of the flags. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
323 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
324 * \return returns a pointer to the loaded library on success, or |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
325 * NULL if it fails to load. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
326 */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
327 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
328 static void* mydlopen(const char *filename, int flag) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
329 char *buf; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
330 const char *end, *start, *ladspapath; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
331 int endsinso, needslash; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
332 size_t filenamelen; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
333 void *result = NULL; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
334 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
335 # ifdef WIN32 /* for windows there's only absolute path support. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
336 * if you have a windows machine, feel free to fix |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
337 * this. (path separator, shared objects extension, |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
338 * et cetera). |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
339 */ |
14390 | 340 af_msg(AF_MSG_VERBOSE, "\ton windows, only absolute pathnames " |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
341 "are supported\n"); |
14390 | 342 af_msg(AF_MSG_VERBOSE, "\ttrying %s\n", filename); |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
343 return dlopen(filename, flag); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
344 # endif |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
345 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
346 filenamelen = strlen(filename); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
347 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
348 endsinso = 0; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
349 if (filenamelen > 3) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
350 endsinso = (strcmp(filename+filenamelen-3, ".so") == 0); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
351 if (!endsinso) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
352 buf=malloc(filenamelen+4); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
353 strcpy(buf, filename); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
354 strcat(buf, ".so"); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
355 result=mydlopen(buf, flag); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
356 free(buf); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
357 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
358 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
359 if (result) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
360 return result; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
361 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
362 ladspapath=getenv("LADSPA_PATH"); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
363 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
364 if (ladspapath) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
365 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
366 start=ladspapath; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
367 while (*start != '\0') { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
368 end=start; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
369 while ( (*end != ':') && (*end != '\0') ) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
370 end++; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
371 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
372 buf=malloc(filenamelen + 2 + (end-start) ); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
373 if (end > start) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
374 strncpy(buf, start, end-start); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
375 needslash=0; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
376 if (end > start) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
377 if (*(end-1) != '/') { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
378 needslash = 1; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
379 buf[end-start] = '/'; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
380 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
381 strcpy(buf+needslash+(end-start), filename); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
382 |
14390 | 383 af_msg(AF_MSG_VERBOSE, "\ttrying %s\n", buf); |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
384 result=dlopen(buf, flag); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
385 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
386 free(buf); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
387 if (result) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
388 return result; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
389 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
390 start = end; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
391 if (*start == ':') |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
392 start++; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
393 } /* end while there's still more in the path */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
394 } /* end if there's a ladspapath */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
395 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
396 /* last resort, just open it again, so the dlerror() message is correct */ |
14390 | 397 af_msg(AF_MSG_VERBOSE, "\ttrying %s\n", filename); |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
398 return dlopen(filename,flag); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
399 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
400 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
401 /* ------------------------------------------------------------------------- */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
402 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
403 /** \brief Load a LADSPA Plugin |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
404 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
405 * This function loads the LADSPA plugin specified by the file and label |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
406 * that are present in the setup variable. First, it loads the library. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
407 * If it fails, it returns AF_ERROR. If not, it continues to look for the |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
408 * specified label. If it finds it, it sets the plugin_descriptor inside |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
409 * setup and returns AF_OK. If it doesn't, it returns AF_ERROR. Special case |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
410 * is a label called 'help'. In that case, it prints a list of all available |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
411 * labels (filters) in the library specified by file. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
412 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
413 * \param setup Current setup of the filter. Contains filename and label. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
414 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
415 * \return Either AF_ERROR or AF_OK, depending on the success of the operation. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
416 */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
417 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
418 static int af_ladspa_load_plugin(af_ladspa_t *setup) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
419 const LADSPA_Descriptor *ladspa_descriptor; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
420 LADSPA_Descriptor_Function descriptor_function; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
421 int i; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
422 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
423 /* load library */ |
14390 | 424 af_msg(AF_MSG_VERBOSE, "%s: loading ladspa plugin library %s\n", |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
425 setup->myname, setup->file); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
426 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
427 setup->libhandle = mydlopen(setup->file, RTLD_NOW); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
428 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
429 if (!setup->libhandle) { |
14390 | 430 af_msg(AF_MSG_ERROR, "%s: %s %s\n\t%s\n", setup->myname, |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
431 MSGTR_AF_LADSPA_ErrFailedToLoad, setup->file, dlerror() ); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
432 return AF_ERROR; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
433 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
434 |
14390 | 435 af_msg(AF_MSG_VERBOSE, "%s: library found.\n", setup->myname); |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
436 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
437 /* find descriptor function */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
438 dlerror(); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
439 descriptor_function = (LADSPA_Descriptor_Function) dlsym (setup->libhandle, |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
440 "ladspa_descriptor"); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
441 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
442 if (!descriptor_function) { |
14390 | 443 af_msg(AF_MSG_ERROR, "%s: %s\n\t%s\n", setup->myname, |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
444 MSGTR_AF_LADSPA_ErrNoDescriptor, dlerror()); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
445 return AF_ERROR; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
446 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
447 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
448 /* if label == help, list all labels in library and exit */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
449 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
450 if (strcmp(setup->label, "help") == 0) { |
14390 | 451 af_msg(AF_MSG_INFO, "%s: %s %s:\n", setup->myname, |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
452 MSGTR_AF_LADSPA_AvailableLabels, setup->file); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
453 for (i=0; ; i++) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
454 ladspa_descriptor = descriptor_function(i); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
455 if (ladspa_descriptor == NULL) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
456 return AF_ERROR; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
457 } |
14390 | 458 af_msg(AF_MSG_INFO, " %-16s - %s (%lu)\n", |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
459 ladspa_descriptor->Label, |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
460 ladspa_descriptor->Name, |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
461 ladspa_descriptor->UniqueID); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
462 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
463 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
464 |
14390 | 465 af_msg(AF_MSG_VERBOSE, "%s: looking for label\n", setup->myname); |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
466 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
467 /* find label in library */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
468 for (i=0; ; i++) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
469 ladspa_descriptor = descriptor_function(i); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
470 if (ladspa_descriptor == NULL) { |
14390 | 471 af_msg(AF_MSG_ERROR, "%s: %s\n", setup->myname, |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
472 MSGTR_AF_LADSPA_ErrLabelNotFound); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
473 return AF_ERROR; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
474 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
475 if (strcmp(ladspa_descriptor->Label, setup->label) == 0) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
476 setup->plugin_descriptor = ladspa_descriptor; |
14390 | 477 af_msg(AF_MSG_VERBOSE, "%s: %s found\n", setup->myname, |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
478 setup->label); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
479 return AF_OK; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
480 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
481 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
482 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
483 return AF_OK; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
484 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
485 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
486 /* ------------------------------------------------------------------------- */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
487 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
488 /** \brief Print a malloc() failed error message. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
489 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
490 * Generic function which can be called if a call to malloc(), calloc(), |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
491 * strdup(), et cetera, failed. It prints a message to the console and |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
492 * returns AF_ERROR. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
493 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
494 * \return AF_ERROR |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
495 */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
496 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
497 static int af_ladspa_malloc_failed(char *myname) { |
14390 | 498 af_msg(AF_MSG_ERROR, "%s: %s\n", myname, MSGTR_MemAllocFailed); |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
499 return AF_ERROR; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
500 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
501 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
502 /* ------------------------------------------------------------------------- */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
503 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
504 /** \brief Controls the filter. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
505 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
506 * Control the behaviour of the filter. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
507 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
508 * Commands: |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
509 * CONTROL_REINIT Sets the af structure with proper values for number |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
510 * of channels, rate, format, et cetera. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
511 * CONTROL_COMMAND_LINE Parses the suboptions given to this filter |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
512 * through arg. It first parses the filename and |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
513 * the label. After that, it loads the filter |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
514 * and finds out its proprties. Then in continues |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
515 * parsing the controls given on the commandline, |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
516 * if any are needed. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
517 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
518 * \param af Audio filter instance |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
519 * \param cmd The command to execute |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
520 * \param arg Arguments to the command |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
521 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
522 * \return Either AF_ERROR or AF_OK, depending on the succes of the |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
523 * operation. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
524 */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
525 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
526 static int control(struct af_instance_s *af, int cmd, void *arg) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
527 af_ladspa_t *setup = (af_ladspa_t*) af->setup; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
528 int i, r; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
529 float val; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
530 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
531 switch(cmd) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
532 case AF_CONTROL_REINIT: |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
533 mp_msg(MSGT_AFILTER, MSGL_V, "%s: (re)init\n", setup->myname); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
534 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
535 if (!arg) return AF_ERROR; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
536 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
537 /* for now, only accept 16 bit signed int */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
538 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
539 af->data->rate = ((af_data_t*)arg)->rate; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
540 af->data->nch = ((af_data_t*)arg)->nch; |
14258
3f7f4c9c7901
Make af_ladspa use new AF_FORMAT define that was introduced by Alex's
ivo
parents:
14217
diff
changeset
|
541 af->data->format = AF_FORMAT_S16_NE; |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
542 af->data->bps = 2; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
543 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
544 /* arg->len is not set here yet, so init of buffers and connecting the |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
545 * filter, has to be done in play() :-/ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
546 */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
547 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
548 return af_test_output(af, (af_data_t*)arg); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
549 case AF_CONTROL_COMMAND_LINE: { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
550 char *buf; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
551 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
552 mp_msg(MSGT_AFILTER, MSGL_V, "%s: parse suboptions\n", setup->myname); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
553 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
554 /* suboption parser here! |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
555 * format is (ladspa=)file:label:controls.... |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
556 */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
557 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
558 if (!arg) { |
14390 | 559 af_msg(AF_MSG_ERROR, "%s: %s\n", setup->myname, |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
560 MSGTR_AF_LADSPA_ErrNoSuboptions); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
561 return AF_ERROR; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
562 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
563 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
564 buf = malloc(strlen(arg)+1); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
565 if (!buf) return af_ladspa_malloc_failed(setup->myname); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
566 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
567 /* file... */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
568 buf[0] = '\0'; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
569 sscanf(arg, "%[^:]", buf); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
570 if (buf[0] == '\0') { |
14390 | 571 af_msg(AF_MSG_ERROR, "%s: %s\n", setup->myname, |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
572 MSGTR_AF_LADSPA_ErrNoLibFile); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
573 free(buf); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
574 return AF_ERROR; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
575 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
576 arg += strlen(buf); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
577 setup->file = strdup(buf); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
578 if (!setup->file) return af_ladspa_malloc_failed(setup->myname); |
14390 | 579 af_msg(AF_MSG_VERBOSE, "%s: file --> %s\n", setup->myname, |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
580 setup->file); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
581 if (*(char*)arg != '\0') arg++; /* read ':' */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
582 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
583 /* label... */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
584 buf[0] = '\0'; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
585 sscanf(arg, "%[^:]", buf); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
586 if (buf[0] == '\0') { |
14390 | 587 af_msg(AF_MSG_ERROR, "%s: %s\n", setup->myname, |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
588 MSGTR_AF_LADSPA_ErrNoLabel); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
589 free(buf); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
590 return AF_ERROR; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
591 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
592 arg += strlen(buf); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
593 setup->label = strdup(buf); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
594 if (!setup->label) return af_ladspa_malloc_failed(setup->myname); |
14390 | 595 af_msg(AF_MSG_VERBOSE, "%s: label --> %s\n", setup->myname, |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
596 setup->label); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
597 /* if (*(char*)arg != '0') arg++; */ /* read ':' */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
598 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
599 free(buf); /* no longer needed */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
600 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
601 /* set new setup->myname */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
602 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
603 if(setup->myname) free(setup->myname); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
604 setup->myname = calloc(strlen(af_info_ladspa.name)+strlen(setup->file)+ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
605 strlen(setup->label)+6, 1); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
606 snprintf(setup->myname, strlen(af_info_ladspa.name)+ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
607 strlen(setup->file)+strlen(setup->label)+6, "%s: (%s:%s)", |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
608 af_info_ladspa.name, setup->file, setup->label); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
609 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
610 /* load plugin :) */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
611 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
612 if ( af_ladspa_load_plugin(setup) != AF_OK ) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
613 return AF_ERROR; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
614 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
615 /* see what inputs, outputs and controls this plugin has */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
616 if ( af_ladspa_parse_plugin(setup) != AF_OK ) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
617 return AF_ERROR; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
618 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
619 /* ninputcontrols is set by now, read control values from arg */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
620 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
621 for(i=0; i<setup->ninputcontrols; i++) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
622 if (!arg || (*(char*)arg != ':') ) { |
14390 | 623 af_msg(AF_MSG_ERROR, "%s: %s\n", setup->myname, |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
624 MSGTR_AF_LADSPA_ErrNotEnoughControls); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
625 return AF_ERROR; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
626 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
627 arg++; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
628 r = sscanf(arg, "%f", &val); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
629 if (r!=1) { |
14390 | 630 af_msg(AF_MSG_ERROR, "%s: %s\n", setup->myname, |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
631 MSGTR_AF_LADSPA_ErrNotEnoughControls); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
632 return AF_ERROR; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
633 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
634 setup->inputcontrols[setup->inputcontrolsmap[i]] = val; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
635 arg = strchr(arg, ':'); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
636 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
637 |
14390 | 638 af_msg(AF_MSG_VERBOSE, "%s: input controls: ", setup->myname); |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
639 for(i=0; i<setup->ninputcontrols; i++) { |
14390 | 640 af_msg(AF_MSG_VERBOSE, "%0.4f ", |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
641 setup->inputcontrols[setup->inputcontrolsmap[i]]); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
642 } |
14390 | 643 af_msg(AF_MSG_VERBOSE, "\n"); |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
644 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
645 /* check boundaries of inputcontrols */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
646 |
14390 | 647 af_msg(AF_MSG_VERBOSE, "%s: checking boundaries of input controls\n", |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
648 setup->myname); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
649 for(i=0; i<setup->ninputcontrols; i++) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
650 int p = setup->inputcontrolsmap[i]; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
651 LADSPA_PortRangeHint hint = |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
652 setup->plugin_descriptor->PortRangeHints[p]; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
653 val = setup->inputcontrols[p]; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
654 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
655 if (LADSPA_IS_HINT_BOUNDED_BELOW(hint.HintDescriptor) && |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
656 val < hint.LowerBound) { |
14390 | 657 af_msg(AF_MSG_ERROR, MSGTR_AF_LADSPA_ErrControlBelow, |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
658 setup->myname, i, hint.LowerBound); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
659 return AF_ERROR; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
660 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
661 if (LADSPA_IS_HINT_BOUNDED_ABOVE(hint.HintDescriptor) && |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
662 val > hint.UpperBound) { |
14390 | 663 af_msg(AF_MSG_ERROR, MSGTR_AF_LADSPA_ErrControlAbove, |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
664 setup->myname, i, hint.UpperBound); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
665 return AF_ERROR; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
666 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
667 } |
14390 | 668 af_msg(AF_MSG_VERBOSE, "%s: all controls have sane values\n", |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
669 setup->myname); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
670 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
671 /* All is well! */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
672 setup->status = AF_OK; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
673 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
674 return AF_OK; } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
675 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
676 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
677 return AF_UNKNOWN; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
678 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
679 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
680 /* ------------------------------------------------------------------------- */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
681 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
682 /** \brief Uninitialise the LADSPA Plugin Loader filter. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
683 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
684 * This function deactivates the plugin(s), cleans up, frees all allocated |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
685 * memory and exits. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
686 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
687 * \return No return value. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
688 */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
689 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
690 static void uninit(struct af_instance_s *af) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
691 int i; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
692 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
693 if (af->data) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
694 free(af->data); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
695 if (af->setup) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
696 af_ladspa_t *setup = (af_ladspa_t*) af->setup; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
697 const LADSPA_Descriptor *pdes = setup->plugin_descriptor; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
698 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
699 if (setup->myname) { |
14390 | 700 af_msg(AF_MSG_VERBOSE, "%s: cleaning up\n", setup->myname); |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
701 free(setup->myname); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
702 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
703 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
704 if (setup->chhandles) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
705 for(i=0; i<setup->nch; i++) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
706 if ( (setup->ninputs == 2) && (i & 1) ) { /* stereo effect */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
707 i++; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
708 continue; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
709 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
710 if (pdes->deactivate) pdes->deactivate(setup->chhandles[i]); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
711 if (pdes->cleanup) pdes->cleanup(setup->chhandles[i]); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
712 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
713 free(setup->chhandles); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
714 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
715 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
716 if (setup->file) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
717 free(setup->file); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
718 if (setup->label) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
719 free(setup->label); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
720 if (setup->inputcontrolsmap) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
721 free(setup->inputcontrolsmap); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
722 if (setup->inputcontrols) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
723 free(setup->inputcontrols); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
724 if (setup->outputcontrolsmap) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
725 free(setup->outputcontrolsmap); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
726 if (setup->outputcontrols) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
727 free(setup->outputcontrols); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
728 if (setup->inputs) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
729 free(setup->inputs); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
730 if (setup->outputs) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
731 free(setup->outputs); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
732 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
733 if (setup->inbufs) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
734 for(i=0; i<setup->nch; i++) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
735 if (setup->inbufs[i]) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
736 free(setup->inbufs[i]); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
737 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
738 free(setup->inbufs); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
739 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
740 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
741 if (setup->outbufs) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
742 for(i=0; i<setup->nch; i++) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
743 if (setup->outbufs[i]) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
744 free(setup->outbufs[i]); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
745 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
746 free(setup->outbufs); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
747 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
748 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
749 if (setup->libhandle) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
750 dlclose(setup->libhandle); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
751 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
752 free(setup); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
753 setup = NULL; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
754 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
755 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
756 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
757 /* ------------------------------------------------------------------------- */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
758 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
759 /** \brief Process chunk of audio data through the selected LADSPA Plugin. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
760 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
761 * \param af Pointer to audio filter instance |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
762 * \param data Pointer to chunk of audio data |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
763 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
764 * \return Either AF_ERROR or AF_OK |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
765 */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
766 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
767 static af_data_t* play(struct af_instance_s *af, af_data_t *data) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
768 af_ladspa_t *setup = af->setup; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
769 const LADSPA_Descriptor *pdes = setup->plugin_descriptor; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
770 int16_t *audio = (int16_t*)data->audio; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
771 int nsamples = data->len/2; /* /2 because it's int16_t */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
772 int nch = data->nch; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
773 int rate = data->rate; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
774 int i, p; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
775 float v; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
776 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
777 if (setup->status !=AF_OK) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
778 return data; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
779 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
780 /* See if it's the first call. If so, setup inbufs/outbufs, instantiate |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
781 * plugin, connect ports and activate plugin |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
782 */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
783 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
784 /* 2004-12-07: Also check if the buffersize has to be changed! |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
785 * data->len is not constant per se! re-init buffers. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
786 */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
787 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
788 if ( (setup->bufsize != nsamples/nch) || (setup->nch != nch) ) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
789 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
790 /* if setup->nch==0, it's the first call, if not, something has |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
791 * changed and all previous mallocs have to be freed |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
792 */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
793 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
794 if (setup->nch != 0) { |
14390 | 795 af_msg(AF_MSG_DEBUG1, "%s: bufsize change; free old buffer\n", |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
796 setup->myname); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
797 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
798 if(setup->inbufs) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
799 for(i=0; i<setup->nch; i++) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
800 if(setup->inbufs[i]) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
801 free(setup->inbufs[i]); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
802 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
803 free(setup->inbufs); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
804 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
805 if(setup->outbufs) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
806 for(i=0; i<setup->nch; i++) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
807 if(setup->outbufs[i]) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
808 free(setup->outbufs[i]); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
809 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
810 free(setup->outbufs); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
811 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
812 } /* everything is freed */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
813 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
814 setup->bufsize = nsamples/nch; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
815 setup->nch = nch; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
816 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
817 setup->inbufs = calloc(nch, sizeof(float*)); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
818 setup->outbufs = calloc(nch, sizeof(float*)); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
819 |
14390 | 820 af_msg(AF_MSG_DEBUG1, "%s: bufsize = %d\n", |
14217
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
821 setup->myname, setup->bufsize); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
822 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
823 for(i=0; i<nch; i++) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
824 setup->inbufs[i] = calloc(setup->bufsize, sizeof(float)); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
825 setup->outbufs[i] = calloc(setup->bufsize, sizeof(float)); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
826 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
827 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
828 /* only on the first call, there are no handles. */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
829 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
830 if (!setup->chhandles) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
831 setup->chhandles = calloc(nch, sizeof(LADSPA_Handle)); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
832 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
833 /* create handles |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
834 * for stereo effects, create one handle for two channels |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
835 */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
836 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
837 for(i=0; i<nch; i++) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
838 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
839 if ( (setup->ninputs == 2) && (i & 1) ) { /* stereo effect */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
840 /* copy the handle from previous channel */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
841 setup->chhandles[i] = setup->chhandles[i-1]; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
842 continue; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
843 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
844 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
845 setup->chhandles[i] = pdes->instantiate(pdes, rate); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
846 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
847 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
848 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
849 /* connect input/output ports for each channel/filter instance |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
850 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
851 * always (re)connect ports |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
852 */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
853 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
854 for(i=0; i<nch; i++) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
855 pdes->connect_port(setup->chhandles[i], |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
856 setup->inputs[ (setup->ninputs==2) ? i&1 : 0 ], |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
857 setup->inbufs[i]); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
858 pdes->connect_port(setup->chhandles[i], |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
859 setup->outputs[ (setup->ninputs==2) ? i&1 : 0 ], |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
860 setup->outbufs[i]); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
861 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
862 /* connect (input) controls */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
863 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
864 for (p=0; p<setup->nports; p++) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
865 LADSPA_PortDescriptor d = pdes->PortDescriptors[p]; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
866 if (LADSPA_IS_PORT_CONTROL(d)) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
867 if (LADSPA_IS_PORT_INPUT(d)) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
868 pdes->connect_port(setup->chhandles[i], p, |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
869 &(setup->inputcontrols[p]) ); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
870 } else { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
871 pdes->connect_port(setup->chhandles[i], p, |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
872 &(setup->outputcontrols[p]) ); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
873 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
874 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
875 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
876 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
877 /* Activate filter (if it isn't already :) ) */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
878 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
879 if ( (pdes->activate) && (setup->activated == 0) ) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
880 pdes->activate(setup->chhandles[i]); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
881 setup->activated = 1; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
882 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
883 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
884 } /* All channels/filters done! except for... */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
885 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
886 /* Stereo effect with one channel left. Use same buffer for left |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
887 * and right. connect it to the second port. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
888 */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
889 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
890 if( (setup->ninputs == 2) && (i&1) && (i >= 1) ) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
891 pdes->connect_port(setup->chhandles[i-1], |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
892 setup->inputs[ (setup->ninputs==2) ? i&1 : 0 ], |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
893 setup->inbufs[i-1]); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
894 pdes->connect_port(setup->chhandles[i-1], |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
895 setup->outputs[ (setup->ninputs==2) ? i&1 : 0 ], |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
896 setup->outbufs[i-1]); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
897 } /* done! */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
898 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
899 } /* setup for first call/change of bufsize is done. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
900 * normal playing routine follows... |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
901 */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
902 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
903 /* Right now, I use a separate input and output buffer. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
904 * I could change this to in-place processing (inbuf==outbuf), but some |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
905 * ladspa filters are broken and are not able to handle that. This seems |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
906 * fast enough, so unless somebody complains, it stays this way :) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
907 */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
908 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
909 /* Fill inbufs */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
910 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
911 for (p=0; p<setup->bufsize; p++) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
912 for (i=0; i<nch; i++) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
913 setup->inbufs[i][p] = ( (float) audio[p*nch + i] ) / 32768.0f; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
914 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
915 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
916 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
917 /* Run filter(s) */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
918 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
919 for (i=0; i<nch; i++) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
920 pdes->run(setup->chhandles[i], setup->bufsize); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
921 if (setup->ninputs==2) // stereo effect just ran |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
922 i++; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
923 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
924 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
925 /* Extract outbufs, hard clipping in case the filter exceeded [-1.0,1.0] */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
926 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
927 for (p=0; p<setup->bufsize; p++) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
928 for (i=0; i<nch; i++) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
929 v = setup->outbufs[i][p]; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
930 v *= 32768.0f; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
931 v = (v > 32767.0f ? 32767.0f : v); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
932 v = (v < -32768.0f ? -32768.0f : v); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
933 audio[p*nch + i] = (int16_t) v; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
934 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
935 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
936 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
937 /* done */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
938 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
939 return data; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
940 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
941 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
942 /* ------------------------------------------------------------------------- */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
943 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
944 /** \brief Open LADSPA Plugin Loader Filter |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
945 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
946 * \param af Audio Filter instance |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
947 * |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
948 * \return Either AF_ERROR or AF_OK |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
949 */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
950 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
951 static int open(af_instance_t *af) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
952 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
953 af->control=control; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
954 af->uninit=uninit; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
955 af->play=play; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
956 af->mul.n=1; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
957 af->mul.d=1; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
958 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
959 af->data = calloc(1, sizeof(af_data_t)); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
960 if (af->data == NULL) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
961 return af_ladspa_malloc_failed((char*)af_info_ladspa.name); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
962 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
963 af->setup = calloc(1, sizeof(af_ladspa_t)); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
964 if (af->setup == NULL) { |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
965 free(af->data); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
966 af->data=NULL; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
967 return af_ladspa_malloc_failed((char*)af_info_ladspa.name); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
968 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
969 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
970 ((af_ladspa_t*)af->setup)->status = AF_ERROR; /* will be set to AF_OK if |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
971 * all went OK and play() |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
972 * should proceed. |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
973 */ |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
974 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
975 ((af_ladspa_t*)af->setup)->myname = strdup(af_info_ladspa.name); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
976 if (!((af_ladspa_t*)af->setup)->myname) |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
977 return af_ladspa_malloc_failed((char*)af_info_ladspa.name); |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
978 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
979 return AF_OK; |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
980 } |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
981 |
5b5ebf93ec16
Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff
changeset
|
982 /* ------------------------------------------------------------------------- */ |