void initSynth(struct b_instance *inst, double rate) { // equivalent to ../src/main.c main() unsigned int defaultPreset[9] = {8,8,6, 0,0,0,0, 0,0}; /* initAll() */ initToneGenerator (inst->synth, inst->midicfg); initVibrato (inst->synth, inst->midicfg); initPreamp (inst->preamp, inst->midicfg); initReverb (inst->reverb, inst->midicfg, rate); initWhirl (inst->whirl, inst->midicfg, rate); initRunningConfig(inst->state, inst->midicfg); /* end - initAll() */ initMidiTables(inst->midicfg); setDrawBars (inst, 0, defaultPreset); #if 0 setDrawBars (inst, 1, defaultPreset); setDrawBars (inst, 2, defaultPreset); #endif #ifdef DEBUGPRINT if (walkProgrammes(inst->progs, 0)) { listProgrammes (inst->progs, stderr); } listCCAssignments(inst->midicfg, stderr); #endif }
/* * Ask each module to initialize itself. */ static void initAll () { fprintf (stderr, "init.. "); fprintf (stderr, "Audio : "); fflush (stderr); /* Open the JACK connection and get samplerate. */ if (open_jack()) { perror ("could not connect to JACK."); exit(1); } fprintf (stderr, "Oscillators : "); fflush (stderr); initToneGenerator (inst.synth, inst.midicfg); fprintf (stderr, "Scanner : "); fflush (stderr); initVibrato (inst.synth, inst.midicfg); fprintf (stderr, "Overdrive : "); fflush (stderr); initPreamp (inst.preamp, inst.midicfg); fprintf (stderr, "Reverb : "); fflush (stderr); initReverb (inst.reverb, inst.midicfg, SampleRateD); fprintf (stderr, "Whirl : "); fflush (stderr); initWhirl (inst.whirl, inst.midicfg, SampleRateD); #ifdef HAVE_ZITACONVOLVE fprintf (stderr, "Convolve : "); fflush (stderr); int s_policy= 0; struct sched_param s_param; memset (&s_param, 0, sizeof(struct sched_param)); if (jack_client_thread_id(j_client)) { pthread_getschedparam(jack_client_thread_id(j_client), &s_policy, &s_param); } else { fprintf(stderr, "zita-convolver: not using RT scheduling\n"); } initConvolution(NULL, inst.midicfg, AUDIO_CHANNELS, BUFFER_SIZE_SAMPLES, s_param.sched_priority, s_policy); #endif fprintf (stderr, "RC : "); fflush (stderr); initRunningConfig(inst.state, inst.midicfg); fprintf (stderr, "..done.\n"); }
static LV2_Handle instantiate (const LV2_Descriptor* descriptor, double rate, const char* bundle_path, const LV2_Feature* const* features) { B3O* b3o = (B3O*)calloc (1, sizeof (B3O)); b3o->o_bias = b3o->o_feedback = b3o->o_sagtobias = b3o->o_postfeed = b3o->o_globfeed = b3o->o_gainin = b3o->o_gainout = -1; b3o->pa = allocPreamp (); initPreamp (b3o->pa, NULL); return (LV2_Handle)b3o; }
int main (int argc, char**argv) { int osc_port=0; void *pa = allocPreamp(); initPreamp(pa, NULL); int c; const char *optstring = "hi:o:O:p:V"; struct option long_options[] = { { "help", no_argument, 0, 'h' }, { "input", no_argument, 0, 'i' }, { "output", no_argument, 0, 'o' }, { "parameter", required_argument, 0, 'p' }, { "version", no_argument, 0, 'V' }, { 0, 0, 0, 0 } }; while ((c = getopt_long(argc, argv, optstring, long_options, NULL)) != -1) { switch (c) { case 'h': usage("jboverdrive", 0); return (0); break; case 'i': jack_inport_name=optarg; break; case 'o': jack_outport_name=optarg; break; case 'O': osc_port=atoi(optarg); break; case 'p': { int ok=0; char *t = strchr(optarg, '='); if (t) { *t='\0'; if (!strcasecmp(optarg, "bias")) {ok=1; p_bias =pp(t+1);} if (!strcasecmp(optarg, "feedback")) {ok=1; p_feedback =pp(t+1);} if (!strcasecmp(optarg, "sagtobias")) {ok=1; p_sagtobias=pp(t+1);} if (!strcasecmp(optarg, "postfeed")) {ok=1; p_postfeed =pp(t+1);} if (!strcasecmp(optarg, "globfeed")) {ok=1; p_globfeed =pp(t+1);} if (!strcasecmp(optarg, "gainin")) {ok=1; p_gainin =pp(t+1);} if (!strcasecmp(optarg, "gainout")) {ok=1; p_gainout =pp(t+1);} *t='='; } if (!ok) { fprintf(stderr, "invalid parameter '%s' given.\n", optarg); } } break; case 'V': printf ("%s %s\n\n", "jboverdrive", VERSION); printf( "Copyright (C) 2003-2004 Fredrik Kilander <*****@*****.**>\n" "Copyright (C) 2012 Robin Gareus <*****@*****.**>\n" "\n" "This is free software; see the source for copying conditions. There is NO\n" "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n" ); return(0); default: fprintf(stderr, "invalid argument.\n"); usage("jboverdrive", 1); } } if (osc_port) { #ifdef HAVE_LIBLO if (init_osc(osc_port)) osc_port=0; #else fprintf(stderr, "This version has not been compiled with liblo.\nOSC is not available.\n"); #endif } j_client = jack_client_open ("b_overdrive", JackNullOption, NULL); if (!j_client) { fprintf(stderr, "could not connect to jack.\n"); return(1); } j_input_port = jack_port_register (j_client, "in", JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0); j_output_port = jack_port_register (j_client, "out", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); if (!j_output_port || !j_input_port) { fprintf(stderr, "no more jack ports available.\n"); jack_client_close (j_client); return(1); } jack_on_shutdown (j_client, jack_shutdown_callback, NULL); jack_set_process_callback(j_client,jack_audio_callback, pa); #ifndef _WIN32 signal (SIGHUP, catchsig); signal (SIGINT, catchsig); #endif fctl_biased (pa, p_bias); fctl_biased_fb (pa, p_feedback); fctl_sagtoBias (pa, p_sagtobias); fctl_biased_fb2 (pa, p_postfeed); fctl_biased_gfb (pa, p_globfeed); fsetInputGain (pa, p_gainin); fsetOutputGain (pa, p_gainout); jack_activate(j_client); connect_jack_ports(); while (j_client) { // TODO interaction; allow to change parameters // via terminal I/O sleep (1); } #ifdef HAVE_LIBLO if (osc_port) { shutdown_osc(); } #endif freePreamp(pa); return (0); }