NameEntry* name_push(char *name, NameEntry **entry) { if (name_find(*entry, name) >= 0) return *entry; NameEntry *n = name_new(name); n->next = *entry; *entry = n; return n; }
void tl_init_triode(tl_arglist *args){ tl_procession *procession; // for dac // check for a procession in the args if(args->argv[0]->type!=TL_PROCESSION) { printf("error: tl_init_moog_abuse: first init argument needs to be a valid procession pointer\n"); return; } else procession = args->argv[0]->procession; // initialize solver: solver = tl_init_UDS_solver(0, // ins 1, // 1); // upsampling (not yet implemented) // dac: dac = tl_init_dac(procession, 2, 1); // adc: adc = tl_init_adc(procession, 1, 1); solver->inlets[0] = adc->outlets[0]; // control interface: ctls = init_ctl(TL_HEAD_CTL); // init ctls here // init controls b_reset = init_ctl(TL_BANG_CTL); b_reset->name = name_new("reset"); b_reset->bang_func = reset; install_onto_ctl_list(ctls, b_reset); // hook up to dac dac->inlets[0] = solver->outlets[0]; dac->inlets[1] = adc->outlets[0]; }
tl_name cpy_file_name_no_path(char *full_path){ char *file_name, *pch, *name; int i; i = strlen(full_path); // go to final / if any while(full_path[i]!='/'&&i>=0)i--; // copy the string into a buffer file_name = strdup(full_path+i+1); printf("%s\n",file_name); // kill the file extension if(pch = strchr(file_name, '.')) *pch = '\0'; name = name_new(file_name); free(file_name); return name; }
// init func void tl_init_lotka_volt(tl_arglist *args){ tl_procession *procession; // needed for DAC // check for a procession in the args if(args->argv[0]->type!=TL_PROCESSION) { printf("error: tl_init_fm : first init argument needs to be a valid procession pointer\n"); return; } else procession = args->argv[0]->procession; // initialize the solver solver = tl_init_UDS_solver(2, N_NODES, 1); // we need a dac, so make one dac = tl_init_dac(procession, N_NODES, 1); // initialize the local ctl list head lotka_volt_head = init_ctl(TL_HEAD_CTL); // initialize lotka_volt solver nodes prey_node = tl_init_UDS_node(prey_dot, N_NODES, 1); tl_reset_UDS_node(prey_node, 0.0); tl_push_UDS_node(solver->UDS_net, prey_node); pred_node = tl_init_UDS_node(pred_dot, N_NODES, 1); tl_reset_UDS_node(pred_node, 0.0); tl_push_UDS_node(solver->UDS_net, pred_node); // hook up the inlets and outlets pred_node->data_in[0] = prey_node->data_out; pred_node->data_in[1] = pred_node->data_out; prey_node->data_in[0] = prey_node->data_out; prey_node->data_in[1] = pred_node->data_out; // ctl setup int i; char buf[50]; k_alpha = init_ctl(TL_LIN_CTL); sprintf(buf, "k_alpha"); k_alpha->name = name_new(buf); set_ctl_val(k_alpha, 0); install_onto_ctl_list(lotka_volt_head, k_alpha); k_beta = init_ctl(TL_LIN_CTL); sprintf(buf, "k_beta"); k_beta->name = name_new(buf); set_ctl_val(k_beta, 0); install_onto_ctl_list(lotka_volt_head, k_beta); k_delta = init_ctl(TL_LIN_CTL); sprintf(buf, "k_delta"); k_delta->name = name_new(buf); set_ctl_val(k_delta, 0); install_onto_ctl_list(lotka_volt_head, k_delta); k_gamma = init_ctl(TL_LIN_CTL); sprintf(buf, "k_gamma"); k_gamma->name = name_new(buf); set_ctl_val(k_gamma, 0); install_onto_ctl_list(lotka_volt_head, k_gamma); k_m0 = init_ctl(TL_LIN_CTL); sprintf(buf, "k_m0"); k_m0->name = name_new(buf); set_ctl_val(k_m0, 0); install_onto_ctl_list(lotka_volt_head, k_m0); k_m1 = init_ctl(TL_LIN_CTL); sprintf(buf, "k_m1"); k_m1->name = name_new(buf); set_ctl_val(k_m1, 0); install_onto_ctl_list(lotka_volt_head, k_m1); for(i=0;i<N_NODES;i++) { k_states[i] = init_ctl(TL_LIN_CTL); sprintf(buf, "k_states_%d", i); k_states[i]->name = name_new(buf); set_ctl_val(k_states[i], 0); install_onto_ctl_list(lotka_volt_head, k_states[i]); } // set up the set function b_set_lotka_volt = init_ctl(TL_BANG_CTL); b_set_lotka_volt->name = name_new("set_lotka_volt_states"); b_set_lotka_volt->bang_func = set_lotka_volt; install_onto_ctl_list(lotka_volt_head, b_set_lotka_volt); // hookup oulets to dac for(i=0;i<N_NODES;i++) dac->inlets[i] = solver->outlets[i]; }
static tl_UDS_osc *init_UDS_osc(int which){ tl_UDS_osc *x = malloc(sizeof(tl_UDS_osc)); char buf[50]; int i; // initialize the nodes x->sin_node = tl_init_UDS_node(osc_sin, osc_cnt*2, 1); x->cos_node = tl_init_UDS_node(osc_cos, osc_cnt*2, 1); // initialize the controls x->k_osc_freq = init_ctl(TL_LIN_CTL); sprintf(buf, "k_osc_freq_%d", which); x->k_osc_freq->name = name_new(buf); set_ctl_val(x->k_osc_freq, 440); install_onto_ctl_list(osc_head, x->k_osc_freq); x->k_sync_thresh = init_ctl(TL_LIN_CTL); sprintf(buf, "k_sync_thresh_%d", which); x->k_sync_thresh->name = name_new(buf); set_ctl_val(x->k_sync_thresh, .9); install_onto_ctl_list(osc_head, x->k_sync_thresh); x->k_delta = init_ctl(TL_LIN_CTL); sprintf(buf, "k_delta_%d", which); x->k_delta->name = name_new(buf); set_ctl_val(x->k_delta, 0); install_onto_ctl_list(osc_head, x->k_delta); x->k_sync_g = init_ctl(TL_LIN_CTL); sprintf(buf, "k_sync_g_%d", which); x->k_sync_g->name = name_new(buf); set_ctl_val(x->k_sync_g, 1); install_onto_ctl_list(osc_head, x->k_sync_g); x->k_alpha = init_ctl(TL_LIN_CTL); sprintf(buf, "k_alpha_%d", which); x->k_alpha->name = name_new(buf); set_ctl_val(x->k_alpha, 0); install_onto_ctl_list(osc_head, x->k_alpha); x->k_beta = init_ctl(TL_LIN_CTL); sprintf(buf, "k_beta_%d", which); x->k_beta->name = name_new(buf); set_ctl_val(x->k_beta, 0); install_onto_ctl_list(osc_head, x->k_beta); for(i=0;i<osc_cnt;i++) { x->k_mod_depth[i] = init_ctl(TL_LIN_CTL); sprintf(buf, "k_mod_depth_%d_%d", which,i); x->k_mod_depth[i]->name = name_new(buf); set_ctl_val(x->k_mod_depth[i], 0); install_onto_ctl_list(osc_head, x->k_mod_depth[i]); } for(i=0;i<osc_cnt;i++) { x->k_gamma[i] = init_ctl(TL_LIN_CTL); sprintf(buf, "k_gamma_%d_%d", which,i); x->k_gamma[i]->name = name_new(buf); set_ctl_val(x->k_gamma[i], 0); install_onto_ctl_list(osc_head, x->k_gamma[i]); } // the other variables x->is_sync = 0; x->which = which; // stack the ctls together /* x->k_osc_freq->next = x->k_sync_thresh; */ /* x->k_sync_thresh->next = x->k_delta; */ /* x->k_delta->next = x->k_sync_g; */ /* x->k_sync_g->next = x->k_alpha; */ /* x->k_alpha->next = x->k_beta; */ /* x->k_beta->next = x->k_gamma[0]; */ /* //x->k_sync_g->next = x->k_mod_depth[0]; */ /* for(i=1;i<osc_cnt;i++) */ /* x->k_mod_depth[i-1]->next = x->k_mod_depth[i]; */ x->alphas = malloc(sizeof(tl_smp)*osc_cnt*tl_get_block_len()); for(i=0;i<osc_cnt*tl_get_block_len();i++) x->alphas[i] = 0; // copy the top ctl ptr into the node stuctures x->sin_node->ctls = x->k_osc_freq; x->cos_node->ctls = x->k_osc_freq; // copy them all into the global ctl processor /* install_onto_ctl_list(osc_head, x->k_osc_freq); */ return x; }
// init func void tl_init_fm_duff(tl_arglist *args){ int i, j; tl_procession *procession; // needed for DAC // check for a procession in the args if(args->argv[0]->type!=TL_PROCESSION) { printf("error: tl_init_fm : first init argument needs to be a valid procession pointer\n"); return; } else procession = args->argv[0]->procession; // initialize the solver solver = tl_init_UDS_solver(0, osc_cnt*2, 1); // we need a dac, so make one dac = tl_init_dac(procession, osc_cnt*2, 1); // initialize the local ctl list head osc_head = init_ctl(TL_HEAD_CTL); // initialize the oscillator parts oscs = malloc(sizeof(tl_UDS_osc *) * osc_cnt); for(i=0;i<osc_cnt; i++) { // initialize oscs[i] = init_UDS_osc(i); // install into the solver oscs[i]->sin_node->extra_data = (void *)oscs[i]; oscs[i]->cos_node->extra_data = (void *)oscs[i]; tl_push_UDS_node(solver->UDS_net, oscs[i]->sin_node); tl_push_UDS_node(solver->UDS_net, oscs[i]->cos_node); } for(i=0;i<osc_cnt*2; i++) dac->inlets[i] = solver->outlets[i]; reset_oscs(); // initialize the oscillators' states // connect the outlet of each oscillator to a each inlet on each one // including its own int k; for(i=0;i<osc_cnt;i++) { k = 0; for(j=0;j<osc_cnt*2;j+=2) { // arrange the inputs in the same order for each oscillator oscs[i]->sin_node->data_in[j] = oscs[k]->sin_node->data_out; oscs[i]->cos_node->data_in[j] = oscs[k]->sin_node->data_out; oscs[i]->sin_node->data_in[j+1] = oscs[k]->cos_node->data_out; oscs[i]->cos_node->data_in[j+1] = oscs[k++]->cos_node->data_out; } } // define the reset function bang ctl b_reset = init_ctl(TL_BANG_CTL); b_reset->name = name_new("reset_fm_oscs"); b_reset->bang_func = reset_oscs; install_onto_ctl_list(osc_head, b_reset); tl_ctl *next_toggle; char buf[50]; int cnt = 0; next_toggle = b_sync_toggle; for(i=0;i<osc_cnt;i++) for(j=0;j<osc_cnt;j++) { // initialize the control with appropriate name sprintf(buf, "b_sync_toggle_%d_%d",i+1, j+1); next_toggle = init_ctl(TL_BANG_CTL); next_toggle->name = name_new(buf); // give it a numeric tag toggle_data[cnt][0] = i; toggle_data[cnt][1] = j; // set the bang function next_toggle->bang_func = set_sync_matrix; // assign the tag set_ctl_bang_data(next_toggle, (void *)toggle_data[cnt++]); //printf("tl_init_fm: %p %p\n",toggle_data, next_toggle->bang_data); // install the current ctl install_onto_ctl_list(osc_head, next_toggle); } for(i=0;i<osc_cnt;i++) for(j=0;j<osc_cnt;j++) sync_matrix[i][j] = 0; }