]> git.sesse.net Git - mlt/commitdiff
Add support for sox.effect variants.
authorDan Dennedy <dan@dennedy.org>
Mon, 9 May 2011 00:59:30 +0000 (17:59 -0700)
committerDan Dennedy <dan@dennedy.org>
Mon, 9 May 2011 00:59:30 +0000 (17:59 -0700)
The legacy forms of 'sox:"effect options"' and 'sox effect="name
options"' still work. The new forms allows them all to be enumerated by
Mlt apps, e.g.: melt -query filter. Also, this registers metadata for
both the generic 'sox' filter and all of the new 'sox.effect' ones
including their usage help!

src/modules/sox/Makefile
src/modules/sox/factory.c
src/modules/sox/filter_sox.c
src/modules/sox/filter_sox.yml [new file with mode: 0644]

index 654af4d52ed19adee90c1467aa3dd402757070df..d6ac591c0f03b2ceb21e77b8cf58a206c73972fc 100644 (file)
@@ -29,6 +29,12 @@ clean:
 
 install: all
        install -m 755 $(TARGET) "$(DESTDIR)$(libdir)/mlt"
+       install -d "$(DESTDIR)$(datadir)/mlt/sox"
+       install -m 644 filter_sox.yml "$(DESTDIR)$(datadir)/mlt/sox"
+
+uninstall:
+       rm "$(DESTDIR)$(libdir)/mlt/libmltsox$(LIBSUF)" 2> /dev/null || true
+       rm -rf "$(DESTDIR)$(datadir)/mlt/sox"
 
 ifneq ($(wildcard .depend),)
 include .depend
index 048d3bc500ea08256a7846d6e7c933f204e32968..620c2307cdfe6d4119b663c78bfa7fa4f77caf79 100644 (file)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include <string.h>
 #include <framework/mlt.h>
 
+#include <string.h>
+#include <limits.h>
+#ifdef SOX14
+#include <sox.h>
+#endif
+
 extern mlt_filter filter_sox_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 ];
+       const char *service_type = NULL;
+       mlt_properties result = NULL;
+
+       // Convert the service type to a string.
+       switch ( type )
+       {
+               case consumer_type:
+                       service_type = "consumer";
+                       break;
+               case filter_type:
+                       service_type = "filter";
+                       break;
+               case producer_type:
+                       service_type = "producer";
+                       break;
+               case transition_type:
+                       service_type = "transition";
+                       break;
+               default:
+                       return NULL;
+       }
+       // Load the yaml file
+       snprintf( file, PATH_MAX, "%s/sox/%s_%s.yml", mlt_environment( "MLT_DATA" ), service_type, "sox" );
+       result = mlt_properties_parse_yaml( file );
+
+#ifdef SOX14
+       if ( result && ( type == filter_type ) )
+       {
+               // Annotate the yaml properties with sox effect usage.
+               mlt_properties params = mlt_properties_get_data( result, "parameters", NULL );
+               const sox_effect_handler_t *e;
+               int i;
+
+               for ( i = 0; sox_effect_fns[i]; i++ )
+               {
+                       e = sox_effect_fns[i]();
+                       if ( e && e->name && !strcmp( e->name, id + 4 ) )
+                       {
+                               mlt_properties p = mlt_properties_get_data( params, "0", NULL );
+
+                               mlt_properties_set( result, "identifier", e->name );
+                               mlt_properties_set( result, "title", e->name );
+                               mlt_properties_set( p, "type", "string" );
+                               mlt_properties_set( p, "title", "Options" );
+                               if ( e->usage )
+                                       mlt_properties_set( p, "format", e->usage );
+                       }
+               }
+       }
+#endif
+       return result;
+}
+
 MLT_REPOSITORY
 {
        MLT_REGISTER( filter_type, "sox", filter_sox_init );
+       MLT_REGISTER_METADATA( filter_type, "sox", metadata, NULL );
+#ifdef SOX14
+       int i;
+       const sox_effect_handler_t *e;
+       char name[64] = "sox.";
+       for ( i = 0; sox_effect_fns[i]; i++ )
+       {
+               e = sox_effect_fns[i]();
+               if ( e && e->name && !( e->flags & SOX_EFF_DEPRECATED ) && !( e->flags & SOX_EFF_INTERNAL ) )
+               {
+                       strcpy( name + 4, e->name );
+                       MLT_REGISTER( filter_type, name, filter_sox_init );
+                       MLT_REGISTER_METADATA( filter_type, name, metadata, NULL );
+               }
+       }
+#endif
 }
index 483e0f5852d5dacbaa962f41c9ae5d3e69b3809d..67e81b5725635d40fa0e96ab58f2e10581cc1593 100644 (file)
@@ -413,7 +413,19 @@ mlt_filter filter_sox_init( mlt_profile profile, mlt_service_type type, const ch
                
                this->process = filter_process;
                
-               if ( arg != NULL )
+               if ( !strncmp( id, "sox.", 4 ) )
+               {
+                       char *s = malloc( strlen( id ) + ( arg? strlen( arg ) + 2 : 1 ) );
+                       strcpy( s, id + 4 );
+                       if ( arg )
+                       {
+                               strcat( s, " " );
+                               strcat( s, arg );
+                       }
+                       mlt_properties_set( properties, "effect", s );
+                       free( s );
+               }
+               else if ( arg )
                        mlt_properties_set( properties, "effect", arg );
                mlt_properties_set_data( properties, "input_buffer", input_buffer, BUFFER_LEN, mlt_pool_release, NULL );
                mlt_properties_set_data( properties, "output_buffer", output_buffer, BUFFER_LEN, mlt_pool_release, NULL );
diff --git a/src/modules/sox/filter_sox.yml b/src/modules/sox/filter_sox.yml
new file mode 100644 (file)
index 0000000..180808d
--- /dev/null
@@ -0,0 +1,22 @@
+schema_version: 0.1
+type: filter
+identifier: sox
+title: sox
+version: 1
+copyright: Copyright (C) 2003-2011 Ushodaya Enterprises Limited
+license: LGPL
+language: en
+url: http://sox.sourceforge.net/
+creator: Dan Dennedy
+tags:
+  - Audio
+description: Process audio using a SoX effect.
+bugs:
+  - Some effects are stereo only, but MLT processes each channel separately.
+  - Some effects have a temporal side-effect that do not work well.
+
+parameters:
+  - identifier: argument
+    title: Effect name and options
+    type: string
+    format: effect [options]