]> git.sesse.net Git - mlt/commitdiff
Add service metadata for jackrack, ladspa, and ladspa.id.
authorDan Dennedy <dan@dennedy.org>
Wed, 11 May 2011 04:28:08 +0000 (21:28 -0700)
committerDan Dennedy <dan@dennedy.org>
Wed, 11 May 2011 04:28:08 +0000 (21:28 -0700)
src/modules/jackrack/Makefile
src/modules/jackrack/factory.c
src/modules/jackrack/filter_jackrack.yml [new file with mode: 0644]
src/modules/jackrack/filter_ladspa.yml [new file with mode: 0644]

index 2d2a8563b1f351a7ed9f98df6fce5e4ed0a7a976..ebc5ab4110d30ad1ed5bf3022e1756c5f93c2685 100644 (file)
@@ -44,6 +44,13 @@ clean:
 
 install: all
        install -m 755 $(TARGET) "$(DESTDIR)$(libdir)/mlt"
+       install -d "$(DESTDIR)$(datadir)/mlt/jackrack"
+       install -m 644 filter_jackrack.yml "$(DESTDIR)$(datadir)/mlt/jackrack"
+       install -m 644 filter_ladspa.yml "$(DESTDIR)$(datadir)/mlt/jackrack"
+
+uninstall:
+       rm "$(DESTDIR)$(libdir)/mlt/libmltjackrack$(LIBSUF)" 2> /dev/null || true
+       rm -rf "$(DESTDIR)$(datadir)/mlt/jackrack"
 
 ifneq ($(wildcard .depend),)
 include .depend
index 1476b153d27beb7c125cde02eb6f2e1cd43cffaa..599d020d01c944c8ef52a5dc34c084761301d8a8 100644 (file)
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
-#include <string.h>
 #include <framework/mlt.h>
+#include <ladspa.h>
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <float.h>
+
+#include "plugin_mgr.h"
 
 extern mlt_filter filter_jackrack_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg );
 extern mlt_filter filter_ladspa_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg );
 
+static mlt_properties metadata( mlt_service_type type, const char *id, void *data )
+{
+       char file[ PATH_MAX ];
+       snprintf( file, PATH_MAX, "%s/jackrack/filter_%s.yml",
+               mlt_environment( "MLT_DATA" ), strncmp( id, "ladspa.", 7 ) ? id : "ladspa" );
+       mlt_properties result = mlt_properties_parse_yaml( file );
+
+       if ( !strncmp( id, "ladspa.", 7 ) )
+       {
+               // Annotate the yaml properties with ladspa control port info.
+               plugin_mgr_t *mgr = plugin_mgr_new();
+               plugin_desc_t *desc = plugin_mgr_get_any_desc( mgr, strtol( id + 7, NULL, 10 ) );
+
+               if ( desc )
+               {
+                       mlt_properties params = mlt_properties_new();
+                       mlt_properties p;
+                       char key[20];
+                       int i;
+
+                       mlt_properties_set( result, "identifier", id );
+                       mlt_properties_set( result, "title", desc->name );
+                       mlt_properties_set_data( result, "parameters", params, 0, (mlt_destructor) mlt_properties_close, NULL );
+                       for ( i = 0; i < desc->control_port_count; i++ )
+                       {
+                               int j = desc->control_port_indicies[i];
+                               LADSPA_Data sample_rate = 48000;
+                               LADSPA_PortRangeHintDescriptor hint_descriptor = desc->port_range_hints[j].HintDescriptor;
+
+                               p = mlt_properties_new();
+                               snprintf( key, sizeof(key), "%d", i );
+                               mlt_properties_set_data( params, key, p, 0, (mlt_destructor) mlt_properties_close, NULL );
+                               snprintf( key, sizeof(key), "%d", j );
+                               mlt_properties_set( p, "identifier", key );
+                               mlt_properties_set( p, "title", desc->port_names[ j ] );
+                               if ( LADSPA_IS_HINT_INTEGER( hint_descriptor ) )
+                               {
+                                       mlt_properties_set( p, "type", "integer" );
+                                       mlt_properties_set_int( p, "default", plugin_desc_get_default_control_value( desc, j, sample_rate ) );
+                               }
+                               else if ( LADSPA_IS_HINT_TOGGLED( hint_descriptor ) )
+                               {
+                                       mlt_properties_set( p, "type", "boolean" );
+                                       mlt_properties_set_int( p, "default", plugin_desc_get_default_control_value( desc, j, sample_rate ) );
+                               }
+                               else
+                               {
+                                       mlt_properties_set( p, "type", "float" );
+                                       mlt_properties_set_double( p, "default", plugin_desc_get_default_control_value( desc, j, sample_rate ) );
+                               }
+                               /* set upper and lower, possibly adjusted to the sample rate */
+                               if ( LADSPA_IS_HINT_BOUNDED_BELOW( hint_descriptor ) )
+                               {
+                                       LADSPA_Data lower = desc->port_range_hints[j].LowerBound;
+                                       if ( LADSPA_IS_HINT_SAMPLE_RATE( hint_descriptor ) )
+                                               lower *= sample_rate;
+                                       if ( LADSPA_IS_HINT_LOGARITHMIC( hint_descriptor ) )
+                                       {
+                                               if (lower < FLT_EPSILON)
+                                                       lower = FLT_EPSILON;
+                                       }
+                                       mlt_properties_set_double( p, "minimum", lower );
+                               }
+                               if ( LADSPA_IS_HINT_BOUNDED_ABOVE( hint_descriptor ) )
+                               {
+                                       LADSPA_Data upper = desc->port_range_hints[j].UpperBound;
+                                       if ( LADSPA_IS_HINT_SAMPLE_RATE( hint_descriptor ) )
+                                               upper *= sample_rate;
+                                       mlt_properties_set_double( p, "maximum", upper );
+                               }
+                               if ( LADSPA_IS_HINT_LOGARITHMIC( hint_descriptor ) )
+                                       mlt_properties_set( p, "scale", "log" );
+                       }
+                       p = mlt_properties_new();
+                       snprintf( key, sizeof(key), "%d", i );
+                       mlt_properties_set_data( params, key, p, 0, (mlt_destructor) mlt_properties_close, NULL );
+                       mlt_properties_set( p, "identifier", "wetness" );
+                       mlt_properties_set( p, "title", "Wet/Dry" );
+                       mlt_properties_set( p, "type", "float" );
+                       mlt_properties_set_double( p, "default", 1 );
+                       mlt_properties_set_double( p, "minimum", 0 );
+                       mlt_properties_set_double( p, "maximum", 1 );
+               }
+               plugin_mgr_destroy( mgr );
+       }
+
+       return result;
+}
+
 MLT_REPOSITORY
 {
+       plugin_mgr_t *mgr = plugin_mgr_new();
+       GSList *list;
+
+       for ( list = mgr->all_plugins; list; list = g_slist_next( list ) )
+       {
+               plugin_desc_t *desc = (plugin_desc_t *) list->data;
+               char *s = malloc( strlen( "ladpsa." ) + 21 );
+
+               sprintf( s, "ladspa.%lu", desc->id );
+               MLT_REGISTER( filter_type, s, filter_ladspa_init );
+               MLT_REGISTER_METADATA( filter_type, s, metadata, NULL );
+       }
+       plugin_mgr_destroy( mgr );
+
        MLT_REGISTER( filter_type, "jackrack", filter_jackrack_init );
+       MLT_REGISTER_METADATA( filter_type, "jackrack", metadata, NULL );
        MLT_REGISTER( filter_type, "ladspa", filter_ladspa_init );
+       MLT_REGISTER_METADATA( filter_type, "ladspa", metadata, NULL );
 }
diff --git a/src/modules/jackrack/filter_jackrack.yml b/src/modules/jackrack/filter_jackrack.yml
new file mode 100644 (file)
index 0000000..d8877c1
--- /dev/null
@@ -0,0 +1,57 @@
+schema_version: 0.1
+type: filter
+identifier: jackrack
+title: JACK
+version: 1
+copyright: Copyright (C) 2004-2011 Ushodaya Enterprises Limited
+license: GPLv2
+language: en
+url: http://www.ladspa.org/
+creator: Dan Dennedy
+tags:
+  - Audio
+description: Process audio using JACK.
+notes: >
+  This can be used to receive audio from JACK by connecting only input ports.
+  It can be used to output audio to JACK by connecting only the output ports.
+  Or, you can use it as a filter with something like JACK Rack by connecting
+  both output and input ports to send and receive.
+  You can configure as many channels as you need and repeat the in_1/out_1
+  pattern for as many channels as you have configured.
+  If you are using a MLT consumer that uses ALSA, then you should start
+  jackd with the dummy driver, e.g.: jackd -ddummy -r48000 -p2048.
+  The MLT JACK client name uses the format: mlt{pid}.
+bugs:
+  - >
+    MLT cannot automatically adapt to the sample rate at which JACK is configured.
+    Please make sure they are configured the same.
+  - Does not automatically reconfigure to the number of channels requested by consumer.
+  - Some effects have a temporal side-effect that may not work well.
+
+parameters:
+  - identifier: argument
+    title: JACK Rack file
+    type: string
+    description: >
+      Creates JACK ports and runs a JACK Rack project to process audio
+      through a stack of LADSPA filters.
+  - identifier: src
+    title: JACK Rack file
+    type: string
+  - identifier: channels
+    title: Channels
+    type: integer
+    minimum: 1
+    default: 2
+  - identifier: in_1
+    title: Receive L
+    type: string
+  - identifier: in_2
+    title: Receive R
+    type: string
+  - identifier: out_1
+    title: Send L
+    type: string
+  - identifier: out_2
+    title: Send R
+    type: string
diff --git a/src/modules/jackrack/filter_ladspa.yml b/src/modules/jackrack/filter_ladspa.yml
new file mode 100644 (file)
index 0000000..7792eeb
--- /dev/null
@@ -0,0 +1,28 @@
+schema_version: 0.1
+type: filter
+identifier: ladspa
+title: LADSPA
+version: 1
+copyright: Copyright (C) 2004-2011 Ushodaya Enterprises Limited
+license: GPLv2
+language: en
+url: http://www.ladspa.org/
+creator: Dan Dennedy
+tags:
+  - Audio
+description: Process audio using LADSPA plugins.
+notes: >
+  Automatically adapts to the number of channels and sampling rate of the consumer.
+bugs:
+  - Some effects have a temporal side-effect that may not work well.
+
+parameters:
+  - identifier: argument
+    title: JACK Rack XML file
+    type: string
+    description: >
+      Runs a JACK Rack project to process audio through a stack of
+      LADSPA filters without using JACK.
+  - identifier: resource
+    title: JACK Rack XML file
+    type: string