Updated README for veejay-ng , autogenerate FX controls for Khagan (OSC live user interface builder) , range check in HOST_parameter_func, minor modifications

git-svn-id: svn://code.dyne.org/veejay/trunk@594 eb8d1916-c9e9-0310-b8de-cf0c9472ead5
This commit is contained in:
Niels Elburg
2006-09-03 17:43:57 +00:00
parent 9ad76c67d9
commit 698d5aaf4a
8 changed files with 471 additions and 45 deletions

View File

@@ -26,14 +26,65 @@
Install Install
======= =======
See file 'INSTALL' 0. get required packages
1. autogen.sh
2. configure
3. make
4. make install
Running Running
======= =======
- Start veejay with a video template and open filename.avi as a new sample
veejay -w <width> \
-h <height> \
-fps <frames p. sec> \
-P [0=yuv420,1=yuv422,2=yuv444] \
-d [0=none,1=sdl,2=opengl] \
filename.avi
veejay -w352 -h288 -f25 -P2 -d2 movie.avi
Start veejay with all capture devices loaded as new samples
veejay -w352 -h288 -f25 -P2 -d2 -A
Controling
==========
All communication goes via OSC (Open Sound Control).
sayOSC localhost 3490 0 /sample_1/print
Example FX
==========
For this to work, you need to grab pluginpack from the repository
and edit the ~.veejay/plugins file to include the path to the installed
plugins
sayOSC localhost 3490 s /sample_1/fx_0/set LVDPhotoplay
sayOSC localhost 3490 i /sample_1/fx_0/fx_status 1
If you need a GUI, you can use Khagan
http://khagan.berlios.de/
Veejay dumps .kh files in the directory where you started it.
$ sayOSC localhost 3490 /sample_1/khagan
$ khagan
File -> Open -> sample_1.kh
Otherwise,
See the updated namespace:
sayOSC localhost 3490 0 /sample_1/print
sayOSC localhost 3490 i /sample_1/fx_0/photoplay/square_size 23
CONTACT / FEEDBACK & HELP CONTACT / FEEDBACK & HELP

View File

@@ -166,32 +166,114 @@ static int configure_channel( void *instance, const char *name, int channel_id,
void livido_plug_parameter_set_text( void *parameter, void *value ) void livido_plug_parameter_set_text( void *parameter, void *value )
{ {
veejay_msg(0,"%s: value = '%s'", __FUNCTION__, *((char*) value )); veejay_msg(0,"%s: value = '%s'", __FUNCTION__, *((char*) value ));
vevo_property_set( parameter, "value", LIVIDO_ATOM_TYPE_STRING, 1, value ); char *new_val = *( (char*) value );
int len = (new_val == NULL ? 0 : strlen( new_val ));
if( len > 0 )
{
int error = vevo_property_set( parameter, "value", LIVIDO_ATOM_TYPE_STRING, 1, value );
#ifdef STRICT_CHECKING
assert( error == VEVO_NO_ERROR );
#endif
}
} }
void livido_plug_parameter_set_number( void *parameter, void *value ) void livido_plug_parameter_set_number( void *parameter, void *value )
{ {
veejay_msg(0,"%s: value = '%g'", __FUNCTION__, (double) *((double*) value )); double range[2];
vevo_property_set( parameter, "value", LIVIDO_ATOM_TYPE_DOUBLE, 1, value ); void *templ = NULL;
int error = vevo_property_get( parameter, "parent_template",0, &templ );
#ifdef STRICT_CHECKING
assert( error == VEVO_NO_ERROR );
#endif
error = vevo_property_get( templ, "min", 0 , &(range[0]) );
#ifdef STRICT_CHECKING
assert( error == VEVO_NO_ERROR );
#endif
error = vevo_property_get( templ, "max", 0, &(range[1]) );
#ifdef STRICT_CHECKING
assert( error == VEVO_NO_ERROR );
#endif
double new_val = *((double*) value);
if( new_val >= range[0] && new_val <= range[1] )
{
error = vevo_property_set( parameter, "value", VEVO_ATOM_TYPE_DOUBLE, 1, value );
#ifdef STRICT_CHECKING
assert( error == VEVO_NO_ERROR );
#endif
}
else
{
char *name = get_str_vevo(templ, "name");
veejay_msg(0, "Parameter '%s' value %g out of range %g - %g", name,new_val, range[0],range[1]);
free(name);
}
} }
void livido_plug_parameter_set_index( void *parameter, void *value) void livido_plug_parameter_set_index( void *parameter, void *value)
{ {
veejay_msg(0,"%s: value = '%d'", __FUNCTION__, *((int*) value )); int range[2];
vevo_property_set( parameter, "value", VEVO_ATOM_TYPE_INT, 1, value ); void *templ = NULL;
int error = vevo_property_get( parameter, "parent_template",0, &templ );
#ifdef STRICT_CHECKING
assert( error == VEVO_NO_ERROR );
#endif
error = vevo_property_get( templ, "min", 0 , &(range[0]) );
#ifdef STRICT_CHECKING
assert( error == VEVO_NO_ERROR );
#endif
error = vevo_property_get( templ, "max", 0, &(range[1]) );
#ifdef STRICT_CHECKING
assert( error == VEVO_NO_ERROR );
#endif
int new_val = *((int*) value);
if( new_val >= range[0] && new_val <= range[1] )
{
error = vevo_property_set( parameter, "value", VEVO_ATOM_TYPE_INT, 1, value );
#ifdef STRICT_CHECKING
assert( error == VEVO_NO_ERROR );
#endif
}
else
{
char *name = get_str_vevo(templ, "name");
veejay_msg(0, "Parameter '%s' value %d out of range %d - %d", name,new_val, range[0],range[1]);
free(name);
}
} }
void livido_plug_parameter_set_bool( void *parameter, void *value ) void livido_plug_parameter_set_bool( void *parameter, void *value )
{ {
veejay_msg(0,"%s: value = '%d'", __FUNCTION__, *((int*) value )); int range[2];
vevo_property_set( parameter, "value", VEVO_ATOM_TYPE_BOOL, 1, value ); void *templ = NULL;
int error;
int new_val = *((int*) value);
if( new_val >= 0 && new_val <= 1 )
{
error = vevo_property_set( parameter, "value", VEVO_ATOM_TYPE_BOOL, 1, value );
#ifdef STRICT_CHECKING
assert( error == VEVO_NO_ERROR );
#endif
}
else
{
int error = vevo_property_get( parameter, "parent_template",0, &templ );
#ifdef STRICT_CHECKING
assert( error == VEVO_NO_ERROR );
#endif
char *name = get_str_vevo(templ, "name");
veejay_msg(0, "Parameter '%s' value %d out of range %d - %d", name,new_val, range[0],range[1]);
free(name);
}
} }
void livido_plug_parameter_set_color( void *parameter,void *value ) void livido_plug_parameter_set_color( void *parameter,void *value )
{ {
veejay_msg(0,"%s: array", __FUNCTION__); veejay_msg(0,"%s: array", __FUNCTION__);
vevo_property_set( parameter, "value", VEVO_ATOM_TYPE_DOUBLE, 4, value ); // vevo_property_set( parameter, "value", VEVO_ATOM_TYPE_DOUBLE, 4, value );
} }
void livido_plug_parameter_set_coord( void *parameter, void *value ) void livido_plug_parameter_set_coord( void *parameter, void *value )
{ {
veejay_msg(0,"%s: array", __FUNCTION__); veejay_msg(0,"%s: array", __FUNCTION__);
vevo_property_set( parameter, "value", LIVIDO_ATOM_TYPE_DOUBLE, 2, value ); // vevo_property_set( parameter, "value", LIVIDO_ATOM_TYPE_DOUBLE, 2, value );
} }
static int livido_pname_to_host_kind( const char *str ) static int livido_pname_to_host_kind( const char *str )
@@ -691,7 +773,17 @@ int livido_plug_build_namespace( void *plugin_template , int entry_id, void *fx_
plugin_new_event( plugin_new_event(
data, osc_namespace, fx_instance, base, param_name, format, NULL, descrip, NULL, entry_id ); data,
osc_namespace,
fx_instance,
base,
param_name,
format,
NULL,
descrip,
NULL,
i,
param_templ );
free(param_name); free(param_name);
free(format); free(format);
@@ -1107,6 +1199,7 @@ void livido_reverse_clone_parameter( void *instance, int seq, void *fx_value_por
{ {
int vj_np = vevo_property_num_elements( instance, "in_parameters" ); int vj_np = vevo_property_num_elements( instance, "in_parameters" );
int i; int i;
for( i = 0; i < vj_np; i ++ ) for( i = 0; i < vj_np; i ++ )
{ {
char vkey[10]; char vkey[10];
@@ -1116,7 +1209,7 @@ void livido_reverse_clone_parameter( void *instance, int seq, void *fx_value_por
assert( error == LIVIDO_NO_ERROR ); assert( error == LIVIDO_NO_ERROR );
#endif #endif
sprintf(vkey, "p%02d", i ); sprintf(vkey, "p%02d", i );
clone_prop_vevo( fx_value_port, param,vkey, "value" ); clone_prop_vevo( param, fx_value_port, vkey, "value" );
} }
} }
@@ -1134,6 +1227,7 @@ void livido_clone_parameter( void *instance, int seq, void *fx_value_port )
#endif #endif
sprintf(vkey, "p%02d", i ); sprintf(vkey, "p%02d", i );
clone_prop_vevo( fx_value_port, param,vkey, "value" ); clone_prop_vevo( fx_value_port, param,vkey, "value" );
// clone_prop_vevo( param, fx_value_port, vkey, "value" );
} }
@@ -1144,6 +1238,7 @@ void livido_set_parameter( void *instance, int seq, void *value )
void *param = NULL; void *param = NULL;
void *param_templ = NULL; void *param_templ = NULL;
int error = vevo_property_get( instance, "in_parameters", seq, &param); int error = vevo_property_get( instance, "in_parameters", seq, &param);
if( error == LIVIDO_NO_ERROR ) if( error == LIVIDO_NO_ERROR )
{ {
livido_set_parameter_f pctrl; livido_set_parameter_f pctrl;
@@ -1151,7 +1246,9 @@ void livido_set_parameter( void *instance, int seq, void *value )
#ifdef STRICT_CHECKING #ifdef STRICT_CHECKING
assert( error == 0 ); assert( error == 0 );
#endif #endif
(*pctrl)( instance, value ); (*pctrl)( param, value );
//@FIXME
} }
} }

View File

@@ -431,7 +431,7 @@ void plug_clone_from_parameters(void *instance, void *fx_values)
#ifdef STRICT_CHECKING #ifdef STRICT_CHECKING
assert( error == VEVO_NO_ERROR ); assert( error == VEVO_NO_ERROR );
#endif #endif
// copy parameters from plugin to fx_values
(*grc)( instance ,0, fx_values ); (*grc)( instance ,0, fx_values );
} }

View File

@@ -109,6 +109,13 @@ sample_video_info_t *veejay_get_ps(void *data)
veejay_t *v = (veejay_t*) data; veejay_t *v = (veejay_t*) data;
return v->video_info; return v->video_info;
} }
int veejay_get_port(void *data)
{
veejay_t *v = (veejay_t*) data;
return v->port_offset;
}
int veejay_osc_verify_format( void *vevo_port, char const *types ) int veejay_osc_verify_format( void *vevo_port, char const *types )
{ {
char *format = get_str_vevo( vevo_port, "format" ); char *format = get_str_vevo( vevo_port, "format" );

View File

@@ -462,6 +462,12 @@ void osc_sample_print( void *sample,const char *path, const char *types, void *
} }
void osc_sample_khagan( void *sample,const char *path, const char *types, void **dargv)
{
sample_produce_khagan_file( sample );
}
static struct static struct
{ {
const char *name; const char *name;
@@ -512,6 +518,7 @@ static struct
{ "rec/stop", NULL, { NULL,NULL,NULL,NULL },"Stop recording from sample", { "rec/stop", NULL, { NULL,NULL,NULL,NULL },"Stop recording from sample",
osc_sample_record_stop }, osc_sample_record_stop },
{ "print", NULL, { NULL,NULL,NULL,NULL },"Print OSC namespace", osc_sample_print }, { "print", NULL, { NULL,NULL,NULL,NULL },"Print OSC namespace", osc_sample_print },
{ "khagan", NULL, { NULL,NULL,NULL,NULL },"Write XML file for khagan", osc_sample_khagan },
{ NULL, NULL, { NULL,NULL,NULL,NULL },NULL, NULL }, { NULL, NULL, { NULL,NULL,NULL,NULL },NULL, NULL },
}; };
@@ -584,7 +591,7 @@ static void osc_fx_generic_event(
args, args,
descr, descr,
func, func,
0 -1
); );
} }
void osc_add_sample_generic_events( lo_server_thread *st, void *user_data, void *osc_port, void *vevo_port, const char *base, int chain_len ) void osc_add_sample_generic_events( lo_server_thread *st, void *user_data, void *osc_port, void *vevo_port, const char *base, int chain_len )
@@ -602,7 +609,7 @@ void osc_add_sample_generic_events( lo_server_thread *st, void *user_data, void
sample_generic_events_[i].args, sample_generic_events_[i].args,
sample_generic_events_[i].descr, sample_generic_events_[i].descr,
sample_generic_events_[i].func, sample_generic_events_[i].func,
0 ); -1 );
} }
for( i =0; i < chain_len ; i ++ ) for( i =0; i < chain_len ; i ++ )
@@ -623,7 +630,7 @@ void osc_add_sample_generic_events( lo_server_thread *st, void *user_data, void
fx_events_[k].args, fx_events_[k].args,
fx_events_[k].descr, fx_events_[k].descr,
fx_events_[k].func, fx_events_[k].func,
0 -1
); );
} }
} }

View File

@@ -156,8 +156,14 @@ void veejay_osc_del_methods( void *user_data, void *osc_space,void *vevo_port, v
free(keys); free(keys);
} }
//@ fallback handler!
int osc_rest_handler( const char *path, const char *types,
lo_arg **argv, int argc, void *data, void *user_data )
{
veejay_msg(0, "Incoming OSC Path '%s' not recognized", path );
return 0;
}
//@ plugin handler! //@ plugin handler!
int osc_plugin_handler( const char *path, const char *types, int osc_plugin_handler( const char *path, const char *types,
@@ -173,10 +179,9 @@ int osc_plugin_handler( const char *path, const char *types,
veejay_msg(0, "Plugin Path %s wrong format '%s' , need '%s'", veejay_msg(0, "Plugin Path %s wrong format '%s' , need '%s'",
path,types, required_format ); path,types, required_format );
pthread_mutex_unlock( &(info->vevo_mutex) ); pthread_mutex_unlock( &(info->vevo_mutex) );
return 0;
return 1;
} }
veejay_msg(0, "Seq = %d", pd->seq );
int n_elem = strlen(required_format); int n_elem = strlen(required_format);
#ifdef STRICT_CHECKING #ifdef STRICT_CHECKING
assert( n_elem == argc ); assert( n_elem == argc );
@@ -189,6 +194,8 @@ int osc_plugin_handler( const char *path, const char *types,
elements[k] = argv[k]->i32; elements[k] = argv[k]->i32;
plug_set_parameter( pd->instance, pd->seq, n_elem, (void*)elements ); plug_set_parameter( pd->instance, pd->seq, n_elem, (void*)elements );
free(elements); free(elements);
pthread_mutex_unlock( &(info->vevo_mutex) );
return 0;
} }
else if( types[0] == 'd' ) else if( types[0] == 'd' )
{ {
@@ -197,19 +204,25 @@ int osc_plugin_handler( const char *path, const char *types,
elements[k] = argv[k]->d; elements[k] = argv[k]->d;
plug_set_parameter( pd->instance, pd->seq, n_elem, (void*) elements ); plug_set_parameter( pd->instance, pd->seq, n_elem, (void*) elements );
free(elements); free(elements);
pthread_mutex_unlock( &(info->vevo_mutex) );
return 0;
} }
else if( types[0] == 's' ) else if( types[0] == 's' )
{ {
char *strs = malloc(sizeof(char*) * n_elem ); char **strs = malloc(sizeof(char*) * n_elem );
for( k = 0; k < n_elem; k ++ ) for( k = 0; k < n_elem; k ++ )
strs[k] = strdup( (char*) &argv[k]->s ); strs[k] = strdup( (char*) &argv[k]->s );
plug_set_parameter( pd->instance,pd->seq, n_elem, (void*) strs ); plug_set_parameter( pd->instance,pd->seq, n_elem, (void*) strs );
} for( k = 0; k < n_elem; k ++ )
if(strs[k]) free(strs[k]);
pthread_mutex_unlock( &(info->vevo_mutex) );
return 0;
}
pthread_mutex_unlock( &(info->vevo_mutex)); pthread_mutex_unlock( &(info->vevo_mutex));
return 1; //@ try another method
return 0;
} }
int osc_veejay_handler( const char *path, const char *types, int osc_veejay_handler( const char *path, const char *types,
lo_arg **argv, int argc, void *data, void *user_data ) lo_arg **argv, int argc, void *data, void *user_data )
{ {
@@ -228,7 +241,7 @@ int osc_veejay_handler( const char *path, const char *types,
} }
pthread_mutex_unlock( &(info->vevo_mutex)); pthread_mutex_unlock( &(info->vevo_mutex));
return 1; return 1; //@ try another method
} }
int osc_sample_handler( const char *path, const char *types, int osc_sample_handler( const char *path, const char *types,
@@ -243,25 +256,23 @@ int osc_sample_handler( const char *path, const char *types,
argv )) argv ))
{ {
pthread_mutex_unlock( &(info->vevo_mutex) ); pthread_mutex_unlock( &(info->vevo_mutex) );
return 0; return 0;
} }
char *required_format = sample_property_format_osc( pd->instance, path ); char *required_format = sample_property_format_osc( pd->instance, path );
if(required_format == NULL ) if(required_format == NULL )
{ {
veejay_msg(0, "Invalid path '%s'", path); veejay_msg(0, "Plugin Path %s wrong format '%s' , need '%s'",
path,types, required_format );
pthread_mutex_unlock( &(info->vevo_mutex) ); pthread_mutex_unlock( &(info->vevo_mutex) );
return 0;
return 1;
} }
if( strcmp( required_format , types ) != 0 ) if( strcmp( required_format , types ) != 0 )
{ {
veejay_msg(0, "Sample Path %s wrong format '%s' , need '%s'", veejay_msg(0, "Sample Path %s wrong format '%s' , need '%s'",
path,types, required_format ); path,types, required_format );
pthread_mutex_unlock( &(info->vevo_mutex) ); pthread_mutex_unlock( &(info->vevo_mutex) );
return 0;
return 1;
} }
int n_elem = strlen(required_format); int n_elem = strlen(required_format);
@@ -269,6 +280,9 @@ int osc_sample_handler( const char *path, const char *types,
assert( n_elem == argc ); assert( n_elem == argc );
#endif #endif
int k; int k;
free(required_format);
if( types[0] == 'i' ) if( types[0] == 'i' )
{ {
int32_t *elements = (int32_t*) malloc(sizeof(int32_t) * n_elem ); int32_t *elements = (int32_t*) malloc(sizeof(int32_t) * n_elem );
@@ -276,6 +290,8 @@ int osc_sample_handler( const char *path, const char *types,
elements[k] = argv[k]->i32; elements[k] = argv[k]->i32;
sample_set_property_from_path( pd->instance, path, (void*)elements ); sample_set_property_from_path( pd->instance, path, (void*)elements );
free(elements); free(elements);
pthread_mutex_unlock(&(info->vevo_mutex));
return 0;
} }
else if( types[0] == 'd' ) else if( types[0] == 'd' )
{ {
@@ -283,8 +299,10 @@ int osc_sample_handler( const char *path, const char *types,
for( k = 0; k < n_elem; k ++ ) for( k = 0; k < n_elem; k ++ )
elements[k] = argv[k]->d; elements[k] = argv[k]->d;
sample_set_property_from_path( pd->instance, path, (void*)elements ); sample_set_property_from_path( pd->instance, path, (void*)elements );
free(elements); free(elements);
pthread_mutex_unlock(&(info->vevo_mutex));
return 0;
} }
else if( types[0] == 's' ) else if( types[0] == 's' )
{ {
@@ -292,6 +310,10 @@ int osc_sample_handler( const char *path, const char *types,
for( k = 0; k < n_elem; k ++ ) for( k = 0; k < n_elem; k ++ )
strs[k] = strdup( (char*) &argv[k]->s ); strs[k] = strdup( (char*) &argv[k]->s );
sample_set_property_from_path( pd->instance, path, (void*)strs ); sample_set_property_from_path( pd->instance, path, (void*)strs );
for( k = 0; k < n_elem; k ++ )
if(strs[k]) free(strs[k]);
pthread_mutex_unlock(&(info->vevo_mutex));
return 0;
} }
else if( types[0] == 'h' ) else if( types[0] == 'h' )
{ {
@@ -299,13 +321,15 @@ int osc_sample_handler( const char *path, const char *types,
for( k = 0; k < n_elem; k ++ ) for( k = 0; k < n_elem; k ++ )
elements[k] = argv[k]->h; elements[k] = argv[k]->h;
sample_set_property_from_path( pd->instance, path, (void*) elements ); sample_set_property_from_path( pd->instance, path, (void*) elements );
pthread_mutex_unlock(&(info->vevo_mutex));
return 0;
} }
free(required_format);
pthread_mutex_unlock( &(info->vevo_mutex)); pthread_mutex_unlock( &(info->vevo_mutex));
return 0; return 1;
} }
void veejay_osc_add_sample_generic_events(void *user_data, void *osc_port, void *vevo_port, const char *base, int fx) void veejay_osc_add_sample_generic_events(void *user_data, void *osc_port, void *vevo_port, const char *base, int fx)
@@ -335,6 +359,9 @@ void *veejay_new_osc_server( void *data, const char *port )
s->st = lo_server_thread_new( port, error_handler ); s->st = lo_server_thread_new( port, error_handler );
lo_server_thread_start( s->st ); lo_server_thread_start( s->st );
// lo_server_thread_add_method( s->st, NULL,NULL, osc_rest_handler,NULL );
veejay_msg( 0, "OSC server ready at UDP port %d", lo_server_thread_get_port(s->st) ); veejay_msg( 0, "OSC server ready at UDP port %d", lo_server_thread_get_port(s->st) );
return (void*) s; return (void*) s;
} }
@@ -350,6 +377,7 @@ static int servit_new_event(
const char *descr, const char *descr,
vevo_event_f *func, vevo_event_f *func,
int extra_token, int extra_token,
void *ptemplate,
lo_method_handler method ) lo_method_handler method )
{ {
veejay_t *info = (veejay_t*) userdata; veejay_t *info = (veejay_t*) userdata;
@@ -386,6 +414,23 @@ static int servit_new_event(
assert( error == VEVO_NO_ERROR ); assert( error == VEVO_NO_ERROR );
#endif #endif
if( ptemplate )
{
error = vevo_property_set( p, "parent", VEVO_ATOM_TYPE_VOIDPTR,1,&ptemplate );
#ifdef STRICT_CHECKING
assert( error == VEVO_NO_ERROR );
#endif
}
/* if( extra_token >= 0)
{
error = vevo_property_set(p, "ref", VEVO_ATOM_TYPE_INT,1, &extra_token );
#ifdef STRICT_CHECKING
assert( error == VEVO_NO_ERROR );
#endif
}*/
if( args ) if( args )
{ {
int i; int i;
@@ -460,7 +505,7 @@ int vevosample_new_event(
vevo_event_f *func, vevo_event_f *func,
int extra_token) int extra_token)
{ {
return servit_new_event( userdata,osc_space,instance,base,key,fmt,args,descr,func,extra_token, return servit_new_event( userdata,osc_space,instance,base,key,fmt,args,descr,func,extra_token,NULL,
osc_sample_handler ); osc_sample_handler );
} }
@@ -476,7 +521,7 @@ int veejay_new_event(
vevo_event_f *func, vevo_event_f *func,
int extra_token) int extra_token)
{ {
return servit_new_event( userdata,osc_space,instance,base,key,fmt,args,descr,func,extra_token, return servit_new_event( userdata,osc_space,instance,base,key,fmt,args,descr,func,extra_token,NULL,
osc_veejay_handler ); osc_veejay_handler );
} }
@@ -490,9 +535,10 @@ int plugin_new_event(
const char **args, const char **args,
const char *descr, const char *descr,
vevo_event_f *func, vevo_event_f *func,
int extra_token) int extra_token,
void *ptempl )
{ {
return servit_new_event( userdata,osc_space,instance,base,key,fmt,args,descr,func,extra_token, return servit_new_event( userdata,osc_space,instance,base,key,fmt,args,descr,func,extra_token,ptempl,
osc_plugin_handler ); osc_plugin_handler );
} }

View File

@@ -33,7 +33,8 @@ int plugin_new_event(
const char **args, const char **args,
const char *descr, const char *descr,
void *func, void *func,
int extra_token); int extra_token,
void *ptempl);
int veejay_new_event( int veejay_new_event(
void *userdata, void *userdata,

View File

@@ -953,8 +953,6 @@ int sample_process_fx( void *sample, int fx_entry )
#ifdef STRICT_CHECKING #ifdef STRICT_CHECKING
assert( error == VEVO_NO_ERROR ); assert( error == VEVO_NO_ERROR );
#endif #endif
plug_process( fx_instance );
error = vevo_property_get( port, "fx_values", 0, &fx_values ); error = vevo_property_get( port, "fx_values", 0, &fx_values );
#ifdef STRICT_CHECKING #ifdef STRICT_CHECKING
assert( error == VEVO_NO_ERROR ); assert( error == VEVO_NO_ERROR );
@@ -965,10 +963,12 @@ int sample_process_fx( void *sample, int fx_entry )
assert( error == VEVO_NO_ERROR ); assert( error == VEVO_NO_ERROR );
#endif #endif
//update internal parameter values //update internal parameter values
plug_clone_from_parameters( fx_instance, fx_values ); plug_clone_from_parameters( fx_instance, fx_values );
plug_process( fx_instance );
//get the output parameters,if any //get the output parameters,if any
plug_clone_from_output_parameters( fx_instance, fx_out_values ); plug_clone_from_output_parameters( fx_instance, fx_out_values );
@@ -1612,7 +1612,7 @@ void sample_init_namespace( void *data, void *sample , int id )
for( q = 0; ns_entries[q] != NULL ; q ++ ) for( q = 0; ns_entries[q] != NULL ; q ++ )
{ {
char *fmt = sample_property_format_osc( port, ns_entries[q] ); char *fmt = sample_property_format_osc( port, ns_entries[q] );
vevosample_new_event( data, osc_namespace, sample,NULL, ns_entries[q], fmt, NULL,NULL, NULL,0 ); vevosample_new_event( data, osc_namespace, sample,NULL, ns_entries[q], fmt, NULL,NULL, NULL,-1 );
if(fmt) free(fmt); if(fmt) free(fmt);
free(ns_entries[q]); free(ns_entries[q]);
@@ -3693,3 +3693,220 @@ void sample_send_osc_path( void *sample, void *fx_entry )
} }
} }
static char *osc_path_to_khagan_path( const char *str )
{
int n = strlen( str ) + 5;
char *res = (char*) malloc( n );
char arg = '%';
snprintf(res,n, "%s %c", str ,arg);
return res;
}
int khagan_write_property( void *port, const char *key, xmlNodePtr node )
{
int atom_type = vevo_property_atom_type( port, key );
int n_elem = vevo_property_num_elements( port , key );
int error;
if( n_elem == 0 || n_elem > 1 )
{
veejay_msg(0, "Khagan doesnt do list values ??");
return 1;
}
if( atom_type == VEVO_ATOM_TYPE_INT || atom_type == VEVO_ATOM_TYPE_BOOL )
{
int ival = 0;
error = vevo_property_get( port, key, 0, &ival );
#ifdef STRICT_CHECKING
assert( error == VEVO_NO_ERROR );
#endif
int_as_value( node, ival, key );
return 0;
}
else if ( atom_type == VEVO_ATOM_TYPE_DOUBLE )
{
double gval = 0.0;
error = vevo_property_get( port, key,0, &gval );
#ifdef STRICT_CHECKING
assert( error == VEVO_NO_ERROR );
#endif
double_as_value( node, gval, key );
return 0;
}
else if ( atom_type == VEVO_ATOM_TYPE_STRING )
{
char *str = get_str_vevo( port, key );
if( str )
{
cstr_as_value( node, str, key );
free(str);
}
return 0;
}
return 1;
}
int khagan_write_property_as( void *port, const char *key, xmlNodePtr node, const char *as_key )
{
int atom_type = vevo_property_atom_type( port, key );
int n_elem = vevo_property_num_elements( port , key );
int error;
if( n_elem == 0 || n_elem > 1 )
{
veejay_msg(0, "Khagan doesnt do list values ??");
return 1;
}
if( atom_type == VEVO_ATOM_TYPE_INT || atom_type == VEVO_ATOM_TYPE_BOOL )
{
int ival = 0;
error = vevo_property_get( port, key, 0, &ival );
#ifdef STRICT_CHECKING
assert( error == VEVO_NO_ERROR );
#endif
int_as_value( node, ival, as_key );
return 0;
}
else if ( atom_type == VEVO_ATOM_TYPE_DOUBLE )
{
double gval = 0.0;
error = vevo_property_get( port, key,0, &gval );
#ifdef STRICT_CHECKING
assert( error == VEVO_NO_ERROR );
#endif
double_as_value( node, gval, as_key );
return 0;
}
else if ( atom_type == VEVO_ATOM_TYPE_STRING )
{
char *str = get_str_vevo( port, key );
if( str )
{
cstr_as_value( node, str, as_key );
free(str);
}
return 0;
}
return 1;
}
/*
* Khagan, OSC live interface builder.
*
*
*/
static void sample_produce_khagan_widget(void *osc_port,int port_num, xmlNodePtr rootnode, int n)
{
//sample_runtime_data *srd = (sample_runtime_data*) sample;
char **list = vevo_list_properties ( osc_port );
int i;
int v_splits = n - 1;
xmlNodePtr nodes[ v_splits ];
xmlNodePtr cur_node = rootnode;
int n_widgets = 0;
for( i = 0; list[i] != NULL ; i ++ )
{
void *osc = NULL;
int error = vevo_property_get( osc_port, list[i],0,&osc );
void *template = NULL;
error = vevo_property_get( osc, "parent",0,&template );
if( error == VEVO_NO_ERROR )
{
if( n_widgets < v_splits )
{
nodes[n_widgets] =
xmlNewChild( cur_node, NULL, (const xmlChar*) "vsplit", NULL );
}
else
nodes[n_widgets] = cur_node;
xmlNodePtr node =
xmlNewChild( nodes[n_widgets] , NULL, (const xmlChar*) "widget", NULL );
char *description = get_str_vevo( template, "description");
char *khagan_path = osc_path_to_khagan_path( list[i] );
cstr_as_value( node, "PhatKnob", "name" );
khagan_write_property_as( template, "default", node, "value" );
khagan_write_property( template, "min" , node );
khagan_write_property( template, "max" , node );
cstr_as_value( node, khagan_path, "osc_path" );
int_as_value( node, port_num, "port" );
cstr_as_value( node, description, "label" );
cstr_as_value( node, "False", "is_log" );
free(description);
free(khagan_path);
cur_node = nodes[n_widgets];
n_widgets ++;
}
else
veejay_msg(0, "%s has no parent", list[i]);
free(list[i]);
}
free(list);
}
void sample_produce_khagan_file( void *sample )
{
sample_runtime_data *srd = (sample_runtime_data*) sample;
int port_num = veejay_get_port( srd->user_data );
int error;
int k;
const char *encoding = "UTF-8";
xmlNodePtr rootnode;
xmlDocPtr doc = xmlNewDoc( "1.0" );
rootnode = xmlNewDocNode( doc, NULL, (const xmlChar*) "gui", NULL );
xmlDocSetRootElement( doc, rootnode );
for( k =0; k < SAMPLE_CHAIN_LEN; k ++ )
{
void *fxp = sample_get_fx_port_ptr( srd, k );
void *fxi = NULL;
error = vevo_property_get( fxp, "fx_instance",0,&fxi );
if( error == VEVO_NO_ERROR )
{
void *osc_port = plug_get_name_space( fxi );
int n = vevo_property_num_elements( fxi, "in_parameters" );
if( osc_port )
sample_produce_khagan_widget( osc_port, port_num, rootnode ,n);
}
}
int id = 0;
error = vevo_property_get( srd->info_port, "primary_key", 0, &id );
char filename[256];
char sfilename[256];
sprintf(sfilename, "Fsample_%d.kh", id );
sprintf(filename, "sample_%d.kh", id );
// void xmlDocDump(FILE *f, xmlDocPtr doc);
FILE *res = fopen( filename , "w" );
if(!res)
veejay_msg(0, "Cannot write to %s",filename);
else
xmlDocDump( res, doc );
fclose(res);
int ret = xmlSaveFormatFileEnc( sfilename, doc, encoding , 1 );
xmlFreeDoc( doc );
}