void	veejay_osc_del_methods( void *user_data, void *osc_space,void *vevo_port, void *fx_instance )
{
	veejay_t *info = (veejay_t*) user_data;
	osc_recv_t *s = (osc_recv_t*) info->osc_server;

	char **keys = vevo_list_properties( osc_space );
	int i;
	int error;
	for( i = 0; keys[i] != NULL ; i ++ )
	{
		void *event_port = NULL;
		error = vevo_property_get( osc_space, keys[i],0,&event_port );
		
		void *ptr = NULL;
		error = vevo_property_get( event_port, "userdata",0, &ptr );
		
		char *types = get_str_vevo( event_port, "format" );
		
		lo_server_thread_del_method( s->st, keys[i], types );
		
		free(keys[i]);
		if(types)
			free(types);
		free(ptr);
	}
	free(keys);

}
Exemple #2
0
static	void	vevosample_ui_construct_bind_list( void *sample, int k, int p_num, void *dslot, const char *window,
	       	const char *fx_frame	)
{
	//@ list all binds
	sample_runtime_data *srd = (sample_runtime_data*) sample;
	fx_slot_t *slot = (fx_slot_t*) dslot;
	void *osc_send = veejay_get_osc_sender(srd->user_data );
	if(!osc_send)
		return;

	char bind_path[128];
	sprintf(bind_path, "/sample_%d/fx_%d/unbind", srd->primary_key,k);

	void *msg = veejay_message_new_pulldown(
			osc_send, window, fx_frame, "combobox_release_bind", "Choose item to release", bind_path, 0, "None" );
	
	veejay_message_add_argument( osc_send, msg, "s", "None");

	int i;
	if(!slot->bind )
	{
		veejay_message_pulldown_done(osc_send, msg);
		return;
	}

	char **items = vevo_list_properties( slot->bind );
	if(! items )
	{
		veejay_message_pulldown_done(osc_send, msg);
		return;
	}
	for( i = 0; items[i] != NULL ; i ++ )
	{
		int n[3];
		sscanf( items[i], "bp%d_%d_%d", &n[BIND_OUT_P],&n[BIND_ENTRY],&n[BIND_IN_P] );
		fx_slot_t *rel = (fx_slot_t*) sample_get_fx_port_ptr( srd, n[BIND_ENTRY]);

		if( n[BIND_OUT_P] == p_num && vevo_property_get( slot->bind, items[i],0,NULL) == VEVO_NO_ERROR)
		{
			void *filter_template = NULL;
			int error = vevo_property_get( rel->fx_instance, "filter_templ",0 ,&filter_template );
			char *fxname = vevo_property_get_string( filter_template, "name" );

			char *pname = _get_in_parameter_name( rel->fx_instance, n[BIND_IN_P] );
			char list_item[128];
			snprintf(list_item, 128, "fx_%d '%s' p%d '%s'",
					n[BIND_ENTRY], fxname, n[BIND_IN_P],pname );

			veejay_message_add_argument( osc_send, msg, "s", list_item );

			free(fxname);
			free(pname);	
		}
		free(items[i]);
	}
	free(items);
	veejay_message_pulldown_done(osc_send, msg);

}
static	int	vj_midi_events(void *vv )
{
	vmidi_t *v = (vmidi_t*)vv;
	char **items = vevo_list_properties(v->vims);
	if(!items) return 0;

	int i;
	int len = 0;
	for( i = 0; items[i] != NULL ; i ++ )
	{
		len ++;
		free(items[i]);
	}
	free(items);
	return len;	
}
Exemple #4
0
int	veejay_vevo_send_osc( void *osc, const char *msg, void *vevo_port )
{
	char  **keys = vevo_list_properties( vevo_port );
	int i;
	lo_message lmsg = lo_message_new();
	oscclient_t *c  = (oscclient_t*) osc;

	
	for ( i = 0; keys[i] != NULL; i ++ )
	{
		char *format = vevo_format_kind( vevo_port, keys[i] );
		int n_elems = vevo_property_num_elements( vevo_port, keys[i] );

		while( *format )
		{
			switch(*format)
			{
				case 'd':
					_vevo_get_int( vevo_port, keys[i], n_elems, lmsg  );
					break;
				case 'g':
					_vevo_get_dbl( vevo_port, keys[i], n_elems, lmsg );
					break;
				default:
					break;
			}
			*format++;
		}

		free(keys[i]);	
	}

	free(keys);

	int result = lo_send_message( c->addr, msg, lmsg );

	lo_message_free( lmsg );

	if( result == -1)
		return VEVO_ERROR_HARDWARE; //@ long live bogus error codes

	
	return VEVO_NO_ERROR;
}
void	vj_midi_save(void *vv, const char *filename)
{
	vmidi_t *v = (vmidi_t*) vv;
        if(!v->active) return;

	int fd = open( filename, O_TRUNC|O_CREAT|O_WRONLY,S_IRWXU );
	if(!fd)
	{
		vj_msg(VEEJAY_MSG_ERROR, "Unable to save MIDI settings to %s",filename);
		return;
	}

	char **items = vevo_list_properties( v->vims );
	int i;
	if( items == NULL )
	{
		vj_msg(VEEJAY_MSG_ERROR, "No MIDI events learned yet");
		return;
	}
	uint32_t count = 0;
	for( i =0 ; items[i] != NULL ;i ++ )
	{
		char tmp[512];
		dvims_t *d  = NULL;
		if( vevo_property_get( v->vims, items[i], 0, &d ) == VEVO_NO_ERROR )
		{
			snprintf(tmp, 512, "%s %d %s \"%s\"\n",
				items[i],
				d->extra,
				(d->widget == NULL ? "none" : d->widget ),
				d->msg );
			if( write( fd, tmp, strlen( tmp )) >= 0 )
				count ++;
		}
		free(items[i]);
	}
	free(items);
	close(fd);

	vj_msg(VEEJAY_MSG_INFO, "Wrote %d MIDI events to %s", count, filename );
}
void	vj_midi_reset( void *vv )
{
	vmidi_t *v = (vmidi_t*)vv;

	int a = vj_midi_events(vv);
	if( a > 0 )
	{
		char warn[200];
		snprintf(warn,sizeof(warn), "This will clear %d MIDI events, Continue ?",a );
		if( prompt_dialog( "MIDI", warn ) == GTK_RESPONSE_REJECT )
			return;

	}

	char **items = vevo_list_properties(v->vims);
	if(!items) {
		vj_msg(VEEJAY_MSG_INFO,"No MIDI events to clear");
		return;
	}
	int i;
	for( i = 0; items[i] != NULL ; i ++ )
	{
		dvims_t *d = NULL;
		if( vevo_property_get( v->vims, items[i],0,&d ) == VEVO_NO_ERROR )
		{
			if(d->msg) free(d->msg);
			if(d->widget) free(d->widget);
			free(d);
		}
		free(items[i]);
	}
	free(items);
	
	vpf(v->vims);

	v->vims = vpn(VEVO_ANONYMOUS_PORT);

	vj_msg(VEEJAY_MSG_INFO, "Cleared %d MIDI events.",a);
}
Exemple #7
0
void	vevosample_ui_get_bind_list( void *sample, const char *window )
{
	int fx_id = 0;
	int p_num = 0;
	int dummy = 0;
	sscanf(window, "SampleBind%dFX%dOP%d",&dummy,&fx_id,&p_num);

	
	sample_runtime_data *srd = (sample_runtime_data*) sample;
	fx_slot_t *sl = (fx_slot_t*) sample_get_fx_port_ptr( srd, fx_id);
	void *osc_send = veejay_get_osc_sender(srd->user_data );
	if(!osc_send)
		return;

//@ we also update path!
	char bind_path[128];
	sprintf(bind_path, "/sample_%d/fx_%d/unbind", srd->primary_key,fx_id);
	
	
//@ pulldown abused for updatin ! see pulldown_done_update  , it calls an update method in uiosc.c	
	void *msg = veejay_message_new_pulldown( osc_send, window, "n/a", "combobox_release_bind", "Choose Item to release", bind_path, 0, "None" );

//	veejay_message_add_argument(
//				osc_send, msg, "s", "None" );

	char **items = vevo_list_properties( sl->bind );
	if(! items )
	{
		veejay_message_pulldown_done_update(
			osc_send, msg );

		return;
	}
	int i;
	for( i = 0; items[i] != NULL ; i ++ )
	{
		int n[3];
		sscanf( items[i], "bp%d_%d_%d", &n[BIND_OUT_P],&n[BIND_ENTRY],&n[BIND_IN_P] );
#endif
		fx_slot_t *rel = (fx_slot_t*) sample_get_fx_port_ptr( srd, n[BIND_ENTRY]);

		if( n[BIND_OUT_P] == p_num && vevo_property_get(sl->bind, items[i],0,NULL) == VEVO_NO_ERROR )
		{
			veejay_msg(0, "'%s' is a valid bind",items[i]);
			void *filter_template = NULL;
			int error = vevo_property_get( rel->fx_instance, "filter_templ",0 ,&filter_template );
			char *fxname = vevo_property_get_string( filter_template, "name" );

			char *pname = _get_in_parameter_name( rel->fx_instance, n[BIND_IN_P] );
			char list_item[128];
			snprintf(list_item, 128, "fx_%d '%s' p%d '%s'",
					n[BIND_ENTRY], fxname,n[BIND_IN_P], pname );

			veejay_message_add_argument( osc_send, msg, "s", list_item );

			free(fxname);
			free(pname);	


		}
		free(items[i]);
	}
	free(items);
	
	veejay_message_pulldown_done_update(
			osc_send, msg );
}
Exemple #8
0
static void		vevosample_ui_construct_fx_contents( void *sample, int entry_id, const char *window , const char *fx_frame)
{
	sample_runtime_data *srd = (sample_runtime_data*) sample;
	void *osc_send = veejay_get_osc_sender( srd->user_data );
	int id = 0;
	if(!osc_send)
		return;
	fx_slot_t *slot = sample_get_fx_port_ptr( srd, entry_id );
	if(slot->window)
		free(slot->window);
	slot->window = strdup( window );
			
	int error = vevo_property_get( srd->info_port, "primary_key", 0, &id );
	void *filter_template = NULL;
	error = vevo_property_get( slot->fx_instance, "filter_templ",0 ,&filter_template );
	char *label_str = vevo_property_get_string( filter_template, "name" );
	char label[128];
	sprintf( label, "FX slot %d with  \"%s\" ", entry_id, label_str );
	free(label_str);
	
	sprintf(fx_frame, "fx_%d", entry_id ); 

	veejay_ui_bundle_add( osc_send, "/create/frame", "sssx", window, fx_frame, label );

	char alpha_tmp[128];
	sprintf( alpha_tmp, "/sample_%d/fx_%d/alpha", id, entry_id );
			
	veejay_ui_bundle_add( osc_send, "/create/numeric", "sssdddiissssx",window,fx_frame,
			"Alpha", 0.0, 1.0, slot->alpha,2,0,"VSlider",alpha_tmp, "d", "Transparency" );

	
	sprintf( alpha_tmp, "/sample_%d/fx_%d/status", id, entry_id);

	veejay_ui_bundle_add( osc_send, "/create/switch", "ssssissx", window, fx_frame, "Check",
			"Enabled", slot->active, alpha_tmp, "Turn on/off FX" );
	
	int q;
	int n = vevo_property_num_elements( slot->fx_instance, "in_parameters" );

	for( q = 0; q < n ; q ++ )
	{
		void *parameter = NULL;
		error = vevo_property_get( slot->fx_instance, "in_parameters", q, &parameter );
		void *parameter_templ = NULL;
		error = vevo_property_get( parameter, "parent_template",0,&parameter_templ);
		int kind = 0;
		error = vevo_property_get( parameter_templ, "HOST_kind",0,&kind );
		char *parameter_name = vevo_property_get_string(parameter_templ, "name" );
		char *osc_path 		= vevo_property_get_string(parameter, "HOST_osc_path" );
		int ival = 0;
		double gval = 0.0;
		int imin = 0, imax = 0;
		double gmin = 0.0, gmax = 0.0;
		char *hint = vevo_property_get_string( parameter_templ, "description" );
		switch( kind )
		{
			case HOST_PARAM_INDEX:
				vevo_property_get( parameter, "value",0,&ival);
				gval = (double) ival;
				vevo_property_get( parameter_templ, "min",0,&imin );
				gmin = (double) imin;
				vevo_property_get( parameter_templ, "max",0,&imax );
				gmax = (double) imax;
				veejay_ui_bundle_add( osc_send, "/create/numeric", "sssdddiissssx", window, fx_frame,
						parameter_name,gmin,gmax,gval,0,0,"VSlider", osc_path, "i", hint );
				
				break;
			case HOST_PARAM_NUMBER:
				vevo_property_get( parameter, "value",0,&gval);
				vevo_property_get( parameter_templ, "min",0,&gmin );
				vevo_property_get( parameter_templ, "max",0,&gmax );
				veejay_ui_bundle_add( osc_send, "/create/numeric", "sssdddiissssx",
						window,fx_frame,parameter_name,gmin,gmax,gval,2,0,"VSlider",osc_path,"d", hint);
				break;
			case HOST_PARAM_SWITCH:
				vevo_property_get( parameter, "value",0,&ival );
				veejay_ui_bundle_add( osc_send, "/create/switch", "ssssissx", window,fx_frame, "Check",
						parameter_name, ival ,osc_path, hint );
				break;
			default:
				break;
		}
		free(hint);
		free(parameter_name);
		free(osc_path);
	}
	
	n = vevo_property_num_elements( slot->fx_instance, "in_channels" );

veejay_msg(0, "UI Factory: There are %d input channels", n );
	
	if( n > 1 )
	{
		char ch_path[128];
		sprintf( ch_path, "/sample_%d/fx_%d/input_channel", id, entry_id);


		void *msg = veejay_message_new_widget( osc_send, window, 
					ch_path, n-1 );

		void *ch = sample_get_fx_port_channels_ptr( id , entry_id );
		char **items = vevo_list_properties( ch );
		for( q = 0; items[q] != NULL ;q  ++ )
		{
			void *sample = NULL;
			vevo_property_get( ch, items[q],0,&sample);
			if(sample && strncasecmp( items[q] , "slot0", 5 ) != 0)
			{
				int id = sample_get_run_id( sample );
				char name[32];
				sprintf(name , "S%d", id );
				veejay_message_add_argument( osc_send, msg, "s", name );
			veejay_msg(0, "Added '%s' ", name);
			}
			free(items[q]);
		}
		free(items);
		//	veejay_message_add_argument( osc_send, msg, "s", name );

		veejay_message_widget_done( osc_send, msg );
	}

	n =  vevo_property_num_elements( slot->fx_instance, "out_parameters" );
	if( n <= 0 )
	{
		return;
	}
	
	char long_label[128];
	snprintf(long_label,128,"Output parameters", label);
	sprintf(fx_frame, "bind_%d", entry_id ); 
	veejay_ui_bundle_add( osc_send, "/create/frame", "sssx", window, fx_frame, long_label );

	char box_name[128];
	sprintf( box_name, "%s_box", fx_frame );
	
	veejay_ui_bundle_add( osc_send, "/create/box", "sssix", window,fx_frame, box_name, 0 );
	
	for( q = 0; q < n ; q ++ )
	{
		void *parameter = NULL;
		error = vevo_property_get( slot->fx_instance, "out_parameters", q, &parameter );
		void *parameter_templ = NULL;
		error = vevo_property_get( parameter, "parent_template",0,&parameter_templ);
		int kind = 0;
		error = vevo_property_get( parameter_templ, "HOST_kind",0,&kind );
		if( kind == HOST_PARAM_NUMBER || kind == HOST_PARAM_SWITCH || kind == HOST_PARAM_INDEX )
		{
			char *parameter_name = vevo_property_get_string(parameter_templ, "name" );
			sprintf(fx_frame, "fxb_%d",q );
			veejay_ui_bundle_add( osc_send, "/create/vframe", "ssssx", window, box_name,fx_frame, parameter_name );
			char param_id[32];
			sprintf(param_id,"o%02d",q );

			char *parameter_value = vevo_sprintf_property_value(
					parameter, "value " );
			
			veejay_ui_bundle_add( osc_send, "/create/label",
				"ssssx", window,fx_frame,param_id, (parameter_value==NULL ? "   " : parameter_value) ); //@ updated by apply_bind !!!
			if(parameter_value)
				free(parameter_value);
			free(parameter_name );

			
			
			char hint[128];
			snprintf(hint, 128,"Bind %s to an Input Parameter of another FX slot");
			char bindname[32];
			char unbindname[32];
			sprintf(bindname,"bind_p%d", q);
			sprintf(unbindname,"unbind_p%d",q );

			//@ special button
			veejay_ui_bundle_add( osc_send, "/create/button","sssssx",
				window, fx_frame, "B", bindname, hint );


			//@ normal button, special parameters
			veejay_ui_bundle_add( osc_send, "/create/button","sssssx",
				window, fx_frame, "C", unbindname, "Reset binding");
		}
	}
	
}