int setup(void){ int i, cnt = 5000; tl_class *class_list; // initialize globals ... rethink this tl_set_samplerate(44100); tl_set_block_len(64); set_g_lvl_stck(init_lvl_stck()); set_g_ctl_head(init_ctl(TL_HEAD_CTL)); // TODO: attach these to modules, I can't see // any reason not to do this and automate this whole process ctl_l_freq = init_ctl(TL_LIN_CTL); ctl_r_freq = init_ctl(TL_LIN_CTL); ctl_l_freq->is_verbose = 0; ctl_r_freq->is_verbose = 0; ctl_l_amp = init_ctl(TL_LIN_CTL); ctl_r_amp = init_ctl(TL_LIN_CTL); ctl_l_amp->is_verbose = 1; ctl_r_amp->is_verbose = 1; install_onto_ctl_list(get_g_ctl_head(), ctl_l_freq); install_onto_ctl_list(get_g_ctl_head(), ctl_r_freq); install_onto_ctl_list(get_g_ctl_head(), ctl_l_amp); install_onto_ctl_list(get_g_ctl_head(), ctl_r_amp); // initialize portaudio pa_initialize(0,0,2,2,.25); // setup the modules dac = (tl_dac *)tl_init_dac(2,1); // dac will initialize the global output buffer return 0; }
EXPORT int iaxc_initialize(int num_calls) { int i; int port; os_init(); setup_jb_output(); MUTEXINIT(&iaxc_lock); MUTEXINIT(&event_queue_lock); iaxc_set_audio_prefs(0); if ( iaxc_recvfrom != (iaxc_recvfrom_t)recvfrom ) iax_set_networking(iaxc_sendto, iaxc_recvfrom); /* Note that iax_init() only sets up the receive port when the * sendto/recvfrom functions have not been replaced. We need * to call iaxc_init in either case because there is other * initialization beyond the socket setup that needs to be done. */ if ( (port = iax_init(source_udp_port)) < 0 ) { iaxci_usermsg(IAXC_ERROR, "Fatal error: failed to initialize iax with port %d", port); return -1; } if ( iaxc_recvfrom == (iaxc_recvfrom_t)recvfrom ) iaxci_bound_port = port; else iaxci_bound_port = -1; /* tweak the jitterbuffer settings */ iax_set_jb_target_extra( jb_target_extra ); max_calls = num_calls; /* initialize calls */ if ( max_calls <= 0 ) max_calls = 1; /* 0 == Default? */ /* calloc zeroes for us */ calls = (struct iaxc_call *)calloc(sizeof(struct iaxc_call), max_calls); if ( !calls ) { iaxci_usermsg(IAXC_ERROR, "Fatal error: can't allocate memory"); return -1; } selected_call = -1; for ( i = 0; i < max_calls; i++ ) { strncpy(calls[i].callerid_name, DEFAULT_CALLERID_NAME, IAXC_EVENT_BUFSIZ); strncpy(calls[i].callerid_number, DEFAULT_CALLERID_NUMBER, IAXC_EVENT_BUFSIZ); } if ( !test_mode ) { #ifndef AUDIO_ALSA if ( pa_initialize(&audio_driver, 8000) ) { iaxci_usermsg(IAXC_ERROR, "failed pa_initialize"); return -1; } #else /* TODO: It is unknown whether this stuff for direct access to * alsa should be left in iaxclient. We're leaving it in here for * the time being, but unless it becomes clear that someone cares * about having it, it will be removed. Also note that portaudio * is capable of using alsa. This is another reason why this * direct alsa access may be unneeded. */ if ( alsa_initialize(&audio_driver, 8000) ) return -1; #endif } #ifdef USE_VIDEO if ( video_initialize() ) iaxci_usermsg(IAXC_ERROR, "iaxc_initialize: cannot initialize video!\n"); #endif /* Default audio format capabilities */ audio_format_capability = IAXC_FORMAT_ULAW | IAXC_FORMAT_ALAW | #ifdef CODEC_GSM IAXC_FORMAT_GSM | #endif IAXC_FORMAT_SPEEX; audio_format_preferred = IAXC_FORMAT_SPEEX; return 0; }
int setup(void){ int i, cnt = 5000; tl_class *class_list; // initialize globals ... rethink this tl_set_samplerate(44100); tl_set_block_len(64); set_g_lvl_stck(init_lvl_stck()); set_g_ctl_head(init_ctl(TL_HEAD_CTL)); // TODO: attach these to modules, I can't see // any reason not to do this and automate this whole process ctl_l_freq = init_ctl(TL_LIN_CTL); ctl_r_freq = init_ctl(TL_LIN_CTL); ctl_l_freq->is_verbose = 0; ctl_r_freq->is_verbose = 0; ctl_l_amp = init_ctl(TL_LIN_CTL); ctl_r_amp = init_ctl(TL_LIN_CTL); ctl_l_amp->is_verbose = 1; ctl_r_amp->is_verbose = 1; install_onto_ctl_list(get_g_ctl_head(), ctl_l_freq); install_onto_ctl_list(get_g_ctl_head(), ctl_r_freq); install_onto_ctl_list(get_g_ctl_head(), ctl_l_amp); install_onto_ctl_list(get_g_ctl_head(), ctl_r_amp); // initialize portaudio pa_initialize(0,0,2,2,.25); // setup the modules dac = (tl_dac *)tl_init_dac(2,1); // dac will initialize the global output buffer tbl_l = (tl_table *)tl_init_table(1000, 1); tbl_r = (tl_table *)tl_init_table(1000, 1); lkup_l = (tl_lookup *)tl_init_lookup(1); lkup_r = (tl_lookup *)tl_init_lookup(1); osc_l = init_osc(tbl_l, lkup_l, ctl_l_freq->outlet, ctl_l_amp->outlet); osc_r = init_osc(tbl_r, lkup_r, ctl_r_freq->outlet, ctl_r_amp->outlet); // this part needs to be done explicitly // first, register the ctls set_ctl_kr(ctl_l_freq, &l_freq_val); set_ctl_kr(ctl_r_freq, &r_freq_val); set_ctl_kr(ctl_l_amp, &l_amp_val); set_ctl_kr(ctl_r_amp, &r_amp_val); // now register the classes set_g_class_head(init_class()); tl_install_class(get_g_class_head(), (void *)osc_l, osc_l->dsp_func, osc_l->kill_func); tl_install_class(get_g_class_head(), (void *)osc_r, osc_r->dsp_func, osc_r->kill_func); tl_install_class(get_g_class_head(), (void *)dac, dac->dsp_func, dac->kill_func); // connect to the dac dac->inlets[0] = osc_l->tbl->outlets[0]; dac->inlets[1] = osc_r->tbl->outlets[0]; return 0; }