Пример #1
0
void	vj_midi_learning_vims( void *vv, char *widget, char *msg, int extra )
{
	vmidi_t *v = (vmidi_t*) vv;
        if(!v->active) return;

	if( !v->learn )
		return;

	if( v->learn_event[0] == -1 || v->learn_event[1] == -1 || v->learn_event[2] == -1 ) {
		veejay_msg(0, "Cannot learn '%s' (%s) - unknown midi event.",
			widget, msg );
		return;
	}

	dvims_t *d = (dvims_t*) vj_malloc(sizeof(dvims_t));
	d->extra = extra;	
	d->msg = (msg == NULL ? NULL : strdup(msg));
	d->widget = (widget == NULL ? NULL : strdup(widget));
	char key[32];
	snprintf(key,sizeof(key), "%03d%03d", v->learn_event[0],v->learn_event[1] );

	dvims_t *cur = NULL;
	if( vevo_property_get( v->vims, key, 0, &cur ) == VEVO_NO_ERROR )
	{
		if( cur->widget ) free(cur->widget );
		if( cur->msg ) free(cur->msg);
		free(cur);
	}
	int error = vevo_property_set( v->vims, key, 1, VEVO_ATOM_TYPE_VOIDPTR, &d );
	if( error != VEVO_NO_ERROR )
		return;
	vj_msg( VEEJAY_MSG_INFO, 
		"Midi %x: %x ,%x learned", v->learn_event[0],v->learn_event[1],v->learn_event[2]);
}
Пример #2
0
static	void* instantiate_plugin( void *plugin, int w , int h )
{
	int type = 0;
	int error = vevo_property_get( plugin, "HOST_plugin_type", 0, &type);
	if( error != VEVO_NO_ERROR )
		return NULL;

	void *instance = NULL;
		
	switch( type )
	{
		case VEVO_PLUG_LIVIDO:
			instance = livido_plug_init( plugin,w,h, base_fmt_ );
			break;
		case VEVO_PLUG_FF:
			instance = freeframe_plug_init( plugin,w,h);
			break;
		case VEVO_PLUG_FR:
			instance = frei0r_plug_init( plugin,w,h,base_fmt_ );
			break;
		default:
			veejay_msg(0, "Plugin type not supported.");
			break;
	}

	if( instance != NULL )
		vevo_property_set( instance, "HOST_type", VEVO_ATOM_TYPE_INT, 1, &type );

	
	return instance;
}
Пример #3
0
void		init() {
	char server_port_name[10];
	char *server 	 = veejay_osc_server_get_addr( info->osc_server );
	int   server_port= veejay_osc_server_get_port( info->osc_server );	

	sprintf( server_port_name, "%d", server_port );
	
	veejay_msg(0, "Veejay server '%s' communicates with %s" ,server,uri );

	void *ui = veejay_new_osc_sender_uri( uri );
	veejay_send_osc( ui, "/veejay", "sx", server );
	int error = vevo_property_set( info->clients, uri, VEVO_ATOM_TYPE_VOIDPTR,1,&ui );

}
Пример #4
0
void	vj_midi_load(void *vv, const char *filename)
{
	vmidi_t *v = (vmidi_t*) vv;
        if(!v->active) return;

	int a = vj_midi_events(vv);
	if( a > 0 )
	{
		char warn[200];
		snprintf(warn,sizeof(warn), "There are %d MIDI event known, loading from file will overwrite any existing events. Continue ?", a );
		if( prompt_dialog( "MIDI", warn ) == GTK_RESPONSE_REJECT )
			return;

	}

	int fd = open( filename, O_RDONLY );
	if(!fd)
	{
		vj_msg(VEEJAY_MSG_ERROR, "Unable to open file '%s': %s", filename, strerror(errno));
		return;
	}
	struct stat t;
	if( fstat( fd, &t) != 0 )
	{
		veejay_msg(0, "Error loading MIDI config '%s':%s",filename,strerror(errno));
		vj_msg(VEEJAY_MSG_ERROR,"Unable to load %s: %s", filename, strerror(errno));
		return;
	}
	else
	{
		if( !S_ISREG( t.st_mode ) && !S_ISLNK(t.st_mode) )
		{
			vj_msg(VEEJAY_MSG_ERROR, "File '%s' is not a regular file or symbolic link. Refusing to load it.",
				filename );
			return;
		}
	}

	char *buf = (char*) vj_calloc( 128000 );
	uint32_t count = 0;
	if (read( fd, buf, 128000 ) > 0 )
	{
		int len = strlen( buf );
		int j,k=0;

		char value[1024];
		veejay_memset(value,0,sizeof(value));
	
		for( j = 0; j < len; j ++ )
		{
			if( buf[j] == '\0' ) break;
			if( buf[j] == '\n' )
			{
				char key[32];
				char widget[100];
				char message[512];
				int extra = 0;
				
				veejay_memset( key,0,sizeof(key));
				veejay_memset( widget,0,sizeof(widget));
				veejay_memset( message,0,sizeof(message));

				if(sscanf( value, "%s %d %s \"%[^\"]", key, &extra, widget, message ) == 4 )
				{
					veejay_memset( value,0,sizeof(value));
					k = 0;
					dvims_t *d = (dvims_t*) vj_calloc(sizeof(dvims_t));
					dvims_t *cur = NULL;
					d->extra = extra;
					d->widget = NULL;
					if( strncasecmp( widget, "none", 4 ) !=0 )
						d->widget = strdup(widget);
					d->msg = strdup(message);
					if( vevo_property_get( v->vims, key, 0, &cur ) == VEVO_NO_ERROR )
					{
						if(cur->widget) free(cur->widget);
						if(cur->msg) free(cur->msg);
						free(cur);
					}
					int error = vevo_property_set( v->vims, key, 1, VEVO_ATOM_TYPE_VOIDPTR, &d);
					if( error == VEVO_NO_ERROR )
						count ++;
#ifdef STRICT_CHECKING
					else {
						veejay_msg(VEEJAY_MSG_ERROR, "Error loading MIDI event '%s': %d",key, error );

					}
#endif
				}

			}
			if( buf[j] != '\n' && buf[j] != '\0' )
				value[k++] = buf[j];
		
		}
	
	}
	free(buf);
	veejay_msg(VEEJAY_MSG_INFO, "loaded %d midi events from %s",count,filename);
	vj_msg(VEEJAY_MSG_INFO, "Loaded %d MIDI events from %s", count ,filename);
}
Пример #5
0
static	int	add_to_plugin_list( const char *path )
{
	if(path == NULL)
		return 0;

	int i;
	char fullname[PATH_MAX+1];
	struct	dirent	**files = NULL;
	struct stat sbuf;
	int	res = 0;

	memset( &sbuf,0 ,sizeof(struct stat));
	res = stat( path, &sbuf );

	if( res != 0 )
	{
		veejay_msg(VEEJAY_MSG_DEBUG, "File or directory '%s' does not exist (skip)", path);
		return 0;
	}
	
	if( S_ISREG( sbuf.st_mode ) )
	{
		vevo_property_set( illegal_plugins_, path, LIVIDO_ATOM_TYPE_STRING, 0, NULL );
		return 0;
	}

	if( !S_ISDIR( sbuf.st_mode ) )
	{
		veejay_msg(VEEJAY_MSG_DEBUG, "Not a directory : '%s'", path );
		return 0;
	}
	int n_files = scandir( path, &files, select_f, alphasort );
	if( n_files <= 0 ) {
		veejay_msg(VEEJAY_MSG_DEBUG, "No plugins found in %s", path );
		return 0;
	}

	for( i = 0 ; i < n_files; i ++ )
	{
		char *name = files[i]->d_name;

		if( vevo_property_get( illegal_plugins_, name, 0 , NULL ) == 0 )
		{
			veejay_msg(VEEJAY_MSG_DEBUG, "'%s' marked as bad", name);
			continue; 
		}

		snprintf(fullname,sizeof(fullname),"%s/%s", path,name );

		void *handle = dlopen(fullname, RTLD_NOW );

		if(!handle) 
		{
			veejay_msg(0,"Plugin '%s' error '%s'", fullname,
				 dlerror() );
			continue;
		}
		char *bname = basename( fullname );
		char *basename = vj_strdup( bname );
		void *plugin = NULL;
		veejay_msg(VEEJAY_MSG_DEBUG, "Loading %s",fullname );

		if(dlsym( handle, "plugMain" ) && sizeof(long) == 4)
		{
			plugin = deal_with_ff( handle, name, base_width_, base_height_ );
			if( plugin )
			{
				index_map_[ index_ ] = plugin;
				index_ ++;
				n_ff_ ++;
			}
			else
				dlclose( handle );	
		} else if(dlsym( handle, "f0r_construct" )) {
			plugin = deal_with_fr( handle, name );
			if( plugin )
			{
				index_map_[ index_ ] = plugin;	
				index_ ++;
				n_fr_ ++;
			}
			else
				dlclose( handle );
		} else if(dlsym( handle, "livido_setup" )) {
			plugin = deal_with_livido( handle , name );
			if( plugin )
			{
				index_map_[index_] = plugin;
				index_ ++;
				n_lvd_ ++;
			}
			else
				dlclose(handle);
		} else{
			dlclose(handle);
			veejay_msg(VEEJAY_MSG_DEBUG, "%s is not compatible.", fullname );
		}

		if( plugin ) {
			vevo_property_set( plugin, "so_name",VEVO_ATOM_TYPE_STRING,1,&basename );
		}

		free(basename);
	
	}

	for( i = 0; i < n_files; i ++ )
		free( files[i] );
	free(files);

	return n_files;
}
Пример #6
0
static int	servit_new_event(
		void *userdata,
		void *osc_space,
		void *instance,
		const char *base,
		const char *key,
		const char *fmt,
		const char **args,
		const char *descr,
		vevo_event_f *func,
		int extra_token,
		void *ptemplate,
	        lo_method_handler method )
{
	veejay_t *info = (veejay_t*) userdata;
	osc_recv_t *s = (osc_recv_t*) info->osc_server;
	void *p = (void*) vevo_port_new( VEVO_ANONYMOUS_PORT );
	int error;
	
	if( func )
	{
		error = vevo_property_set( p, "func", VEVO_ATOM_TYPE_VOIDPTR,1,&func );
	}

	if( fmt == NULL )
		error = vevo_property_set( p, "format", VEVO_ATOM_TYPE_STRING,0,NULL );
	else
		error = vevo_property_set( p, "format", VEVO_ATOM_TYPE_STRING,1, &fmt );

	if( descr == NULL )
		error = vevo_property_set(p, "description",VEVO_ATOM_TYPE_STRING,0, NULL );
	else
		error = vevo_property_set(p, "description", VEVO_ATOM_TYPE_STRING,1, &descr );
	
	if( ptemplate )
	{
		error = vevo_property_set( p, "parent", VEVO_ATOM_TYPE_VOIDPTR,1,&ptemplate );
	}
	
/*	if( extra_token >= 0)
	{
		error = vevo_property_set(p, "ref", VEVO_ATOM_TYPE_INT,1, &extra_token );
	}*/
	
	if( args )
	{
		int i;
		for( i = 0;i < 4; i ++ )
		{
			if(args[i])
			{
				char index[10];
				sprintf(index,"help_%d",i);
				error = vevo_property_set( p, index, VEVO_ATOM_TYPE_STRING,1,&(args[i]) );
			}
		}
	}

	plugin_data_t *pd = (plugin_data_t*) vj_malloc(sizeof(plugin_data_t));
	pd->seq = extra_token;
	pd->caller = userdata;
	pd->instance = instance;
	error = vevo_property_set( p,
				"userdata",
				VEVO_ATOM_TYPE_VOIDPTR,
				1,
				&pd );

	char *tmp_path = NULL;
	if( base)
		tmp_path = osc_create_path( base, key );     
	else
		tmp_path = strdup(key);

	char *my_path  = veejay_valid_osc_name( tmp_path );
	
	error = vevo_property_set( osc_space,
				   my_path,
				   VEVO_ATOM_TYPE_PORTPTR,
				   1,
				   &p );

	lo_server_thread_add_method(
				s->st,
				my_path,
				fmt,
				method,
				(void*) pd );

	free(my_path);
	free(tmp_path);
	
	return VEVO_NO_ERROR;
}