int veejay_osc_property_calls_event( void *instance, const char *path, char *types, void **argv[], void *raw ) { veejay_t *v = (veejay_t*) instance; void *vevo_port = v->osc_namespace; int atom_type = vevo_property_atom_type( vevo_port, path ); if( atom_type == VEVO_ATOM_TYPE_PORTPTR ) { void *port = NULL; int error = vevo_property_get( vevo_port, path,0,&port ); if(error == VEVO_NO_ERROR ) { vevo_event_f f; if( veejay_osc_verify_format( port, types ) ) { error = vevo_property_get( port, "func",0,&f ); if( error == VEVO_NO_ERROR ) { (*f)( instance,path, types, argv,raw ); return 1; } } } } return 0; }
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); }
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 char *_get_in_channel_name( void *instance, int id ) { void *p = NULL; int error = vevo_property_get( instance, "in_channels", id, &p ); if( error != VEVO_NO_ERROR ) return NULL; void *t = NULL; error = vevo_property_get( p, "parent_template", 0, &t ); if( error == VEVO_NO_ERROR ) return vevo_property_get_string( t, "name" ); return NULL; }
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; }
void plug_get_defaults( void *instance, void *fx_values ) { generic_default_values_f gdv; int error = vevo_property_get( instance, "HOST_plugin_defaults_f", 0, &gdv ); if( error == VEVO_NO_ERROR ) (*gdv)( instance, fx_values ); }
void plug_process( void *instance, double timecode ) { generic_process_f gpf; int error = vevo_property_get( instance, "HOST_plugin_process_f", 0, &gpf ); if( error == VEVO_NO_ERROR ) (*gpf)( instance, timecode ); }
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]); }
char *plug_get_osc_path_parameter(void *instance, int k) { void *p = NULL; if( vevo_property_get( instance, "in_parameters",k,&p ) == VEVO_NO_ERROR ) return vevo_property_get_string( p, "HOST_osc_path" ); return NULL; }
void plug_clone_parameters( void *instance, void *fx_values ) { generic_clone_parameter_f gcc; int error = vevo_property_get( instance, "HOST_plugin_param_clone_f", 0, &gcc ); if( error == VEVO_NO_ERROR ) (*gcc)( instance, 0, fx_values ); }
void plug_set_parameter( void *instance, int seq_num,int n_elements,void *value ) { generic_push_parameter_f gpp; int error = vevo_property_get( instance, "HOST_plugin_param_f", 0, &gpp ); if( error == VEVO_NO_ERROR) (*gpp)( instance, seq_num, value ); }
int plug_is_frei0r( void *instance ) { int type = 0; vevo_property_get(instance, "HOST_type", 0, &type ); if( type == VEVO_PLUG_FR ) return 1; return 0; }
int plug_clone_from_output_parameters( void *instance, void *fx_values ) { generic_reverse_clone_out_parameter_f grc; int error = vevo_property_get( instance, "HOST_plugin_out_param_reverse_f", 0, &grc ); if( error != VEVO_NO_ERROR ) return 0; int n = (*grc)(instance,fx_values); return n; }
void plug_clone_from_parameters(void *instance, void *fx_values) { generic_reverse_clone_parameter_f grc; int error = vevo_property_get( instance, "HOST_plugin_param_reverse_f", 0, &grc ); if( error != VEVO_NO_ERROR ) return; // copy parameters from plugin to fx_values (*grc)( instance ,0, fx_values ); }
int plug_get_num_input_channels( int fx_id ) { if(index_map_[fx_id] == NULL ) return 0; int res = 0; vevo_property_get( index_map_[fx_id], "num_inputs",0,&res); return res; }
void *veejay_get_osc_sender_by_uri( veejay_t *info , const char *uri ) { void *sender = NULL; int error = vevo_property_get( info->clients, uri, 0, &sender ); if( error == VEVO_NO_ERROR ) return sender; return NULL; }
static void deinstantiate_plugin( void *instance ) { generic_deinit_f gin = NULL; int error = vevo_property_get( instance, "HOST_plugin_deinit_f", 0, &gin ); if( error == VEVO_NO_ERROR && gin != NULL ) (*gin)(instance); instance = NULL; }
void plug_push_frame( void *instance, int out, int seq_num, void *frame_info ) { VJFrame *frame = (VJFrame*) frame_info; generic_push_channel_f gpu; int error = vevo_property_get( instance, "HOST_plugin_push_f", 0, &gpu ); if( error == VEVO_NO_ERROR ) (*gpu)( instance, seq_num,out, frame ); }
int plug_get_num_parameters( int fx_id ) { if(index_map_[fx_id] == NULL ) return 0; int res = 0; if( vevo_property_get( index_map_[fx_id], "num_params",0,&res) != VEVO_NO_ERROR ) return 0; return res; }
void *veejay_get_osc_sender(veejay_t * info ) { if(!info) return NULL; void *sender = NULL; if(!info->current_client) return NULL; int error = vevo_property_get( info->clients, info->current_client, 0, &sender ); if( error == VEVO_NO_ERROR ) return sender; return NULL; }
//@ create widgets for capture type static void vevosample_ui_type_capture( void *sample, const char *window, const char *frame) { sample_runtime_data *srd = (sample_runtime_data*) sample; int i; char **list = vj_unicap_get_list( srd->data ); double min=0.0; double max=0.0; char format[5]; double dv = 0; char path[128]; int id = srd->primary_key; void *osc_send = veejay_get_osc_sender(srd->user_data ); vevosample_ui_new_frame( sample, window, "capframe", "Settings" ); vevosample_ui_new_frame( sample, window, "capframe2", "Settings" ); for( i = 0; list[i] != NULL ; i++ ) { if(vj_unicap_get_range( srd->data, list[i], &min,&max )) { char *tkey = sample_translate_property(srd,list[i]); // translate property int type = vevo_property_atom_type( srd->info_port, list[i]); if(type==VEVO_ATOM_TYPE_DOUBLE) sprintf(format, "%s", "d" ); else sprintf(format, "%s", "i" ); sprintf(path, "/sample_%d/%s", id, tkey ); if( vj_unicap_property_is_menu( srd->data, list[i] )) { vevo_property_get( srd->info_port, list[i],0,&dv ); // void *msg = veejay_message_new_pulldown( osc_send,window,"combobox_capframe", "capframe2", list[i], path,dv,"none" ); void *msg = veejay_message_new_pulldown( osc_send,window,"capframe2", "combobox_capframe", list[i], path,dv,"none" ); vj_unicap_pack_menu( srd->data, list[i], osc_send, msg ); veejay_message_pulldown_done( osc_send, msg ); } else if( vj_unicap_property_is_range( srd->data, list[i] ) ) { vevosample_ui_new_numeric( sample,window, "capframe", list[i], min,max, (max*0.5), 0,0, "VSlider", path, format, "none" ); } free(tkey); } free(list[i]); } free(list); }
static void free_plugin(void *plugin) { void *handle = NULL; int error = vevo_property_get( plugin, "handle", 0 , &handle ); if( error == VEVO_NO_ERROR ) vevo_port_recursive_free( plugin ); if( handle ) dlclose( handle ); plugin = NULL; }
vj_effect *plug_get_plugin( int fx_id ) { void *port = index_map_[fx_id]; if(port == NULL) return NULL; vj_effect *vje = (vj_effect*) vj_calloc(sizeof(vj_effect)); size_t name_len = vevo_property_element_size( port, "name", 0); vje->description = (char*) vj_calloc(name_len); vevo_property_get( port, "name", 0 , &(vje->description)); vevo_property_get( port, "num_params", 0, &(vje->num_params)); vevo_property_get( port, "mixer", 0, &(vje->extra_frame)); if( vje->num_params > 0 ) { if( vje->num_params > SAMPLE_MAX_PARAMETERS ) { veejay_msg(VEEJAY_MSG_WARNING, "%s has %d parameters, supporting only %d.", vje->description,vje->num_params, SAMPLE_MAX_PARAMETERS ); vje->num_params = SAMPLE_MAX_PARAMETERS; } vje->defaults = (int*) vj_calloc(sizeof(int) * vje->num_params); vje->limits[0]= (int*) vj_calloc(sizeof(int) * vje->num_params); vje->limits[1]= (int*) vj_calloc(sizeof(int) * vje->num_params); int k = 0; int valid_p = 0; char **param_descr = NULL; if( vje->num_params > 0 ) param_descr = (char**) vj_calloc(sizeof(char*) * vje->num_params ); for( k = 0; k < vje->num_params;k++ ) { char key[20]; sprintf(key, "p%02d", k ); void *parameter = NULL; vevo_property_get( port, key, 0, ¶meter ); if(parameter) { vevo_property_get( parameter, "min", 0, &(vje->limits[0][k])); vevo_property_get( parameter, "max", 0, &(vje->limits[1][k])); vevo_property_get( parameter, "default", 0,&(vje->defaults[k])); param_descr[valid_p] = vevo_property_get_string(parameter,"name"); if(param_descr[valid_p]==NULL) param_descr[valid_p] = vj_strdup( "Number" ); valid_p ++; } } vje->num_params = valid_p; vje->param_description = param_descr; } return vje; }
static int memory_needed_for_port( void *port, const char *key ) { void *subport = NULL; int error = vevo_property_get( port , key, 0, &subport ); if( error != VEVO_NO_ERROR ) return 0; char **items = vevo_sprintf_port( subport ); int len = linear_len(items); int k = 0; for( k = 0; items[k] != NULL; k ++ ) free(items[k]); free(items); return len; }
static int _vevo_get_dbl( void *port, const char *key, int n_elem, lo_message lmsg ) { double *values = NULL; if( n_elem == 0 ) return VEVO_NO_ERROR; values = (double*) vj_malloc(sizeof(double) * n_elem ); int i; int error; for( i = 0; i < n_elem; i ++ ) { error = vevo_property_get( port, key, i, &(values[i])); lo_message_add_double( lmsg, values[i]); } 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 plug_build_name_space( int fx_id, void *fx_instance, void *data, int entry_id , int sample_id, generic_osc_cb_f cbf, void *cb_data) { void *plugin = index_map_[fx_id]; int type = 0; if( vevo_property_get( plugin, "HOST_plugin_type", 0, &type) == VEVO_NO_ERROR ) { switch( type ) { case VEVO_PLUG_LIVIDO: livido_plug_build_namespace( plugin, entry_id, fx_instance, data, sample_id, cbf, cb_data ); break; case VEVO_PLUG_FF: break; case VEVO_PLUG_FR: break; default: break; } } }
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); }
static char * flatten_port( void *port, const char *key ) { int len = memory_needed_for_port( port, key ); if( len <= 0 ) return NULL; char *res = (char*) vj_malloc( len ); void *subport = NULL; int error = vevo_property_get( port , key, 0, &subport ); if( error != VEVO_NO_ERROR ) return 0; memset(res,0,len); char **items = vevo_sprintf_port( subport ); int k = 0; for( k = 0; items[k] != NULL; k ++ ) { strncat(res, items[k],strlen(items[k])); free(items[k]); } free(items); return res; }
static void vj_midi_send_vims_now( vmidi_t *v, int *data ) { // format vims message and send it now // it would be nice to filter out unique events per frame step // this can be done by keeping a temporary vevo port // and store (instead of send) the VIMS message // including the sample_id and chain_entry_id but // cutting off all other arguments. // then, last SET_SPEED will overwrite any previous ones for this frame step. // // last, send all messages in temporary port out and cleanup char key[32]; if( v->learn ) { veejay_memcpy( v->learn_event, data, sizeof(v->learn_event )); vj_msg(VEEJAY_MSG_INFO, "MIDI %x:%x,%x -> ?", v->learn_event[0],v->learn_event[1], v->learn_event[2]); return; } snprintf(key,sizeof(key), "%03d%03d", data[0],data[1] ); //@ event key is midi event type + midi control/param id dvims_t *d = NULL; int error = vevo_property_get( v->vims, key, 0, &d); if( error == VEVO_NO_ERROR ) { if( d->extra ) { //@ argument is dynamic double min = 0.0; double max = 0.0; double val = 0.0; switch(d->extra) { case 1: //slider { GtkAdjustment *a = gtk_range_get_adjustment( GTK_RANGE( glade_xml_get_widget_( v->mw, d->widget ) ) ); min = a->lower; max = a->upper; } break; case 2: //spinbox gtk_spin_button_get_range( GTK_SPIN_BUTTON( glade_xml_get_widget_( v->mw, d->widget)), &min, &max); break; } if( data[0] == SND_SEQ_EVENT_PITCHBEND ) { val = ( (data[2]/16384.0f) * (max-min) ); } else if( data[0] == SND_SEQ_EVENT_CONTROLLER || data[0] == SND_SEQ_EVENT_KEYPRESS ) { val = ((max-min)/127.0) * data[2] + min; } else { vj_msg(VEEJAY_MSG_INFO, "MIDI: what's this %x,%x,%x ?",data[0],data[1],data[2]); return; } char vims_msg[255]; snprintf(vims_msg,sizeof(vims_msg), "%s %d;", d->msg, (int) val ); /* use control/param as sample_id */ int tmpv[3]; if ( sscanf(vims_msg, "%03d:%d %d;",&tmpv[0],&tmpv[1],&tmpv[2]) == 3 ) { if(tmpv[1] == 0 && tmpv[0] >= 100 && tmpv[0] < 200) //@ VIMS: sample events, replace 0 (current_id) for control/param number { snprintf(vims_msg,sizeof(vims_msg),"%03d:%d %d;", tmpv[0], data[1], (int)val); veejay_msg(VEEJAY_MSG_DEBUG, "(midi) using control/param %d as sample identifer",data[1]); } } msg_vims( vims_msg ); vj_msg(VEEJAY_MSG_INFO, "MIDI %x:%x, %x -> vims %s", data[0], data[1],data[2], vims_msg); } else { msg_vims( d->msg ); vj_msg(VEEJAY_MSG_INFO, "MIDI %x: %x,%x -> vims %s", data[0],data[1],data[2], d->msg); } } else { vj_msg(VEEJAY_MSG_ERROR, "No vims event for MIDI %x:%x,%x found",data[0],data[1],data[2]); } }