naspro

view src/ladspa/lrdf.c @ 161:cf56ca881571

Fixed some bugs
author Stefano D'Angelo <zanga.mail@gmail.com>
date Sun Jul 19 03:50:39 2009 +0200 (2009-07-19)
parents cc067fdfbaf4
children
line source
1 /*
2 * NASPRO - NASPRO Architecture for Sound Processing
3 * LADSPA bridge
4 *
5 * Copyright (C) 2007-2009 Stefano D'Angelo <zanga.mail@gmail.com>
6 *
7 * See the COPYING file for license conditions.
8 */
10 #include <stdlib.h>
11 #include <stdint.h>
12 #include <string.h>
13 #include <errno.h>
15 #include <locale.h>
17 #include <ladspa.h>
19 #include <librdf.h>
21 #include <NASPRO/core/lib.h>
23 #include "src/ladspa/lrdf.h"
25 #define LADSPA_PREFIX "http://ladspa.org/ontology#"
26 #define RDF_PREFIX "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
28 static librdf_world *world = NULL;
29 static librdf_parser *parser = NULL;
30 static librdf_storage *storage = NULL;
31 static librdf_model *model = NULL;
33 static void
34 parse_file(const char *file, void *data)
35 {
36 librdf_uri *uri;
38 uri = librdf_new_uri_from_filename(world, file);
39 if (uri == NULL)
40 return;
42 librdf_parser_parse_into_model(parser, uri, NULL, model);
44 librdf_free_uri(uri);
45 }
47 static char
48 rdf_filter(const char *file)
49 {
50 size_t file_len;
52 file_len = strlen(file);
54 if (file_len <= 4)
55 return 0;
56 if (!strcmp(file + file_len - 4, ".rdf"))
57 return 1;
59 if (file_len <= 5)
60 return 0;
62 return !strcmp(file + file_len - 5, ".rdfs");
63 }
65 void
66 _naladspa_lrdf_load_all()
67 {
68 char *lrdf_path;
69 char *prev_locale;
71 world = librdf_new_world();
72 if (world == NULL)
73 goto world_err;
75 parser = librdf_new_parser(world, NULL, NULL, NULL);
76 if (parser == NULL)
77 goto parser_err;
79 storage = librdf_new_storage(world, "hashes", NULL,
80 "hash-type='memory'");
81 if (storage == NULL)
82 goto storage_err;
84 model = librdf_new_model(world, storage, NULL);
85 if (model == NULL)
86 goto model_err;
88 prev_locale = setlocale(LC_NUMERIC, NULL);
89 setlocale(LC_NUMERIC, "C");
91 lrdf_path = nacore_env_get_var("LADSPA_RDF_PATH");
92 if (NACORE_STRING_IS_NULL_OR_EMPTY(lrdf_path))
93 {
94 /* TODO: This is *nix-only */
95 nacore_path_home_for_each(".ladspa/rdf", parse_file, rdf_filter,
96 NULL);
97 nacore_path_for_each("/usr/share/ladspa/rdf", parse_file,
98 rdf_filter, NULL);
99 }
100 else
101 nacore_path_for_each(lrdf_path, parse_file, rdf_filter, NULL);
103 if (lrdf_path != NULL)
104 nacore_env_free_var_value(lrdf_path);
106 setlocale(LC_NUMERIC, prev_locale);
108 return;
110 model_err:
111 librdf_free_storage(storage);
112 storage_err:
113 librdf_free_parser(parser);
114 parser_err:
115 librdf_free_world(world);
116 world_err:
117 return;
118 }
120 void
121 _naladspa_lrdf_unload_all()
122 {
123 if (model == NULL)
124 return;
126 librdf_free_model(model);
127 model = NULL;
128 librdf_free_storage(storage);
129 storage = NULL;
130 librdf_free_parser(parser);
131 parser = NULL;
132 librdf_free_world(world);
133 world = NULL;
134 }
136 static char
137 model_contains_statement_with_subject_node(librdf_node *subject_node,
138 const char *predicate,
139 const char *object)
140 {
141 librdf_node *predicate_node, *object_node;
142 librdf_statement *statement;
143 char ret;
145 predicate_node = librdf_new_node_from_uri_string(world,
146 (const unsigned char *)predicate);
147 if (predicate_node == NULL)
148 {
149 librdf_free_node(subject_node);
150 return 0;
151 }
153 object_node = librdf_new_node_from_uri_string(world,
154 (const unsigned char *)object);
155 if (object_node == NULL)
156 {
157 librdf_free_node(predicate_node);
158 librdf_free_node(subject_node);
159 return 0;
160 }
162 statement = librdf_new_statement_from_nodes(world, subject_node,
163 predicate_node, object_node);
164 if (statement == NULL)
165 {
166 librdf_free_node(object_node);
167 librdf_free_node(predicate_node);
168 librdf_free_node(subject_node);
169 return 0;
170 }
172 ret = librdf_model_contains_statement(model, statement) != 0;
174 librdf_free_statement(statement);
176 return ret;
177 }
179 static char
180 model_contains_statement(const char *subject, const char *predicate,
181 const char *object)
182 {
183 librdf_node *subject_node;
185 subject_node = librdf_new_node_from_uri_string(world,
186 (const unsigned char*)subject);
187 if (subject_node == NULL)
188 return 0;
190 return model_contains_statement_with_subject_node(subject_node,
191 predicate, object);
192 }
194 static librdf_stream *
195 model_find_statements_with_subject_node(librdf_node *subject_node,
196 const char *predicate,
197 const char *object)
198 {
199 librdf_node *predicate_node, *object_node;
200 librdf_statement *statement;
201 librdf_stream *ret;
203 predicate_node = NULL;
204 if (predicate != NULL)
205 {
206 predicate_node = librdf_new_node_from_uri_string(world,
207 (const unsigned char*)predicate);
208 if (predicate_node == NULL)
209 {
210 if (subject_node != NULL)
211 librdf_free_node(subject_node);
212 return NULL;
213 }
214 }
216 object_node = NULL;
217 if (object_node != NULL)
218 {
219 object_node = librdf_new_node_from_uri_string(world,
220 (const unsigned char*)object);
221 if (object_node == NULL)
222 {
223 if (predicate_node != NULL)
224 librdf_free_node(predicate_node);
225 if (subject_node != NULL)
226 librdf_free_node(subject_node);
227 return NULL;
228 }
229 }
231 statement = librdf_new_statement(world);
232 if (statement == NULL)
233 {
234 if (object_node != NULL)
235 librdf_free_node(object_node);
236 if (predicate_node != NULL)
237 librdf_free_node(predicate_node);
238 if (subject_node != NULL)
239 librdf_free_node(subject_node);
240 return NULL;
241 }
243 if (subject_node != NULL)
244 librdf_statement_set_subject(statement, subject_node);
245 if (predicate_node != NULL)
246 librdf_statement_set_predicate(statement, predicate_node);
247 if (object_node != NULL)
248 librdf_statement_set_object(statement, object_node);
250 ret = librdf_model_find_statements(model, statement);
252 librdf_free_statement(statement);
254 return ret;
255 }
257 static librdf_stream *
258 model_find_statements(const char *subject, const char *predicate,
259 const char *object)
260 {
261 librdf_node *subject_node;
263 subject_node = NULL;
264 if (subject != NULL)
265 {
266 subject_node = librdf_new_node_from_uri_string(world,
267 (const unsigned char*)subject);
268 if (subject_node == NULL)
269 return NULL;
270 }
272 return model_find_statements_with_subject_node(subject_node,
273 predicate, object);
274 }
276 #define X_MATCH(string, code) \
277 if (model_contains_statement(subject, RDF_PREFIX "type", \
278 LADSPA_PREFIX string)) \
279 { \
280 code \
281 }
283 #define S_MATCH_1(string, na_class) \
284 X_MATCH(string, classes_1 |= na_class;)
286 #define C_MATCH_1(string, na_class, na_out_class) \
287 X_MATCH(string, \
288 classes_1 |= na_class; \
289 classes_1 &= ~(na_out_class);)
291 #define S_MATCH_2(string, na_class) \
292 X_MATCH(string, classes_2 |= na_class;)
294 #define C_MATCH_2(string, na_class, na_out_class) \
295 X_MATCH(string, \
296 classes_2 |= na_class; \
297 classes_2 &= ~(na_out_class);)
299 void
300 _naladspa_lrdf_get_classes(struct nacore_descriptor *desc)
301 {
302 LADSPA_Descriptor *ldesc;
303 char subject[strlen(LADSPA_PREFIX) + 9];
304 uint32_t classes_1 = 0, classes_2 = 0;
306 if (model == NULL)
307 return;
309 ldesc = (LADSPA_Descriptor *)desc->data;
311 sprintf(subject, "%s%lu", LADSPA_PREFIX, ldesc->UniqueID);
313 S_MATCH_1("UtilityPlugin", NACORE_DESCRIPTOR_CLASS_UTILITY);
314 S_MATCH_1("GeneratorPlugin", NACORE_DESCRIPTOR_CLASS_GENERATOR);
315 S_MATCH_1("SimulatorPlugin", NACORE_DESCRIPTOR_CLASS_SIMULATOR);
316 S_MATCH_1("DelayPlugin", NACORE_DESCRIPTOR_CLASS_DELAY);
317 S_MATCH_1("ModulatorPlugin", NACORE_DESCRIPTOR_CLASS_MODULATOR);
318 S_MATCH_1("FrequencyPlugin", NACORE_DESCRIPTOR_CLASS_SPECTRAL);
319 S_MATCH_1("FilterPlugin", NACORE_DESCRIPTOR_CLASS_FILTER);
320 S_MATCH_2("AmplitudePlugin", NACORE_DESCRIPTOR_CLASS_DYNAMICS);
321 S_MATCH_1("AmplifierPlugin", NACORE_DESCRIPTOR_CLASS_AMPLIFIER);
322 S_MATCH_1("DistortionPlugin", NACORE_DESCRIPTOR_CLASS_DISTORTION);
323 S_MATCH_1("ModulatorPlugin", NACORE_DESCRIPTOR_CLASS_MODULATOR);
324 S_MATCH_2("DynamicsPlugin", NACORE_DESCRIPTOR_CLASS_DYNAMICS);
325 C_MATCH_1("OscillatorPlugin", NACORE_DESCRIPTOR_CLASS_OSCILLATOR,
326 NACORE_DESCRIPTOR_CLASS_GENERATOR);
327 C_MATCH_1("PhaserPlugin", NACORE_DESCRIPTOR_CLASS_PHASER,
328 NACORE_DESCRIPTOR_CLASS_MODULATOR);
329 C_MATCH_1("FlangerPlugin", NACORE_DESCRIPTOR_CLASS_FLANGER,
330 NACORE_DESCRIPTOR_CLASS_MODULATOR);
331 C_MATCH_1("ChorusPlugin", NACORE_DESCRIPTOR_CLASS_CHORUS,
332 NACORE_DESCRIPTOR_CLASS_MODULATOR);
333 C_MATCH_1("ReverbPlugin", NACORE_DESCRIPTOR_CLASS_REVERB,
334 NACORE_DESCRIPTOR_CLASS_SIMULATOR
335 | NACORE_DESCRIPTOR_CLASS_DELAY);
336 C_MATCH_1("FrequencyMeterPlugin", NACORE_DESCRIPTOR_CLASS_SPECTRAL
337 | NACORE_DESCRIPTOR_CLASS_ANALYSER,
338 NACORE_DESCRIPTOR_CLASS_UTILITY);
339 C_MATCH_1("LowpassPlugin", NACORE_DESCRIPTOR_CLASS_LOWPASS,
340 NACORE_DESCRIPTOR_CLASS_FILTER);
341 C_MATCH_1("HighpassPlugin", NACORE_DESCRIPTOR_CLASS_HIGHPASS,
342 NACORE_DESCRIPTOR_CLASS_FILTER);
343 C_MATCH_1("BandpassPlugin", NACORE_DESCRIPTOR_CLASS_BANDPASS,
344 NACORE_DESCRIPTOR_CLASS_FILTER);
345 C_MATCH_1("CombPlugin", NACORE_DESCRIPTOR_CLASS_COMB,
346 NACORE_DESCRIPTOR_CLASS_FILTER);
347 C_MATCH_1("AllpassPlugin", NACORE_DESCRIPTOR_CLASS_ALLPASS,
348 NACORE_DESCRIPTOR_CLASS_FILTER);
349 C_MATCH_1("EQPlugin", NACORE_DESCRIPTOR_CLASS_EQ,
350 NACORE_DESCRIPTOR_CLASS_FILTER);
351 C_MATCH_1("ParaEQPlugin", NACORE_DESCRIPTOR_CLASS_PARAEQ,
352 NACORE_DESCRIPTOR_CLASS_FILTER
353 | NACORE_DESCRIPTOR_CLASS_EQ);
354 C_MATCH_1("MultiEQPlugin", NACORE_DESCRIPTOR_CLASS_MULTIEQ,
355 NACORE_DESCRIPTOR_CLASS_FILTER
356 | NACORE_DESCRIPTOR_CLASS_EQ);
357 C_MATCH_1("PitchPlugin", NACORE_DESCRIPTOR_CLASS_PITCH,
358 NACORE_DESCRIPTOR_CLASS_SPECTRAL);
359 C_MATCH_1("WaveshaperPlugin", NACORE_DESCRIPTOR_CLASS_WAVESHAPER,
360 NACORE_DESCRIPTOR_CLASS_DISTORTION);
361 C_MATCH_2("CompressorPlugin", NACORE_DESCRIPTOR_CLASS_COMPRESSOR,
362 NACORE_DESCRIPTOR_CLASS_DYNAMICS);
363 C_MATCH_2("ExpanderPlugin", NACORE_DESCRIPTOR_CLASS_EXPANDER,
364 NACORE_DESCRIPTOR_CLASS_DYNAMICS);
365 C_MATCH_2("LimiterPlugin", NACORE_DESCRIPTOR_CLASS_LIMITER,
366 NACORE_DESCRIPTOR_CLASS_DYNAMICS);
367 C_MATCH_2("GatePlugin", NACORE_DESCRIPTOR_CLASS_GATE,
368 NACORE_DESCRIPTOR_CLASS_DYNAMICS);
370 desc->classes_1 = classes_1;
371 desc->classes_2 = classes_2;
372 }
374 void
375 _naladspa_lrdf_get_scale_defaults(struct nacore_descriptor *desc,
376 struct nacore_port_descriptor *port_descs)
377 {
378 LADSPA_Descriptor *ldesc;
379 librdf_node *setting_node;
380 librdf_node *setting_node2;
381 librdf_node *default_node;
382 librdf_node *port_value_node;
383 librdf_node *port_value_node2;
384 librdf_node *port_value_node3;
385 librdf_stream *stream;
386 librdf_stream *stream2;
387 char subject[strlen(LADSPA_PREFIX) + 9];
388 float value;
389 unsigned long index;
390 char *prev_locale;
392 if (model == NULL)
393 return;
395 prev_locale = setlocale(LC_NUMERIC, NULL);
396 setlocale(LC_NUMERIC, "C");
398 ldesc = (LADSPA_Descriptor *)desc->data;
400 sprintf(subject, "%s%lu", LADSPA_PREFIX, ldesc->UniqueID);
402 stream = model_find_statements(subject, LADSPA_PREFIX "hasSetting",
403 NULL);
404 if (stream == NULL)
405 goto end;
407 default_node = NULL;
408 while (!librdf_stream_end(stream))
409 {
410 setting_node = librdf_statement_get_object(
411 librdf_stream_get_object(stream));
412 setting_node2 = librdf_new_node_from_node(setting_node);
414 if (model_contains_statement_with_subject_node(setting_node2,
415 RDF_PREFIX "type", LADSPA_PREFIX "Default"))
416 {
417 default_node = librdf_new_node_from_node(setting_node);
418 break;
419 }
421 librdf_stream_next(stream);
422 }
423 librdf_free_stream(stream);
425 if (default_node == NULL)
426 goto end;
428 stream = model_find_statements_with_subject_node(default_node,
429 LADSPA_PREFIX "hasPortValue", NULL);
430 if (stream == NULL)
431 goto end;
433 while (!librdf_stream_end(stream))
434 {
435 port_value_node = librdf_statement_get_object(
436 librdf_stream_get_object(stream));
437 port_value_node2 = librdf_new_node_from_node(port_value_node);
438 port_value_node3 = librdf_new_node_from_node(port_value_node);
440 stream2 = model_find_statements_with_subject_node(
441 port_value_node2, RDF_PREFIX "value", NULL);
442 if (stream2 == NULL)
443 break;
445 if (librdf_stream_end(stream2))
446 {
447 librdf_free_stream(stream2);
448 break;
449 }
450 value = atof((char *)
451 librdf_node_get_literal_value(
452 librdf_statement_get_object(
453 librdf_stream_get_object(stream2))));
455 librdf_free_stream(stream2);
457 stream2 = model_find_statements_with_subject_node(
458 port_value_node3, LADSPA_PREFIX "forPort",
459 NULL);
460 if (stream2 == NULL)
461 break;
463 if (librdf_stream_end(stream2))
464 {
465 librdf_free_stream(stream2);
466 break;
467 }
469 index = strtoul(
470 strrchr((char *)
471 librdf_uri_as_string(
472 librdf_node_get_uri(
473 librdf_statement_get_object(
474 librdf_stream_get_object(stream2)))),
475 '.') + 1,
476 NULL, 10);
478 librdf_free_stream(stream2);
480 if (index < desc->port_descs_count)
481 {
482 port_descs[index].scale.properties |=
483 NACORE_SCALE_HAS_DEFAULT;
484 port_descs[index].scale.defaultv = value;
485 }
487 librdf_stream_next(stream);
488 }
489 librdf_free_stream(stream);
491 end:
492 setlocale(LC_NUMERIC, prev_locale);
493 }
495 void
496 _naladspa_lrdf_get_scale_points(struct nacore_descriptor *desc,
497 struct nacore_port_descriptor *port,
498 size_t index)
499 {
500 LADSPA_Descriptor *ldesc;
501 librdf_stream *stream;
502 librdf_stream *stream2;
503 librdf_stream *stream3;
504 librdf_node *scale_node;
505 librdf_node *scale_node2;
506 librdf_node *point_node;
507 librdf_node *point_node2;
508 char subject[strlen(LADSPA_PREFIX) + 20];
509 char *label, *p;
510 size_t len, count, i;
511 char *prev_locale;
513 if (model == NULL)
514 return;
516 prev_locale = setlocale(LC_NUMERIC, NULL);
517 setlocale(LC_NUMERIC, "C");
519 ldesc = (LADSPA_Descriptor *)desc->data;
521 sprintf(subject, "%s%lu.%lu", LADSPA_PREFIX, ldesc->UniqueID,
522 (unsigned long)index);
524 stream = model_find_statements(subject, LADSPA_PREFIX "hasScale", NULL);
525 if (stream == NULL)
526 goto stream_err;
528 if (librdf_stream_end(stream))
529 goto stream_end;
531 scale_node = librdf_statement_get_object(
532 librdf_stream_get_object(stream));
533 scale_node2 = librdf_new_node_from_node(scale_node);
534 if (scale_node2 == NULL)
535 goto stream_end;
537 stream2 = model_find_statements_with_subject_node(scale_node2,
538 LADSPA_PREFIX "hasPoint", NULL);
539 if (stream2 == NULL)
540 {
541 librdf_free_node(scale_node2);
542 goto stream_end;
543 }
545 count = 0;
546 len = 0;
547 while (!librdf_stream_end(stream2))
548 {
549 point_node = librdf_statement_get_object(
550 librdf_stream_get_object(stream2));
551 point_node2 = librdf_new_node_from_node(point_node);
553 stream3 = model_find_statements_with_subject_node(
554 point_node2, LADSPA_PREFIX "hasLabel", NULL);
555 if (stream3 == NULL)
556 {
557 librdf_free_stream(stream2);
558 goto stream_end;
559 }
561 if (librdf_stream_end(stream3))
562 {
563 librdf_free_stream(stream3);
564 librdf_free_stream(stream2);
565 goto stream_end;
566 }
568 label = (char *)
569 librdf_node_get_literal_value(
570 librdf_statement_get_object(
571 librdf_stream_get_object(stream3)));
573 len += strlen(label) + 1;
574 count++;
576 librdf_free_stream(stream3);
578 librdf_stream_next(stream2);
579 }
580 librdf_free_stream(stream2);
582 if (count == 0)
583 goto stream_end;
585 port->data = malloc(len);
586 if (port->data == NULL)
587 goto stream_end;
589 port->scale.points = malloc(count * sizeof(struct nacore_scale_point));
590 if (port->scale.points == NULL)
591 {
592 free(port->data);
593 port->data = NULL;
594 goto stream_end;
595 }
597 scale_node2 = librdf_new_node_from_node(scale_node);
598 if (scale_node2 == NULL)
599 {
600 free(port->data);
601 port->data = NULL;
602 free(port->scale.points);
603 port->scale.points = NULL;
604 goto stream_end;
605 }
607 stream2 = model_find_statements_with_subject_node(scale_node2,
608 LADSPA_PREFIX "hasPoint", NULL);
609 if (stream2 == NULL)
610 {
611 free(port->data);
612 port->data = NULL;
613 free(port->scale.points);
614 port->scale.points = NULL;
615 goto stream_end;
616 }
618 i = 0;
619 p = (char *)port->data;
620 while (!librdf_stream_end(stream2))
621 {
622 point_node = librdf_statement_get_object(
623 librdf_stream_get_object(stream2));
624 point_node2 = librdf_new_node_from_node(point_node);
626 stream3 = model_find_statements_with_subject_node(
627 point_node2, LADSPA_PREFIX "hasLabel", NULL);
628 if (stream3 == NULL)
629 {
630 librdf_free_stream(stream2);
631 free(port->data);
632 port->data = NULL;
633 free(port->scale.points);
634 port->scale.points = NULL;
635 goto stream_end;
636 }
638 if (librdf_stream_end(stream3))
639 {
640 librdf_free_stream(stream3);
641 librdf_free_stream(stream2);
642 free(port->data);
643 port->data = NULL;
644 free(port->scale.points);
645 port->scale.points = NULL;
646 goto stream_end;
647 }
649 label = (char *)
650 librdf_node_get_literal_value(
651 librdf_statement_get_object(
652 librdf_stream_get_object(stream3)));
654 port->scale.points[i].label = p;
656 strcpy(p, label);
657 p += strlen(p) + 1;
659 librdf_free_stream(stream3);
661 point_node2 = librdf_new_node_from_node(point_node);
663 stream3 = model_find_statements_with_subject_node(
664 point_node2, RDF_PREFIX "value", NULL);
665 if (stream3 == NULL)
666 {
667 librdf_free_stream(stream2);
668 free(port->data);
669 port->data = NULL;
670 free(port->scale.points);
671 port->scale.points = NULL;
672 goto stream_end;
673 }
675 if (librdf_stream_end(stream3))
676 {
677 librdf_free_stream(stream3);
678 librdf_free_stream(stream2);
679 free(port->data);
680 port->data = NULL;
681 free(port->scale.points);
682 port->scale.points = NULL;
683 goto stream_end;
684 }
686 port->scale.points[i].value = atof((char *)
687 librdf_node_get_literal_value(
688 librdf_statement_get_object(
689 librdf_stream_get_object(stream3))));
691 librdf_free_stream(stream3);
693 i++;
695 librdf_stream_next(stream2);
696 }
697 librdf_free_stream(stream2);
699 port->scale.points_count = count;
701 stream_end:
702 librdf_free_stream(stream);
703 stream_err:
704 setlocale(LC_NUMERIC, prev_locale);
705 }
707 #define MATCH_UNIT(s, u) \
708 if (!strcmp(value, LADSPA_PREFIX s)) \
709 { \
710 port->scale.unit = u; \
711 librdf_free_stream(stream); \
712 return; \
713 }
715 void
716 _naladspa_lrdf_get_scale_units(struct nacore_descriptor *desc,
717 struct nacore_port_descriptor *port,
718 size_t index)
719 {
720 LADSPA_Descriptor *ldesc;
721 librdf_stream *stream;
722 char subject[strlen(LADSPA_PREFIX) + 20];
723 char *value;
725 port->scale.unit = nacore_scale_unit_none;
727 if (model == NULL)
728 return;
730 ldesc = (LADSPA_Descriptor *)desc->data;
732 sprintf(subject, "%s%lu.%lu", LADSPA_PREFIX, ldesc->UniqueID,
733 (unsigned long)index);
735 stream = model_find_statements(subject, LADSPA_PREFIX "hasUnit", NULL);
736 if (stream == NULL)
737 return;
739 if (librdf_stream_end(stream))
740 {
741 librdf_free_stream(stream);
742 return;
743 }
745 value = (char *)librdf_node_get_literal_value(
746 librdf_statement_get_object(
747 librdf_stream_get_object(stream)));
749 MATCH_UNIT("dB", nacore_scale_unit_db);
750 MATCH_UNIT("coef", nacore_scale_unit_coeff);
751 MATCH_UNIT("Hz", nacore_scale_unit_hz);
752 MATCH_UNIT("seconds", nacore_scale_unit_s);
753 MATCH_UNIT("milliseconds", nacore_scale_unit_ms);
754 MATCH_UNIT("minutes", nacore_scale_unit_m);
756 librdf_free_stream(stream);
757 }
759 void
760 _naladspa_lrdf_free_data(struct nacore_port_descriptor *port)
761 {
762 if (port->scale.points != NULL)
763 free(port->scale.points);
764 if (port->data != NULL)
765 free(port->data);
766 }