naspro

view naspro-bridges-bad/ladspa/lrdf.c @ 170:cebccb1b4718

Build system related stuff
author Stefano D'Angelo <zanga.mail@gmail.com>
date Fri Mar 12 00:49:32 2010 +0200 (2010-03-12)
parents d7568c8379c1
children 4f7243a606b1
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 "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, const char *basename, 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 nacore_path_home_for_each(LRDF_DEFAULT_HOME_PATH, parse_file,
95 rdf_filter, NULL);
96 nacore_path_for_each(LRDF_DEFAULT_SYSTEM_PATH, parse_file,
97 rdf_filter, NULL);
98 }
99 else
100 nacore_path_for_each(lrdf_path, parse_file, rdf_filter, NULL);
102 if (lrdf_path != NULL)
103 nacore_env_free_var_value(lrdf_path);
105 setlocale(LC_NUMERIC, prev_locale);
107 return;
109 model_err:
110 librdf_free_storage(storage);
111 storage_err:
112 librdf_free_parser(parser);
113 parser_err:
114 librdf_free_world(world);
115 world_err:
116 return;
117 }
119 void
120 _naladspa_lrdf_unload_all()
121 {
122 if (model == NULL)
123 return;
125 librdf_free_model(model);
126 model = NULL;
127 librdf_free_storage(storage);
128 storage = NULL;
129 librdf_free_parser(parser);
130 parser = NULL;
131 librdf_free_world(world);
132 world = NULL;
133 }
135 static char
136 model_contains_statement_with_subject_node(librdf_node *subject_node,
137 const char *predicate,
138 const char *object)
139 {
140 librdf_node *predicate_node, *object_node;
141 librdf_statement *statement;
142 char ret;
144 predicate_node = librdf_new_node_from_uri_string(world,
145 (const unsigned char *)predicate);
146 if (predicate_node == NULL)
147 {
148 librdf_free_node(subject_node);
149 return 0;
150 }
152 object_node = librdf_new_node_from_uri_string(world,
153 (const unsigned char *)object);
154 if (object_node == NULL)
155 {
156 librdf_free_node(predicate_node);
157 librdf_free_node(subject_node);
158 return 0;
159 }
161 statement = librdf_new_statement_from_nodes(world, subject_node,
162 predicate_node, object_node);
163 if (statement == NULL)
164 {
165 librdf_free_node(object_node);
166 librdf_free_node(predicate_node);
167 librdf_free_node(subject_node);
168 return 0;
169 }
171 ret = librdf_model_contains_statement(model, statement) != 0;
173 librdf_free_statement(statement);
175 return ret;
176 }
178 static char
179 model_contains_statement(const char *subject, const char *predicate,
180 const char *object)
181 {
182 librdf_node *subject_node;
184 subject_node = librdf_new_node_from_uri_string(world,
185 (const unsigned char*)subject);
186 if (subject_node == NULL)
187 return 0;
189 return model_contains_statement_with_subject_node(subject_node,
190 predicate, object);
191 }
193 static librdf_stream *
194 model_find_statements_with_subject_node(librdf_node *subject_node,
195 const char *predicate,
196 const char *object)
197 {
198 librdf_node *predicate_node, *object_node;
199 librdf_statement *statement;
200 librdf_stream *ret;
202 predicate_node = NULL;
203 if (predicate != NULL)
204 {
205 predicate_node = librdf_new_node_from_uri_string(world,
206 (const unsigned char*)predicate);
207 if (predicate_node == NULL)
208 {
209 if (subject_node != NULL)
210 librdf_free_node(subject_node);
211 return NULL;
212 }
213 }
215 object_node = NULL;
216 if (object_node != NULL)
217 {
218 object_node = librdf_new_node_from_uri_string(world,
219 (const unsigned char*)object);
220 if (object_node == NULL)
221 {
222 if (predicate_node != NULL)
223 librdf_free_node(predicate_node);
224 if (subject_node != NULL)
225 librdf_free_node(subject_node);
226 return NULL;
227 }
228 }
230 statement = librdf_new_statement(world);
231 if (statement == NULL)
232 {
233 if (object_node != NULL)
234 librdf_free_node(object_node);
235 if (predicate_node != NULL)
236 librdf_free_node(predicate_node);
237 if (subject_node != NULL)
238 librdf_free_node(subject_node);
239 return NULL;
240 }
242 if (subject_node != NULL)
243 librdf_statement_set_subject(statement, subject_node);
244 if (predicate_node != NULL)
245 librdf_statement_set_predicate(statement, predicate_node);
246 if (object_node != NULL)
247 librdf_statement_set_object(statement, object_node);
249 ret = librdf_model_find_statements(model, statement);
251 librdf_free_statement(statement);
253 return ret;
254 }
256 static librdf_stream *
257 model_find_statements(const char *subject, const char *predicate,
258 const char *object)
259 {
260 librdf_node *subject_node;
262 subject_node = NULL;
263 if (subject != NULL)
264 {
265 subject_node = librdf_new_node_from_uri_string(world,
266 (const unsigned char*)subject);
267 if (subject_node == NULL)
268 return NULL;
269 }
271 return model_find_statements_with_subject_node(subject_node,
272 predicate, object);
273 }
275 #define X_MATCH(string, code) \
276 if (model_contains_statement(subject, RDF_PREFIX "type", \
277 LADSPA_PREFIX string)) \
278 { \
279 code \
280 }
282 #define S_MATCH_1(string, na_class) \
283 X_MATCH(string, classes_1 |= na_class;)
285 #define C_MATCH_1(string, na_class, na_out_class) \
286 X_MATCH(string, \
287 classes_1 |= na_class; \
288 classes_1 &= ~(na_out_class);)
290 #define S_MATCH_2(string, na_class) \
291 X_MATCH(string, classes_2 |= na_class;)
293 #define C_MATCH_2(string, na_class, na_out_class) \
294 X_MATCH(string, \
295 classes_2 |= na_class; \
296 classes_2 &= ~(na_out_class);)
298 void
299 _naladspa_lrdf_get_classes(struct nacore_descriptor *desc)
300 {
301 LADSPA_Descriptor *ldesc;
302 char subject[strlen(LADSPA_PREFIX) + 9];
303 uint32_t classes_1 = 0, classes_2 = 0;
305 if (model == NULL)
306 return;
308 ldesc = (LADSPA_Descriptor *)desc->data;
310 sprintf(subject, "%s%lu", LADSPA_PREFIX, ldesc->UniqueID);
312 S_MATCH_1("UtilityPlugin", NACORE_DESCRIPTOR_CLASS_UTILITY);
313 S_MATCH_1("GeneratorPlugin", NACORE_DESCRIPTOR_CLASS_GENERATOR);
314 S_MATCH_1("SimulatorPlugin", NACORE_DESCRIPTOR_CLASS_SIMULATOR);
315 S_MATCH_1("DelayPlugin", NACORE_DESCRIPTOR_CLASS_DELAY);
316 S_MATCH_1("ModulatorPlugin", NACORE_DESCRIPTOR_CLASS_MODULATOR);
317 S_MATCH_1("FrequencyPlugin", NACORE_DESCRIPTOR_CLASS_SPECTRAL);
318 S_MATCH_1("FilterPlugin", NACORE_DESCRIPTOR_CLASS_FILTER);
319 S_MATCH_2("AmplitudePlugin", NACORE_DESCRIPTOR_CLASS_DYNAMICS);
320 S_MATCH_1("AmplifierPlugin", NACORE_DESCRIPTOR_CLASS_AMPLIFIER);
321 S_MATCH_1("DistortionPlugin", NACORE_DESCRIPTOR_CLASS_DISTORTION);
322 S_MATCH_1("ModulatorPlugin", NACORE_DESCRIPTOR_CLASS_MODULATOR);
323 S_MATCH_2("DynamicsPlugin", NACORE_DESCRIPTOR_CLASS_DYNAMICS);
324 C_MATCH_1("OscillatorPlugin", NACORE_DESCRIPTOR_CLASS_OSCILLATOR,
325 NACORE_DESCRIPTOR_CLASS_GENERATOR);
326 C_MATCH_1("PhaserPlugin", NACORE_DESCRIPTOR_CLASS_PHASER,
327 NACORE_DESCRIPTOR_CLASS_MODULATOR);
328 C_MATCH_1("FlangerPlugin", NACORE_DESCRIPTOR_CLASS_FLANGER,
329 NACORE_DESCRIPTOR_CLASS_MODULATOR);
330 C_MATCH_1("ChorusPlugin", NACORE_DESCRIPTOR_CLASS_CHORUS,
331 NACORE_DESCRIPTOR_CLASS_MODULATOR);
332 C_MATCH_1("ReverbPlugin", NACORE_DESCRIPTOR_CLASS_REVERB,
333 NACORE_DESCRIPTOR_CLASS_SIMULATOR
334 | NACORE_DESCRIPTOR_CLASS_DELAY);
335 C_MATCH_1("FrequencyMeterPlugin", NACORE_DESCRIPTOR_CLASS_SPECTRAL
336 | NACORE_DESCRIPTOR_CLASS_ANALYSER,
337 NACORE_DESCRIPTOR_CLASS_UTILITY);
338 C_MATCH_1("LowpassPlugin", NACORE_DESCRIPTOR_CLASS_LOWPASS,
339 NACORE_DESCRIPTOR_CLASS_FILTER);
340 C_MATCH_1("HighpassPlugin", NACORE_DESCRIPTOR_CLASS_HIGHPASS,
341 NACORE_DESCRIPTOR_CLASS_FILTER);
342 C_MATCH_1("BandpassPlugin", NACORE_DESCRIPTOR_CLASS_BANDPASS,
343 NACORE_DESCRIPTOR_CLASS_FILTER);
344 C_MATCH_1("CombPlugin", NACORE_DESCRIPTOR_CLASS_COMB,
345 NACORE_DESCRIPTOR_CLASS_FILTER);
346 C_MATCH_1("AllpassPlugin", NACORE_DESCRIPTOR_CLASS_ALLPASS,
347 NACORE_DESCRIPTOR_CLASS_FILTER);
348 C_MATCH_1("EQPlugin", NACORE_DESCRIPTOR_CLASS_EQ,
349 NACORE_DESCRIPTOR_CLASS_FILTER);
350 C_MATCH_1("ParaEQPlugin", NACORE_DESCRIPTOR_CLASS_PARAEQ,
351 NACORE_DESCRIPTOR_CLASS_FILTER
352 | NACORE_DESCRIPTOR_CLASS_EQ);
353 C_MATCH_1("MultiEQPlugin", NACORE_DESCRIPTOR_CLASS_MULTIEQ,
354 NACORE_DESCRIPTOR_CLASS_FILTER
355 | NACORE_DESCRIPTOR_CLASS_EQ);
356 C_MATCH_1("PitchPlugin", NACORE_DESCRIPTOR_CLASS_PITCH,
357 NACORE_DESCRIPTOR_CLASS_SPECTRAL);
358 C_MATCH_1("WaveshaperPlugin", NACORE_DESCRIPTOR_CLASS_WAVESHAPER,
359 NACORE_DESCRIPTOR_CLASS_DISTORTION);
360 C_MATCH_2("CompressorPlugin", NACORE_DESCRIPTOR_CLASS_COMPRESSOR,
361 NACORE_DESCRIPTOR_CLASS_DYNAMICS);
362 C_MATCH_2("ExpanderPlugin", NACORE_DESCRIPTOR_CLASS_EXPANDER,
363 NACORE_DESCRIPTOR_CLASS_DYNAMICS);
364 C_MATCH_2("LimiterPlugin", NACORE_DESCRIPTOR_CLASS_LIMITER,
365 NACORE_DESCRIPTOR_CLASS_DYNAMICS);
366 C_MATCH_2("GatePlugin", NACORE_DESCRIPTOR_CLASS_GATE,
367 NACORE_DESCRIPTOR_CLASS_DYNAMICS);
369 desc->classes_1 = classes_1;
370 desc->classes_2 = classes_2;
371 }
373 void
374 _naladspa_lrdf_get_scale_defaults(struct nacore_descriptor *desc,
375 struct nacore_port_descriptor *port_descs)
376 {
377 LADSPA_Descriptor *ldesc;
378 librdf_node *setting_node;
379 librdf_node *setting_node2;
380 librdf_node *default_node;
381 librdf_node *port_value_node;
382 librdf_node *port_value_node2;
383 librdf_node *port_value_node3;
384 librdf_stream *stream;
385 librdf_stream *stream2;
386 char subject[strlen(LADSPA_PREFIX) + 9];
387 float value;
388 unsigned long index;
389 char *prev_locale;
391 if (model == NULL)
392 return;
394 prev_locale = setlocale(LC_NUMERIC, NULL);
395 setlocale(LC_NUMERIC, "C");
397 ldesc = (LADSPA_Descriptor *)desc->data;
399 sprintf(subject, "%s%lu", LADSPA_PREFIX, ldesc->UniqueID);
401 stream = model_find_statements(subject, LADSPA_PREFIX "hasSetting",
402 NULL);
403 if (stream == NULL)
404 goto end;
406 default_node = NULL;
407 while (!librdf_stream_end(stream))
408 {
409 setting_node = librdf_statement_get_object(
410 librdf_stream_get_object(stream));
411 setting_node2 = librdf_new_node_from_node(setting_node);
413 if (model_contains_statement_with_subject_node(setting_node2,
414 RDF_PREFIX "type", LADSPA_PREFIX "Default"))
415 {
416 default_node = librdf_new_node_from_node(setting_node);
417 break;
418 }
420 librdf_stream_next(stream);
421 }
422 librdf_free_stream(stream);
424 if (default_node == NULL)
425 goto end;
427 stream = model_find_statements_with_subject_node(default_node,
428 LADSPA_PREFIX "hasPortValue", NULL);
429 if (stream == NULL)
430 goto end;
432 while (!librdf_stream_end(stream))
433 {
434 port_value_node = librdf_statement_get_object(
435 librdf_stream_get_object(stream));
436 port_value_node2 = librdf_new_node_from_node(port_value_node);
437 port_value_node3 = librdf_new_node_from_node(port_value_node);
439 stream2 = model_find_statements_with_subject_node(
440 port_value_node2, RDF_PREFIX "value", NULL);
441 if (stream2 == NULL)
442 break;
444 if (librdf_stream_end(stream2))
445 {
446 librdf_free_stream(stream2);
447 break;
448 }
449 value = atof((char *)
450 librdf_node_get_literal_value(
451 librdf_statement_get_object(
452 librdf_stream_get_object(stream2))));
454 librdf_free_stream(stream2);
456 stream2 = model_find_statements_with_subject_node(
457 port_value_node3, LADSPA_PREFIX "forPort",
458 NULL);
459 if (stream2 == NULL)
460 break;
462 if (librdf_stream_end(stream2))
463 {
464 librdf_free_stream(stream2);
465 break;
466 }
468 index = strtoul(
469 strrchr((char *)
470 librdf_uri_as_string(
471 librdf_node_get_uri(
472 librdf_statement_get_object(
473 librdf_stream_get_object(stream2)))),
474 '.') + 1,
475 NULL, 10);
477 librdf_free_stream(stream2);
479 if (index < desc->port_descs_count)
480 {
481 port_descs[index].scale.properties |=
482 NACORE_SCALE_HAS_DEFAULT;
483 port_descs[index].scale.defaultv = value;
484 }
486 librdf_stream_next(stream);
487 }
488 librdf_free_stream(stream);
490 end:
491 setlocale(LC_NUMERIC, prev_locale);
492 }
494 void
495 _naladspa_lrdf_get_scale_points(struct nacore_descriptor *desc,
496 struct nacore_port_descriptor *port,
497 size_t index)
498 {
499 LADSPA_Descriptor *ldesc;
500 librdf_stream *stream;
501 librdf_stream *stream2;
502 librdf_stream *stream3;
503 librdf_node *scale_node;
504 librdf_node *scale_node2;
505 librdf_node *point_node;
506 librdf_node *point_node2;
507 char subject[strlen(LADSPA_PREFIX) + 20];
508 char *label, *p;
509 size_t len, count, i;
510 char *prev_locale;
512 if (model == NULL)
513 return;
515 prev_locale = setlocale(LC_NUMERIC, NULL);
516 setlocale(LC_NUMERIC, "C");
518 ldesc = (LADSPA_Descriptor *)desc->data;
520 sprintf(subject, "%s%lu.%lu", LADSPA_PREFIX, ldesc->UniqueID,
521 (unsigned long)index);
523 stream = model_find_statements(subject, LADSPA_PREFIX "hasScale", NULL);
524 if (stream == NULL)
525 goto stream_err;
527 if (librdf_stream_end(stream))
528 goto stream_end;
530 scale_node = librdf_statement_get_object(
531 librdf_stream_get_object(stream));
532 scale_node2 = librdf_new_node_from_node(scale_node);
533 if (scale_node2 == NULL)
534 goto stream_end;
536 stream2 = model_find_statements_with_subject_node(scale_node2,
537 LADSPA_PREFIX "hasPoint", NULL);
538 if (stream2 == NULL)
539 {
540 librdf_free_node(scale_node2);
541 goto stream_end;
542 }
544 count = 0;
545 len = 0;
546 while (!librdf_stream_end(stream2))
547 {
548 point_node = librdf_statement_get_object(
549 librdf_stream_get_object(stream2));
550 point_node2 = librdf_new_node_from_node(point_node);
552 stream3 = model_find_statements_with_subject_node(
553 point_node2, LADSPA_PREFIX "hasLabel", NULL);
554 if (stream3 == NULL)
555 {
556 librdf_free_stream(stream2);
557 goto stream_end;
558 }
560 if (librdf_stream_end(stream3))
561 {
562 librdf_free_stream(stream3);
563 librdf_free_stream(stream2);
564 goto stream_end;
565 }
567 label = (char *)
568 librdf_node_get_literal_value(
569 librdf_statement_get_object(
570 librdf_stream_get_object(stream3)));
572 len += strlen(label) + 1;
573 count++;
575 librdf_free_stream(stream3);
577 librdf_stream_next(stream2);
578 }
579 librdf_free_stream(stream2);
581 if (count == 0)
582 goto stream_end;
584 port->data = malloc(len);
585 if (port->data == NULL)
586 goto stream_end;
588 port->scale.points = malloc(count * sizeof(struct nacore_scale_point));
589 if (port->scale.points == NULL)
590 {
591 free(port->data);
592 port->data = NULL;
593 goto stream_end;
594 }
596 scale_node2 = librdf_new_node_from_node(scale_node);
597 if (scale_node2 == NULL)
598 {
599 free(port->data);
600 port->data = NULL;
601 free(port->scale.points);
602 port->scale.points = NULL;
603 goto stream_end;
604 }
606 stream2 = model_find_statements_with_subject_node(scale_node2,
607 LADSPA_PREFIX "hasPoint", NULL);
608 if (stream2 == NULL)
609 {
610 free(port->data);
611 port->data = NULL;
612 free(port->scale.points);
613 port->scale.points = NULL;
614 goto stream_end;
615 }
617 i = 0;
618 p = (char *)port->data;
619 while (!librdf_stream_end(stream2))
620 {
621 point_node = librdf_statement_get_object(
622 librdf_stream_get_object(stream2));
623 point_node2 = librdf_new_node_from_node(point_node);
625 stream3 = model_find_statements_with_subject_node(
626 point_node2, LADSPA_PREFIX "hasLabel", NULL);
627 if (stream3 == NULL)
628 {
629 librdf_free_stream(stream2);
630 free(port->data);
631 port->data = NULL;
632 free(port->scale.points);
633 port->scale.points = NULL;
634 goto stream_end;
635 }
637 if (librdf_stream_end(stream3))
638 {
639 librdf_free_stream(stream3);
640 librdf_free_stream(stream2);
641 free(port->data);
642 port->data = NULL;
643 free(port->scale.points);
644 port->scale.points = NULL;
645 goto stream_end;
646 }
648 label = (char *)
649 librdf_node_get_literal_value(
650 librdf_statement_get_object(
651 librdf_stream_get_object(stream3)));
653 port->scale.points[i].label = p;
655 strcpy(p, label);
656 p += strlen(p) + 1;
658 librdf_free_stream(stream3);
660 point_node2 = librdf_new_node_from_node(point_node);
662 stream3 = model_find_statements_with_subject_node(
663 point_node2, RDF_PREFIX "value", NULL);
664 if (stream3 == NULL)
665 {
666 librdf_free_stream(stream2);
667 free(port->data);
668 port->data = NULL;
669 free(port->scale.points);
670 port->scale.points = NULL;
671 goto stream_end;
672 }
674 if (librdf_stream_end(stream3))
675 {
676 librdf_free_stream(stream3);
677 librdf_free_stream(stream2);
678 free(port->data);
679 port->data = NULL;
680 free(port->scale.points);
681 port->scale.points = NULL;
682 goto stream_end;
683 }
685 port->scale.points[i].value = atof((char *)
686 librdf_node_get_literal_value(
687 librdf_statement_get_object(
688 librdf_stream_get_object(stream3))));
690 librdf_free_stream(stream3);
692 i++;
694 librdf_stream_next(stream2);
695 }
696 librdf_free_stream(stream2);
698 port->scale.points_count = count;
700 stream_end:
701 librdf_free_stream(stream);
702 stream_err:
703 setlocale(LC_NUMERIC, prev_locale);
704 }
706 #define MATCH_UNIT(s, u) \
707 if (!strcmp(value, LADSPA_PREFIX s)) \
708 { \
709 port->scale.unit = u; \
710 librdf_free_stream(stream); \
711 return; \
712 }
714 void
715 _naladspa_lrdf_get_scale_units(struct nacore_descriptor *desc,
716 struct nacore_port_descriptor *port,
717 size_t index)
718 {
719 LADSPA_Descriptor *ldesc;
720 librdf_stream *stream;
721 char subject[strlen(LADSPA_PREFIX) + 20];
722 char *value;
724 port->scale.unit = nacore_scale_unit_none;
726 if (model == NULL)
727 return;
729 ldesc = (LADSPA_Descriptor *)desc->data;
731 sprintf(subject, "%s%lu.%lu", LADSPA_PREFIX, ldesc->UniqueID,
732 (unsigned long)index);
734 stream = model_find_statements(subject, LADSPA_PREFIX "hasUnit", NULL);
735 if (stream == NULL)
736 return;
738 if (librdf_stream_end(stream))
739 {
740 librdf_free_stream(stream);
741 return;
742 }
744 value = (char *)librdf_node_get_literal_value(
745 librdf_statement_get_object(
746 librdf_stream_get_object(stream)));
748 MATCH_UNIT("dB", nacore_scale_unit_db);
749 MATCH_UNIT("coef", nacore_scale_unit_coeff);
750 MATCH_UNIT("Hz", nacore_scale_unit_hz);
751 MATCH_UNIT("seconds", nacore_scale_unit_s);
752 MATCH_UNIT("milliseconds", nacore_scale_unit_ms);
753 MATCH_UNIT("minutes", nacore_scale_unit_m);
755 librdf_free_stream(stream);
756 }
758 void
759 _naladspa_lrdf_free_data(struct nacore_port_descriptor *port)
760 {
761 if (port->scale.points != NULL)
762 free(port->scale.points);
763 if (port->data != NULL)
764 free(port->data);
765 }