1 /*
2     Copyright (C) 2004-2009 Fons Adriaensen <fons@kokkinizita.net>
3 
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8 
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13 
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18 
19 
20 //-----------------------------------------------------------------------------------
21 // Common definitions
22 //-----------------------------------------------------------------------------------
23 
24 
25 #include "ambisonic2.h"
26 
27 
28 #define NMODS 4
29 #define VERSION "0.6.1"
30 
31 
32 static const char* maker = "Fons Adriaensen <fons@kokkinizita.net>";
33 static const char* copyr = "GPL";
34 
35 
pconnect(LADSPA_Handle H,unsigned long port,LADSPA_Data * data)36 static void pconnect (LADSPA_Handle H, unsigned long port, LADSPA_Data *data)
37 {
38     ((LadspaPlugin *)H)->setport (port, data);
39 }
40 
activate(LADSPA_Handle H)41 static void activate (LADSPA_Handle H)
42 {
43     ((LadspaPlugin *)H)->active (true);
44 }
45 
runplugin(LADSPA_Handle H,unsigned long k)46 static void runplugin (LADSPA_Handle H, unsigned long k)
47 {
48     ((LadspaPlugin *)H)->runproc (k, false);
49 }
50 /*
51   static void runadding (LADSPA_Handle H, unsigned long k)
52   {
53   ((LadspaPlugin *)H)->runproc (k, true);
54   }
55 
56   static void setadding (LADSPA_Handle H, LADSPA_Data gain)
57   {
58   ((LadspaPlugin *)H)->setgain (gain);
59   }
60 */
deactivate(LADSPA_Handle H)61 static void deactivate (LADSPA_Handle H)
62 {
63     ((LadspaPlugin *)H)->active (false);
64 }
65 
cleanup(LADSPA_Handle H)66 static void cleanup (LADSPA_Handle H)
67 {
68     delete (LadspaPlugin *) H;
69 }
70 
71 
72 //-----------------------------------------------------------------------------------
73 // Plugin definitions
74 //-----------------------------------------------------------------------------------
75 
76 
77 static const char* label0 = "Ambisonics-21-panner";
78 static const char* name0  = "AMB order 2,1 panner";
79 
80 
instant0(const struct _LADSPA_Descriptor * desc,unsigned long rate)81 static LADSPA_Handle instant0 (const struct _LADSPA_Descriptor *desc, unsigned long rate)
82 {
83     return new Ladspa_Monopan21 (rate);
84 }
85 
86 
87 static const LADSPA_PortDescriptor pdesc0 [Ladspa_Monopan21::NPORT] =
88 {
89     LADSPA_PORT_INPUT  | LADSPA_PORT_AUDIO,
90     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
91     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
92     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
93     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
94     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
95     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
96     LADSPA_PORT_INPUT  | LADSPA_PORT_CONTROL,
97     LADSPA_PORT_INPUT  | LADSPA_PORT_CONTROL
98 };
99 
100 static const char * const pname0 [Ladspa_Monopan21::NPORT] =
101 {
102     "In",
103     "Out-W",
104     "Out-X",
105     "Out-Y",
106     "Out-U",
107     "Out-V",
108     "Out-Z",
109     "Elevation",
110     "Azimuth"
111 };
112 
113 static const LADSPA_PortRangeHint phint0 [Ladspa_Monopan21::NPORT] =
114 {
115     { 0, 0, 0 },
116     { 0, 0, 0 },
117     { 0, 0, 0 },
118     { 0, 0, 0 },
119     { 0, 0, 0 },
120     { 0, 0, 0 },
121     { 0, 0, 0 },
122     { LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0, -90, 90 },
123     { LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0, -180, 180 }
124 };
125 
126 
127 //-----------------------------------------------------------------------------------
128 
129 
130 static const char* label1 = "Ambisonics-21-rotator";
131 static const char* name1  = "AMB order 2,1 rotator";
132 
133 
instant1(const struct _LADSPA_Descriptor * desc,unsigned long rate)134 static LADSPA_Handle instant1 (const struct _LADSPA_Descriptor *desc, unsigned long rate)
135 {
136     return new Ladspa_Rotator21 (rate);
137 }
138 
139 
140 static const LADSPA_PortDescriptor pdesc1 [Ladspa_Rotator21::NPORT] =
141 {
142     LADSPA_PORT_INPUT  | LADSPA_PORT_AUDIO,
143     LADSPA_PORT_INPUT  | LADSPA_PORT_AUDIO,
144     LADSPA_PORT_INPUT  | LADSPA_PORT_AUDIO,
145     LADSPA_PORT_INPUT  | LADSPA_PORT_AUDIO,
146     LADSPA_PORT_INPUT  | LADSPA_PORT_AUDIO,
147     LADSPA_PORT_INPUT  | LADSPA_PORT_AUDIO,
148     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
149     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
150     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
151     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
152     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
153     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
154     LADSPA_PORT_INPUT  | LADSPA_PORT_CONTROL
155 };
156 
157 static const char * const pname1 [Ladspa_Rotator21::NPORT] =
158 {
159     "In-W",
160     "In-X",
161     "In-Y",
162     "In-U",
163     "In-V",
164     "In-Z",
165     "Out-W",
166     "Out-X",
167     "Out-Y",
168     "Out-U",
169     "Out-V",
170     "Out-Z",
171     "Angle"
172 };
173 
174 static const LADSPA_PortRangeHint phint1 [Ladspa_Rotator21::NPORT] =
175 {
176     { 0, 0, 0 },
177     { 0, 0, 0 },
178     { 0, 0, 0 },
179     { 0, 0, 0 },
180     { 0, 0, 0 },
181     { 0, 0, 0 },
182     { 0, 0, 0 },
183     { 0, 0, 0 },
184     { 0, 0, 0 },
185     { 0, 0, 0 },
186     { 0, 0, 0 },
187     { 0, 0, 0 },
188     { LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0, -180, 180 }
189 };
190 
191 
192 //-----------------------------------------------------------------------------------
193 
194 
195 static const char* label2 = "Ambisonics-22-panner";
196 static const char* name2  = "AMB order 2,2 panner";
197 
198 
instant2(const struct _LADSPA_Descriptor * desc,unsigned long rate)199 static LADSPA_Handle instant2 (const struct _LADSPA_Descriptor *desc, unsigned long rate)
200 {
201     return new Ladspa_Monopan22 (rate);
202 }
203 
204 
205 static const LADSPA_PortDescriptor pdesc2 [Ladspa_Monopan22::NPORT] =
206 {
207     LADSPA_PORT_INPUT  | LADSPA_PORT_AUDIO,
208     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
209     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
210     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
211     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
212     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
213     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
214     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
215     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
216     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
217     LADSPA_PORT_INPUT  | LADSPA_PORT_CONTROL,
218     LADSPA_PORT_INPUT  | LADSPA_PORT_CONTROL
219 };
220 
221 static const char * const pname2 [Ladspa_Monopan22::NPORT] =
222 {
223     "In",
224     "Out-W",
225     "Out-X",
226     "Out-Y",
227     "Out-Z",
228     "Out-R",
229     "Out-S",
230     "Out-T",
231     "Out-U",
232     "Out-V",
233     "Elevation",
234     "Azimuth"
235 };
236 
237 static const LADSPA_PortRangeHint phint2 [Ladspa_Monopan22::NPORT] =
238 {
239     { 0, 0, 0 },
240     { 0, 0, 0 },
241     { 0, 0, 0 },
242     { 0, 0, 0 },
243     { 0, 0, 0 },
244     { 0, 0, 0 },
245     { 0, 0, 0 },
246     { 0, 0, 0 },
247     { 0, 0, 0 },
248     { 0, 0, 0 },
249     { LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0, -90, 90 },
250     { LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0, -180, 180 }
251 };
252 
253 
254 //-----------------------------------------------------------------------------------
255 
256 
257 static const char* label3 = "Ambisonics-22-rotator";
258 static const char* name3  = "AMB order 2,2 rotator";
259 
260 
instant3(const struct _LADSPA_Descriptor * desc,unsigned long rate)261 static LADSPA_Handle instant3 (const struct _LADSPA_Descriptor *desc, unsigned long rate)
262 {
263     return new Ladspa_Rotator22 (rate);
264 }
265 
266 
267 static const LADSPA_PortDescriptor pdesc3 [Ladspa_Rotator22::NPORT] =
268 {
269     LADSPA_PORT_INPUT  | LADSPA_PORT_AUDIO,
270     LADSPA_PORT_INPUT  | LADSPA_PORT_AUDIO,
271     LADSPA_PORT_INPUT  | LADSPA_PORT_AUDIO,
272     LADSPA_PORT_INPUT  | LADSPA_PORT_AUDIO,
273     LADSPA_PORT_INPUT  | LADSPA_PORT_AUDIO,
274     LADSPA_PORT_INPUT  | LADSPA_PORT_AUDIO,
275     LADSPA_PORT_INPUT  | LADSPA_PORT_AUDIO,
276     LADSPA_PORT_INPUT  | LADSPA_PORT_AUDIO,
277     LADSPA_PORT_INPUT  | LADSPA_PORT_AUDIO,
278     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
279     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
280     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
281     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
282     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
283     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
284     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
285     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
286     LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
287     LADSPA_PORT_INPUT  | LADSPA_PORT_CONTROL
288 };
289 
290 static const char * const pname3 [Ladspa_Rotator22::NPORT] =
291 {
292     "In-W",
293     "In-X",
294     "In-Y",
295     "In-Z",
296     "In-R",
297     "In-S",
298     "In-T",
299     "In-U",
300     "In-V",
301     "Out-W",
302     "Out-X",
303     "Out-Y",
304     "Out-Z",
305     "Out-R",
306     "Out-S",
307     "Out-T",
308     "Out-U",
309     "Out-V",
310     "Angle"
311 };
312 
313 static const LADSPA_PortRangeHint phint3 [Ladspa_Rotator22::NPORT] =
314 {
315     { 0, 0, 0 },
316     { 0, 0, 0 },
317     { 0, 0, 0 },
318     { 0, 0, 0 },
319     { 0, 0, 0 },
320     { 0, 0, 0 },
321     { 0, 0, 0 },
322     { 0, 0, 0 },
323     { 0, 0, 0 },
324     { 0, 0, 0 },
325     { 0, 0, 0 },
326     { 0, 0, 0 },
327     { 0, 0, 0 },
328     { 0, 0, 0 },
329     { 0, 0, 0 },
330     { 0, 0, 0 },
331     { 0, 0, 0 },
332     { 0, 0, 0 },
333     { LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0, -180, 180 }
334 };
335 
336 
337 //-----------------------------------------------------------------------------------
338 //  LADSPA dlsym interface
339 //-----------------------------------------------------------------------------------
340 
341 
342 static const LADSPA_Descriptor moddescr [NMODS] =
343 {
344     {
345 	1979,
346 	label0,
347 	LADSPA_PROPERTY_REALTIME | LADSPA_PROPERTY_HARD_RT_CAPABLE,
348 	name0,
349 	maker,
350 	copyr,
351 	Ladspa_Monopan21::NPORT,
352 	pdesc0,
353 	pname0,
354 	phint0,
355 	0,
356 	instant0,
357 	pconnect,
358 	activate,
359 	runplugin,
360 	0,
361 	0,
362 	deactivate,
363 	cleanup
364     },
365     {
366 	1980,
367 	label1,
368 	LADSPA_PROPERTY_REALTIME | LADSPA_PROPERTY_HARD_RT_CAPABLE,
369 	name1,
370 	maker,
371 	copyr,
372 	Ladspa_Rotator21::NPORT,
373 	pdesc1,
374 	pname1,
375 	phint1,
376 	0,
377 	instant1,
378 	pconnect,
379 	activate,
380 	runplugin,
381 	0,
382 	0,
383 	deactivate,
384 	cleanup
385     },
386     {
387 	1967,
388 	label2,
389 	LADSPA_PROPERTY_REALTIME | LADSPA_PROPERTY_HARD_RT_CAPABLE,
390 	name2,
391 	maker,
392 	copyr,
393 	Ladspa_Monopan22::NPORT,
394 	pdesc2,
395 	pname2,
396 	phint2,
397 	0,
398 	instant2,
399 	pconnect,
400 	activate,
401 	runplugin,
402 	0,
403 	0,
404 	deactivate,
405 	cleanup
406     },
407     {
408 	1968,
409 	label3,
410 	LADSPA_PROPERTY_REALTIME | LADSPA_PROPERTY_HARD_RT_CAPABLE,
411 	name3,
412 	maker,
413 	copyr,
414 	Ladspa_Rotator22::NPORT,
415 	pdesc3,
416 	pname3,
417 	phint3,
418 	0,
419 	instant3,
420 	pconnect,
421 	activate,
422 	runplugin,
423 	0,
424 	0,
425 	deactivate,
426 	cleanup
427     }
428 };
429 
430 
ladspa_descriptor(unsigned long i)431 extern "C" const LADSPA_Descriptor *ladspa_descriptor (unsigned long i)
432 {
433     if (i >= NMODS) return 0;
434     return moddescr + i;
435 }
436 
437 
438 //-----------------------------------------------------------------------------------
439